Interface Task<T>
-
- Type Parameters:
T- the type of result produced by theTask
- All Superinterfaces:
ExternalizableLite,Serializable
public interface Task<T> extends ExternalizableLite
A task which may take a long time to execute, may be executed by multipleExecutors, may generate intermediate results, and may yield for later execution.Implementations define a single method called
execute(Context)that performs the task, possibly yielding execution to some later point. Once the method has completed execution, by returning a result or throwing an exception (but not a Yield exception), the task is considered completed for the assignedExecutor.Tasks are likeCallableandRunnableclasses in that they are designed to be potentially executed by one or moreThreads, typicallyExecutors. UnlikeCallableandRunnableclasses, the execution may occur in Java Virtual Machines, fail and/or recover between different Java Virtual Machine processes. As such, it is recommended to account for fail-over if a task is recovered. Important execution state should be saved in the in theTask.Contextproperties. Tasks should checkTask.Context.isResuming()to determine if the task has failed over to another executor and if execution state should be recovered from theTask.Contextproperties.- Since:
- 21.12
- Author:
- bo
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceTask.Collectable<T,R>Provides the mechanism to submit, orchestrate and collect results from aTaskdefined as part of anTask.Orchestration, including the creation of aTask.Coordinatorto subscribe to results, manage and interact with an orchestratedTask.static interfaceTask.Collector<T,A,R>A mutable reduction operation that accumulates results into a mutable result container, optionally transforming the accumulated result into a final representation after all results have been processed.static interfaceTask.Completable<T,R>ATask.Collectablethat supports performing operations when aTaskorchestration is complete.static interfaceTask.CompletionRunnable<T>A runnable to be called upon task completion.static interfaceTask.Context<T>static interfaceTask.Coordinator<T>static interfaceTask.OptionAn option for configuringTaskorchestration.static interfaceTask.Orchestration<T>static interfaceTask.PropertiesDefine an interface to allow states sharing between the task executors.static interfaceTask.SubscribedOrchestration<T>Defines the subset ofTask.Orchestrationmethods which are permitted afterTask.SubscribedOrchestration.subscribe(Subscriber)is called.static interfaceTask.Subscriber<T>A receiver of items produced by aTask.Coordinator.static interfaceTask.Subscription<T>Represents a subscription aTask.Subscriberhas made to aTask.Coordinator, allowing control and termination of theTask.Subscription.static classTask.Yield
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Texecute(Task.Context<T> context)Executes theTask.-
Methods inherited from interface com.tangosol.io.ExternalizableLite
readExternal, writeExternal
-
-
-
-
Method Detail
-
execute
T execute(Task.Context<T> context) throws Exception
Executes theTask.- Parameters:
context- theTask.Context- Returns:
- the result of executing the
Task - Throws:
Task.Yield- which indicates theTaskexecution should yield execution until some later point in timeException
-
-