public class QueueCircuitBreakerImpl extends java.lang.Object implements QueueCircuitBreaker, org.swisspush.gateleen.routing.RuleProvider.RuleChangesObserver, org.swisspush.gateleen.core.refresh.Refreshable
| Constructor and Description |
|---|
QueueCircuitBreakerImpl(io.vertx.core.Vertx vertx,
QueueCircuitBreakerStorage queueCircuitBreakerStorage,
org.swisspush.gateleen.routing.RuleProvider ruleProvider,
QueueCircuitBreakerRulePatternToCircuitMapping ruleToCircuitMapping,
QueueCircuitBreakerConfigurationResourceManager configResourceManager,
io.vertx.core.Handler<io.vertx.core.http.HttpServerRequest> queueCircuitBreakerHttpRequestHandler,
int requestHandlerPort)
Deprecated.
|
QueueCircuitBreakerImpl(io.vertx.core.Vertx vertx,
java.lang.String redisquesAddress,
QueueCircuitBreakerStorage queueCircuitBreakerStorage,
org.swisspush.gateleen.routing.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<java.lang.Void> |
closeAllCircuits()
Closes all non-closed circuits.
|
io.vertx.core.Future<java.lang.Void> |
closeCircuit(org.swisspush.gateleen.core.http.HttpRequest queuedRequest)
Closes the circuit representing the queued request.
|
io.vertx.core.Future<QueueCircuitState> |
handleQueuedRequest(java.lang.String queueName,
org.swisspush.gateleen.core.http.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<java.lang.Void> |
lockQueue(java.lang.String queueName,
org.swisspush.gateleen.core.http.HttpRequest queuedRequest)
Locks the queue having the provided queueName by calling the vertx-redisques API.
|
void |
refresh() |
io.vertx.core.Future<java.lang.Void> |
reOpenCircuit(org.swisspush.gateleen.core.http.HttpRequest queuedRequest)
Re-Opens the (half-open) circuit representing the provided queued request again.
|
void |
rulesChanged(java.util.List<org.swisspush.gateleen.routing.Rule> rules) |
io.vertx.core.Future<java.lang.Long> |
setOpenCircuitsToHalfOpen()
Changes the status of all circuits having a status equals
QueueCircuitState.OPEN
to QueueCircuitState.HALF_OPEN. |
io.vertx.core.Future<java.lang.String> |
unlockNextQueue()
Unlocks the next queue in-line.
|
io.vertx.core.Future<java.lang.String> |
unlockQueue(java.lang.String queueName)
Unlocks the queue having the provided queueName by calling the vertx-redisques API.
|
io.vertx.core.Future<java.lang.Long> |
unlockSampleQueues()
Unlocks a sample queue of all circuits having a status equals
QueueCircuitState.HALF_OPEN. |
io.vertx.core.Future<java.lang.Void> |
updateStatistics(java.lang.String queueName,
org.swisspush.gateleen.core.http.HttpRequest queuedRequest,
QueueResponseType queueResponseType)
Updates the statistics of the corresponding circuit based on the provided request to execute.
|
public QueueCircuitBreakerImpl(io.vertx.core.Vertx vertx,
QueueCircuitBreakerStorage queueCircuitBreakerStorage,
org.swisspush.gateleen.routing.RuleProvider ruleProvider,
QueueCircuitBreakerRulePatternToCircuitMapping ruleToCircuitMapping,
QueueCircuitBreakerConfigurationResourceManager configResourceManager,
io.vertx.core.Handler<io.vertx.core.http.HttpServerRequest> queueCircuitBreakerHttpRequestHandler,
int requestHandlerPort)
vertx - queueCircuitBreakerStorage - ruleProvider - ruleToCircuitMapping - configResourceManager - queueCircuitBreakerHttpRequestHandler - requestHandlerPort - public QueueCircuitBreakerImpl(io.vertx.core.Vertx vertx,
java.lang.String redisquesAddress,
QueueCircuitBreakerStorage queueCircuitBreakerStorage,
org.swisspush.gateleen.routing.RuleProvider ruleProvider,
QueueCircuitBreakerRulePatternToCircuitMapping ruleToCircuitMapping,
QueueCircuitBreakerConfigurationResourceManager configResourceManager,
io.vertx.core.Handler<io.vertx.core.http.HttpServerRequest> queueCircuitBreakerHttpRequestHandler,
int requestHandlerPort)
vertx - vertxredisquesAddress - 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(java.util.List<org.swisspush.gateleen.routing.Rule> rules)
rulesChanged in interface org.swisspush.gateleen.routing.RuleProvider.RuleChangesObserverpublic void refresh()
refresh in interface org.swisspush.gateleen.core.refresh.Refreshablepublic boolean isCircuitCheckEnabled()
QueueCircuitBreakerisCircuitCheckEnabled in interface QueueCircuitBreakerpublic boolean isStatisticsUpdateEnabled()
QueueCircuitBreakerisStatisticsUpdateEnabled in interface QueueCircuitBreakerpublic io.vertx.core.Future<QueueCircuitState> handleQueuedRequest(java.lang.String queueName, org.swisspush.gateleen.core.http.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<java.lang.Void> updateStatistics(java.lang.String queueName,
org.swisspush.gateleen.core.http.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<java.lang.Void> closeCircuit(org.swisspush.gateleen.core.http.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<java.lang.Void> closeAllCircuits()
QueueCircuitBreakerCloses all non-closed circuits.
Closing all non-closed circuits includes the following steps:
closeAllCircuits in interface QueueCircuitBreakerpublic io.vertx.core.Future<java.lang.Void> reOpenCircuit(org.swisspush.gateleen.core.http.HttpRequest queuedRequest)
QueueCircuitBreakerreOpenCircuit in interface QueueCircuitBreakerqueuedRequest - the queued requestpublic io.vertx.core.Future<java.lang.Void> lockQueue(java.lang.String queueName,
org.swisspush.gateleen.core.http.HttpRequest queuedRequest)
QueueCircuitBreakerlockQueue in interface QueueCircuitBreakerqueueName - the name of the queuequeuedRequest - the queued requestpublic io.vertx.core.Future<java.lang.String> unlockNextQueue()
QueueCircuitBreakernull
string in this case.unlockNextQueue in interface QueueCircuitBreakernull string
when no queue was available to unlock.public io.vertx.core.Future<java.lang.Long> setOpenCircuitsToHalfOpen()
QueueCircuitBreakerQueueCircuitState.OPEN
to QueueCircuitState.HALF_OPEN.setOpenCircuitsToHalfOpen in interface QueueCircuitBreakerpublic io.vertx.core.Future<java.lang.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<java.lang.String> unlockQueue(java.lang.String queueName)
QueueCircuitBreakerunlockQueue in interface QueueCircuitBreakerqueueName - the name of the queue