public class Shotgun<C> extends java.lang.Object implements SubmissionPattern<C>, CompletionPattern<C>
| Constructor and Description |
|---|
Shotgun(java.util.Map<CompletionService,C> executorToContext,
int submissionCount) |
Shotgun(java.util.Map<CompletionService,C> executorToContext,
int submissionCount,
ShotgunStrategy strategy) |
| Modifier and Type | Method and Description |
|---|---|
void |
shutdown()
Attempts to shutdown all the services.
|
<T> ResilientFuture<T> |
submit(ResilientPatternAction<T,C> action,
long millisTimeout)
Submits a
ResilientPatternAction that will be run asynchronously. |
<T> ResilientFuture<T> |
submit(ResilientPatternAction<T,C> action,
ResilientCallback<T> callback,
long millisTimeout)
Submits a
ResilientPatternAction that will be run asynchronously similar to
SubmissionPattern.submit(ResilientPatternAction, long). |
<T> void |
submitAndComplete(ResilientPatternAction<T,C> action,
ResilientPromise<T> promise,
long millisTimeout)
Submits a
ResilientPatternAction that will be run asynchronously. |
<T> void |
submitAndComplete(ResilientPatternAction<T,C> action,
ResilientPromise<T> promise,
ResilientCallback<T> callback,
long millisTimeout)
Submits a
ResilientPatternAction that will be run asynchronously. |
public Shotgun(java.util.Map<CompletionService,C> executorToContext, int submissionCount)
public Shotgun(java.util.Map<CompletionService,C> executorToContext, int submissionCount, ShotgunStrategy strategy)
public <T> ResilientFuture<T> submit(ResilientPatternAction<T,C> action, long millisTimeout)
SubmissionPatternResilientPatternAction 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 SubmissionPattern<C>T - 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> ResilientFuture<T> submit(ResilientPatternAction<T,C> action, ResilientCallback<T> callback, long millisTimeout)
SubmissionPatternResilientPatternAction that will be run asynchronously similar to
SubmissionPattern.submit(ResilientPatternAction, 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 SubmissionPattern<C>T - 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(ResilientPatternAction<T,C> action, ResilientPromise<T> promise, long millisTimeout)
CompletionPatternResilientPatternAction that will be run asynchronously.
At the completion of the task, the result will be delivered to the promise provided.submitAndComplete in interface CompletionPattern<C>T - 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> void submitAndComplete(ResilientPatternAction<T,C> action, ResilientPromise<T> promise, ResilientCallback<T> callback, long millisTimeout)
CompletionPatternResilientPatternAction 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 CompletionPattern<C>T - 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 void shutdown()
PatternRejectedActionException. Implementations
may differ on if pending or executing actions are cancelled.Copyright © 2014 Tim Brooks. All Rights Reserved.