public class DefaultService extends AbstractService implements MultiService
actionMetrics, circuitBreaker, isShutdown, semaphoreMAX_CONCURRENCY_LEVEL, MAX_TIMEOUT_MILLIS| Constructor and Description |
|---|
DefaultService(java.util.concurrent.ExecutorService service,
PrecipiceSemaphore semaphore) |
DefaultService(java.util.concurrent.ExecutorService service,
PrecipiceSemaphore semaphore,
ActionMetrics actionMetrics) |
DefaultService(java.util.concurrent.ExecutorService service,
PrecipiceSemaphore semaphore,
ActionMetrics actionMetrics,
CircuitBreaker circuitBreaker) |
DefaultService(java.util.concurrent.ExecutorService service,
PrecipiceSemaphore semaphore,
CircuitBreaker breaker) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
run(ResilientAction<T> action)
Performs a
ResilientAction that will be run synchronously on the calling
thread. |
void |
shutdown()
Attempts to shutdown the service.
|
<T> ResilientFuture<T> |
submit(ResilientAction<T> action,
long millisTimeout)
Submits a
ResilientAction that will be run asynchronously. |
<T> ResilientFuture<T> |
submit(ResilientAction<T> action,
ResilientCallback<T> callback,
long millisTimeout)
Submits a
ResilientAction that will be run asynchronously similar to
SubmissionService.submit(ResilientAction, long). |
<T> void |
submitAndComplete(ResilientAction<T> action,
ResilientPromise<T> promise,
long millisTimeout)
Submits a
ResilientAction that will be run asynchronously. |
<T> void |
submitAndComplete(ResilientAction<T> action,
ResilientPromise<T> promise,
ResilientCallback<T> callback,
long millisTimeout)
Submits a
ResilientAction that will be run asynchronously. |
acquirePermitOrRejectIfActionNotAllowed, getActionMetrics, getCircuitBreakerclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetActionMetrics, getCircuitBreakerpublic DefaultService(java.util.concurrent.ExecutorService service,
PrecipiceSemaphore semaphore)
public DefaultService(java.util.concurrent.ExecutorService service,
PrecipiceSemaphore semaphore,
ActionMetrics actionMetrics)
public DefaultService(java.util.concurrent.ExecutorService service,
PrecipiceSemaphore semaphore,
CircuitBreaker breaker)
public DefaultService(java.util.concurrent.ExecutorService service,
PrecipiceSemaphore semaphore,
ActionMetrics actionMetrics,
CircuitBreaker circuitBreaker)
public <T> ResilientFuture<T> submit(ResilientAction<T> action, long millisTimeout)
SubmissionServiceResilientAction that will be run asynchronously.
The result of the action will be delivered to the future returned
by this call. An attempt to cancel the action will be made if it
does not complete before the timeout.submit in interface SubmissionServiceT - the type of the result of the actionaction - the action to submitmillisTimeout - milliseconds before the action times outResilientFuture representing pending completion of the actionpublic <T> void submitAndComplete(ResilientAction<T> action, ResilientPromise<T> promise, long millisTimeout)
CompletionServiceResilientAction that will be run asynchronously. At the
completion of the task, the result will be delivered to the promise provided.submitAndComplete in interface CompletionServiceT - the type of the result of the actionaction - the action to submitpromise - a promise to which deliver the resultmillisTimeout - milliseconds before the action times outpublic <T> ResilientFuture<T> submit(ResilientAction<T> action, ResilientCallback<T> callback, long millisTimeout)
SubmissionServiceResilientAction that will be run asynchronously similar to
SubmissionService.submit(ResilientAction, long). However, at the completion of the task,
the provided callback will be executed. The callback will be run regardless of the result
of the action.submit in interface SubmissionServiceT - the type of the result of the actionaction - the action to submitcallback - to run on action completionmillisTimeout - milliseconds before the action times outResilientFuture representing pending completion of the actionpublic <T> void submitAndComplete(ResilientAction<T> action, ResilientPromise<T> promise, ResilientCallback<T> callback, long millisTimeout)
CompletionServiceResilientAction that will be run asynchronously. At the completion
of the task, the result will be delivered to the promise provided. And the provided
callback will be executed.submitAndComplete in interface CompletionServiceT - the type of the result of the actionaction - the action to submitpromise - a promise to which deliver the resultcallback - to run on action completionmillisTimeout - milliseconds before the action times outpublic <T> T run(ResilientAction<T> action) throws java.lang.Exception
RunServiceResilientAction that will be run synchronously on the calling
thread. However, at the completion of the task, the result will be delivered to
the promise provided. And the provided callback will be executed.
If the ResilientAction throws a ActionTimeoutException, the result of
the action will be a timeout. Any other exception and the result of the action
will be an error.run in interface RunServiceT - the type of the result of the actionaction - the action to runResilientPromise representing result of the actionRejectedActionException - if the action is rejectedjava.lang.Exceptionpublic void shutdown()
ServiceRejectedActionException. Implementations may differ on if pending
or executing actions are cancelled.Copyright © 2014 Tim Brooks. All Rights Reserved.