Class RedisQueueCircuitBreakerStorage

    • Method Detail

      • getQueueCircuitInformation

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

        public io.vertx.core.Future<io.vertx.core.json.JsonObject> getAllCircuits()
        Description copied from interface: QueueCircuitBreakerStorage
        Get the information (status, failRatio and circuit) of all circuits.
        Specified by:
        getAllCircuits in interface QueueCircuitBreakerStorage
        Returns:
        returns a JsonObject containing the information of all circuits
      • updateStatistics

        public io.vertx.core.Future<UpdateStatisticsResult> updateStatistics​(PatternAndCircuitHash patternAndCircuitHash,
                                                                             String uniqueRequestID,
                                                                             long timestamp,
                                                                             int errorThresholdPercentage,
                                                                             long entriesMaxAgeMS,
                                                                             long minQueueSampleCount,
                                                                             long maxQueueSampleCount,
                                                                             QueueResponseType queueResponseType)
        Description copied from interface: QueueCircuitBreakerStorage

        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
        Specified by:
        updateStatistics in interface QueueCircuitBreakerStorage
        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

        public io.vertx.core.Future<Void> lockQueue​(String queueName,
                                                    PatternAndCircuitHash patternAndCircuitHash)
        Description copied from interface: QueueCircuitBreakerStorage
        Mark the queueName as a locked queue of the circuit representing the provided patternAndCircuitHash.
        Specified by:
        lockQueue in interface QueueCircuitBreakerStorage
        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

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

        public io.vertx.core.Future<Void> closeCircuit​(PatternAndCircuitHash patternAndCircuitHash)
        Description copied from interface: QueueCircuitBreakerStorage

        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
        Specified by:
        closeCircuit in interface QueueCircuitBreakerStorage
        Parameters:
        patternAndCircuitHash - the information of the circuit
        Returns:
        returns a void Future when circuit could be closed successfully.
      • closeAndRemoveCircuit

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

        public io.vertx.core.Future<Void> closeAllCircuits()
        Description copied from interface: QueueCircuitBreakerStorage

        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
        Specified by:
        closeAllCircuits in interface QueueCircuitBreakerStorage
        Returns:
        returns a void Future when all non-closed circuits could be closed successfully.
      • reOpenCircuit

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

        public io.vertx.core.Future<io.vertx.redis.client.Response> unlockSampleQueues()
        Description copied from interface: QueueCircuitBreakerStorage
        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.
        Specified by:
        unlockSampleQueues in interface QueueCircuitBreakerStorage
        Returns:
        returns a Future holding a list of sample queues to unlock