public class QueueCircuitBreakerImpl extends Object implements QueueCircuitBreaker, RuleProvider.RuleChangesObserver, Refreshable
| Modifier and Type | Field and Description |
|---|---|
static String |
OPEN_TO_HALF_OPEN_TASK_LOCK |
static String |
UNLOCK_QUEUES_TASK_LOCK |
static String |
UNLOCK_SAMPLE_QUEUES_TASK_LOCK |
| Constructor and Description |
|---|
QueueCircuitBreakerImpl(io.vertx.core.Vertx vertx,
Lock lock,
String redisquesAddress,
QueueCircuitBreakerStorage queueCircuitBreakerStorage,
RuleProvider ruleProvider,
QueueCircuitBreakerRulePatternToCircuitMapping ruleToCircuitMapping,
QueueCircuitBreakerConfigurationResourceManager configResourceManager,
io.vertx.core.Handler<io.vertx.core.http.HttpServerRequest> queueCircuitBreakerHttpRequestHandler,
int requestHandlerPort)
Constructor for the QueueCircuitBreakerImpl.
|
| Modifier and Type | Method and Description |
|---|---|
io.vertx.core.Future<Void> |
closeAllCircuits()
Closes all non-closed circuits.
|
io.vertx.core.Future<Void> |
closeCircuit(HttpRequest queuedRequest)
Closes the circuit representing the queued request.
|
io.vertx.core.Future<QueueCircuitState> |
handleQueuedRequest(String queueName,
HttpRequest queuedRequest)
Handles a queued request by checking the current
QueueCircuitState of the corresponding circuit. |
boolean |
isCircuitCheckEnabled()
Check whether the circuit check is enabled.
|
boolean |
isStatisticsUpdateEnabled()
Check whether the statistics update is enabled.
|
io.vertx.core.Future<Void> |
lockQueue(String queueName,
HttpRequest queuedRequest)
Locks the queue having the provided queueName by calling the vertx-redisques API.
|
void |
refresh() |
io.vertx.core.Future<Void> |
reOpenCircuit(HttpRequest queuedRequest)
Re-Opens the (half-open) circuit representing the provided queued request again.
|
void |
rulesChanged(List<Rule> rules) |
io.vertx.core.Future<Long> |
setOpenCircuitsToHalfOpen()
Changes the status of all circuits having a status equals
QueueCircuitState.OPEN
to QueueCircuitState.HALF_OPEN. |
io.vertx.core.Future<String> |
unlockNextQueue()
Unlocks the next queue in-line.
|
io.vertx.core.Future<String> |
unlockQueue(String queueName)
Unlocks the queue having the provided queueName by calling the vertx-redisques API.
|
io.vertx.core.Future<Long> |
unlockSampleQueues()
Unlocks a sample queue of all circuits having a status equals
QueueCircuitState.HALF_OPEN. |
io.vertx.core.Future<Void> |
updateStatistics(String queueName,
HttpRequest queuedRequest,
QueueResponseType queueResponseType)
Updates the statistics of the corresponding circuit based on the provided request to execute.
|
public static final String OPEN_TO_HALF_OPEN_TASK_LOCK
public static final String UNLOCK_QUEUES_TASK_LOCK
public static final String UNLOCK_SAMPLE_QUEUES_TASK_LOCK
public QueueCircuitBreakerImpl(io.vertx.core.Vertx vertx,
Lock lock,
String redisquesAddress,
QueueCircuitBreakerStorage queueCircuitBreakerStorage,
RuleProvider ruleProvider,
QueueCircuitBreakerRulePatternToCircuitMapping ruleToCircuitMapping,
QueueCircuitBreakerConfigurationResourceManager configResourceManager,
io.vertx.core.Handler<io.vertx.core.http.HttpServerRequest> queueCircuitBreakerHttpRequestHandler,
int requestHandlerPort)
vertx - vertxlock - the lock implementationredisquesAddress - the event bus address of redisquesqueueCircuitBreakerStorage - the storageruleProvider - the provider for the rule objectsruleToCircuitMapping - ruleToCircuitMapping helper classconfigResourceManager - the manager for the configuration resourcequeueCircuitBreakerHttpRequestHandler - request handlerrequestHandlerPort - the port to listen topublic void rulesChanged(List<Rule> rules)
rulesChanged in interface RuleProvider.RuleChangesObserverpublic void refresh()
refresh in interface Refreshablepublic boolean isCircuitCheckEnabled()
QueueCircuitBreakerisCircuitCheckEnabled in interface QueueCircuitBreakerpublic boolean isStatisticsUpdateEnabled()
QueueCircuitBreakerisStatisticsUpdateEnabled in interface QueueCircuitBreakerpublic io.vertx.core.Future<QueueCircuitState> handleQueuedRequest(String queueName, HttpRequest queuedRequest)
QueueCircuitBreakerQueueCircuitState of the corresponding circuit.
When the QueueCircuitState of the corresponding circuit equals QueueCircuitState.OPEN,
the provided queueName will be locked.handleQueuedRequest in interface QueueCircuitBreakerqueueName - the name of the queuequeuedRequest - the queued requestQueueCircuitState representing the current status of the circuitpublic io.vertx.core.Future<Void> updateStatistics(String queueName, HttpRequest queuedRequest, QueueResponseType queueResponseType)
QueueCircuitBreakerUpdates the statistics of the corresponding circuit based on the provided request to execute.
Updating the statistics includes the following steps:
QueueResponseType.FAILUREQueueResponseType.SUCCESSupdateStatistics in interface QueueCircuitBreakerqueueName - the name of the queuequeuedRequest - the queued requestqueueResponseType - the QueueResponseType representing the execution result of the queuedRequestpublic io.vertx.core.Future<Void> closeCircuit(HttpRequest queuedRequest)
QueueCircuitBreakerCloses the circuit representing the queued request.
Closing the circuit includes the following steps:
closeCircuit in interface QueueCircuitBreakerqueuedRequest - the queued requestpublic io.vertx.core.Future<Void> closeAllCircuits()
QueueCircuitBreakerCloses all non-closed circuits.
Closing all non-closed circuits includes the following steps:
closeAllCircuits in interface QueueCircuitBreakerpublic io.vertx.core.Future<Void> reOpenCircuit(HttpRequest queuedRequest)
QueueCircuitBreakerreOpenCircuit in interface QueueCircuitBreakerqueuedRequest - the queued requestpublic io.vertx.core.Future<Void> lockQueue(String queueName, HttpRequest queuedRequest)
QueueCircuitBreakerlockQueue in interface QueueCircuitBreakerqueueName - the name of the queuequeuedRequest - the queued requestpublic io.vertx.core.Future<String> unlockNextQueue()
QueueCircuitBreakernull
string in this case.unlockNextQueue in interface QueueCircuitBreakernull string
when no queue was available to unlock.public io.vertx.core.Future<Long> setOpenCircuitsToHalfOpen()
QueueCircuitBreakerQueueCircuitState.OPEN
to QueueCircuitState.HALF_OPEN.setOpenCircuitsToHalfOpen in interface QueueCircuitBreakerpublic io.vertx.core.Future<Long> unlockSampleQueues()
QueueCircuitBreakerQueueCircuitState.HALF_OPEN. The sample
queues are always the queues which have not been unlocked the longest.unlockSampleQueues in interface QueueCircuitBreakerpublic io.vertx.core.Future<String> unlockQueue(String queueName)
QueueCircuitBreakerunlockQueue in interface QueueCircuitBreakerqueueName - the name of the queueCopyright © 2016–2017. All rights reserved.