Interface QueueCircuitBreakerStorage

    • Method Detail

      • getQueueCircuitInformation

        io.vertx.core.Future<io.vertx.core.json.JsonObject> getQueueCircuitInformation​(String circuitHash)
        Get the information (status, failRatio and circuit) of the circuit represented by the provided circuitHash.
        Parameters:
        circuitHash - the hash representing the circuit to get the informations from
        Returns:
        returns a JsonObject containing the information of the circuit
      • getAllCircuits

        io.vertx.core.Future<io.vertx.core.json.JsonObject> getAllCircuits()
        Get the information (status, failRatio and circuit) of all circuits.
        Returns:
        returns a JsonObject containing the information of all circuits
      • updateStatistics

        io.vertx.core.Future<UpdateStatisticsResult> updateStatistics​(PatternAndCircuitHash patternAndCircuitHash,
                                                                      String uniqueRequestID,
                                                                      long timestamp,
                                                                      int errorThresholdPercentage,
                                                                      long entriesMaxAgeMS,
                                                                      long minQueueSampleCount,
                                                                      long maxQueueSampleCount,
                                                                      QueueResponseType queueResponseType)

        Updates the statistics of the corresponding circuit based on the provided patternAndCircuitHash.

        Updating the statistics includes the following steps:

        • Record uniqueRequestID as failed when queueResponseType equals QueueResponseType.FAILURE
        • Record uniqueRequestID as success when queueResponseType equals QueueResponseType.SUCCESS
        • Calculate failRatio based on fail/success records not older than entriesMaxAgeMS
        • Change status of corresponding circuit to 'OPEN' when minQueueSampleCount and errorThresholdPercentage is reached
        • Remove oldest fail/success records when maxQueueSampleCount is reached
        Parameters:
        patternAndCircuitHash - the information of the circuit
        uniqueRequestID - the unique identifier of the queued request
        timestamp - the current timestamp
        errorThresholdPercentage - the threshold to change status to 'OPEN' when reached
        entriesMaxAgeMS - the maximum age of fail/success records to respect to calculate the failRatio
        minQueueSampleCount - the minimum amount of records (unique uniqueRequestIDs) to reach before status can be changed
        maxQueueSampleCount - the maximum amount of fail/success records to keep
        queueResponseType - the QueueResponseType representing the execution result of the queuedRequest
        Returns:
        returns an UpdateStatisticsResult object representing the result of the statistics update
      • lockQueue

        io.vertx.core.Future<Void> lockQueue​(String queueName,
                                             PatternAndCircuitHash patternAndCircuitHash)
        Mark the queueName as a locked queue of the circuit representing the provided patternAndCircuitHash.
        Parameters:
        queueName - the name of the queue
        patternAndCircuitHash - the information of the circuit
        Returns:
        returns a void Future when the queue could be successfully marked as locked
      • popQueueToUnlock

        io.vertx.core.Future<String> popQueueToUnlock()
        Get the next queue to unlock. When successful, the queue is removed from the storage.
        Returns:
        returns a Future holding the name of the next queue or null when no queue was found
      • closeCircuit

        io.vertx.core.Future<Void> closeCircuit​(PatternAndCircuitHash patternAndCircuitHash)

        Closes the circuit.

        Closing the circuit includes the following steps:

        • Clear statistics of this circuit
        • Reset failRatio of this circuit to zero
        • Set status of this circuit to 'CLOSED'
        • Unlock all queues related to this circuit
        Parameters:
        patternAndCircuitHash - the information of the circuit
        Returns:
        returns a void Future when circuit could be closed successfully.
      • closeAndRemoveCircuit

        io.vertx.core.Future<Void> closeAndRemoveCircuit​(PatternAndCircuitHash patternAndCircuitHash)
        Closes the circuit and removes all circuit information from storage.
        Parameters:
        patternAndCircuitHash - the information of the circuit
        Returns:
        returns a void Future when circuit could be closed and removed successfully.
      • closeAllCircuits

        io.vertx.core.Future<Void> closeAllCircuits()

        Closes all non-closed circuits.

        Closing all non-closed circuits includes the following steps:

        • Clear statistics of all non-closed circuits
        • Reset failRatio of all non-closed circuits to zero
        • Set status of all non-closed circuits to 'CLOSED'
        • Unlock all queues related to all non-closed circuits
        Returns:
        returns a void Future when all non-closed circuits could be closed successfully.
      • reOpenCircuit

        io.vertx.core.Future<Void> reOpenCircuit​(PatternAndCircuitHash patternAndCircuitHash)
        Re-Opens the (half-open) circuit again. Circuits should be re-opened after a sample queue request was not successful.
        Parameters:
        patternAndCircuitHash - the information of the circuit
        Returns:
        returns a void Future when the circuit could be re-opened successfully
      • unlockSampleQueues

        io.vertx.core.Future<io.vertx.redis.client.Response> unlockSampleQueues()
        Get a list of sample queues of all circuits having a status equals QueueCircuitState.HALF_OPEN. The sample queues are always the queues which have not been unlocked the longest. Each sample queue of each circuit is then updated to be the 'most recently' unlocked queue.
        Returns:
        returns a Future holding a list of sample queues to unlock