public interface TaskRunner
GlobalOrchestratorConfig
or locally to any individual Orchestrator. Several built-in versions are also available.LogTaskRunner,
StatTaskRunner,
ProfilingTaskRunner| Modifier and Type | Method and Description |
|---|---|
Object |
before(TaskRun taskRun)
Called before
executeTaskMethod(TaskRun, Thread, Object), but in the parent thread. |
Object |
executeTaskMethod(TaskRun taskRun,
Thread parentThread,
Object fromBefore)
Task invocation -- an implementation should invoke
TaskRun.run()
to complete the invocation (unless there is some reason to prevent it, but then the implementation
must take responsibility to ensure the all CompletableFuture return values are completed). |
void |
onComplete(TaskRun taskRun,
Object fromBefore,
boolean doneOnExit)
Called once any CompletableFuture return result completes, which may be before the call to
TaskRun.run() or after if a method returns an incomplete CompletableFuture.
|
Object before(TaskRun taskRun)
executeTaskMethod(TaskRun, Thread, Object), but in the parent thread.
If there is no immediate spawning then it will be the same thread. The returned object will
simply be passed to executeTaskMethod and is otherwise not read or modified by the framework.taskRun - that will also be passed to executeTaskMethodObject executeTaskMethod(TaskRun taskRun, Thread parentThread, Object fromBefore)
TaskRun.run()
to complete the invocation (unless there is some reason to prevent it, but then the implementation
must take responsibility to ensure the all CompletableFuture return values are completed). A typical
subclass implementation would be to simply surround the call, e.g.:
public Object executeTaskMethod(TaskRun taskRun, Thread parentThread, Object fromBefore) {
LOG.info("STARTED " + taskRun.getTaskPlusMethodName());
try {
taskRun.run()
} finally {
LOG.info("ENDED " + taskRun.getTaskPlusMethodName());
}
}
taskRun - to executeparentThread - of spawned task, which may be same as Thread.currentThread()fromBefore - value returned from before(TaskRun)void onComplete(TaskRun taskRun, Object fromBefore, boolean doneOnExit)
The provided doneOnExit parameter indicates whether a CompletableFuture return value had isDone()==true when the method completed. This should not be taken as very close but not exactly precise, since there are very small time intervals involved in the steps behind making that determination.
taskRun - that was executedfromBefore - value returned from before(TaskRun)doneOnExit - false iff a CompletableFuture was returned and it was not done when the method exitedCopyright © 2021. All rights reserved.