Class ComputeJobContinuationAdapter
- java.lang.Object
- 
- org.apache.ignite.compute.ComputeJobAdapter
- 
- org.apache.ignite.compute.ComputeJobContinuationAdapter
 
 
- 
- All Implemented Interfaces:
- Serializable,- Callable<Object>,- ComputeJob,- ComputeJobContinuation
 
 public abstract class ComputeJobContinuationAdapter extends ComputeJobAdapter implements ComputeJobContinuation Convenience adapter forComputeJobimplementations. It provides the following functionality:- 
      Default implementation of ComputeJob.cancel()method and ability to check whether cancellation occurred.
- 
      Ability to set and get a job arguments via ComputeJobAdapter.setArguments(Object...)andComputeJobAdapter.argument(int)methods.
 ComputeJobAdaptercan be used from task logic to create jobs. The example creates job adapter as anonymous class, but you are free to create a separate class for it.public class TestGridTask extends ComputeTaskSplitAdapter<String, Integer> { // Used to imitate some logic for the // sake of this example private int multiplier = 3; @Override protected Collection<? extends ComputeJob> split(int gridSize, final String arg) throws IgniteCheckedException { List<ComputeJobAdapter<String>> jobs = new ArrayList<ComputeJobAdapter<String>>(gridSize); for (int i = 0; i < gridSize; i++) { jobs.add(new ComputeJobAdapter() { // Job execution logic. public Object execute() throws IgniteCheckedException { return multiplier * arg.length(); } }); } return jobs; } // Aggregate multiple job results into // one task result. public Integer reduce(List<ComputeJobResult> results) throws IgniteCheckedException { int sum = 0; // For the sake of this example, let's sum all results. for (ComputeJobResult res : results) { sum += (Integer)res.getData(); } return sum; } }- See Also:
- Serialized Form
 
- 
- 
Constructor SummaryConstructors Modifier Constructor Description protectedComputeJobContinuationAdapter()No-arg constructor.protectedComputeJobContinuationAdapter(@Nullable Object arg)Creates job with one arguments.protectedComputeJobContinuationAdapter(@Nullable Object... args)Creates job with specified arguments.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcallcc()Resumes job if it was held byComputeJobContinuation.holdcc()method.booleanheldcc()Checks if job execution has been temporarily held (suspended).<T> Tholdcc()Holds (suspends) a given job indefinitely untilComputeJobContinuation.callcc()is called.<T> Tholdcc(long timeout)Holds (suspends) a given job for specified timeout or untilComputeJobContinuation.callcc()is called.- 
Methods inherited from class org.apache.ignite.compute.ComputeJobAdapterargument, arguments, call, cancel, isCancelled, setArguments
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.apache.ignite.compute.ComputeJobexecute
 
- 
 
- 
- 
- 
Constructor Detail- 
ComputeJobContinuationAdapterprotected ComputeJobContinuationAdapter() No-arg constructor.
 - 
ComputeJobContinuationAdapterprotected ComputeJobContinuationAdapter(@Nullable @Nullable Object arg)Creates job with one arguments. This constructor exists for better backward compatibility with internal Ignite 2.x code.- Parameters:
- arg- Job argument.
 
 - 
ComputeJobContinuationAdapterprotected ComputeJobContinuationAdapter(@Nullable @Nullable Object... args)Creates job with specified arguments.- Parameters:
- args- Optional job arguments.
 
 
- 
 - 
Method Detail- 
heldccpublic boolean heldcc() Checks if job execution has been temporarily held (suspended).If job has completed its execution, then falseis always returned.- Specified by:
- heldccin interface- ComputeJobContinuation
- Returns:
- Trueif job has been held.
 
 - 
callccpublic void callcc() Resumes job if it was held byComputeJobContinuation.holdcc()method. Resuming job means thatComputeJob.execute()method will be called again. It is user's responsibility to check, as needed, whether job is executing from scratch and has been resumed.Note that the job is resumed with exactly the same state as of when it was 'held' via the ComputeJobContinuation.holdcc()method.If job is not running, has not been suspended, or has completed its execution, then no-op. The method is named after 'call-with-current-continuation'design pattern, commonly abbreviated as'call/cc', which originated in Scheme programming language.- Specified by:
- callccin interface- ComputeJobContinuation
 
 - 
holdcc@Nullable public <T> T holdcc() Holds (suspends) a given job indefinitely untilComputeJobContinuation.callcc()is called. Job will remain in active queue, but itsComputeJobContinuation.heldcc()method will returntrue. Implementations ofCollisionSpishould check if jobs are held or not as needed.All jobs should stop their execution and return right after calling 'holdcc(..)'method. For convenience, this method always returnsnull, so you can hold and return in one line by calling'return holdcc()'method.If job is not running or has completed its execution, then no-op. The 'cc'suffix stands for'current-continuation'which is a pretty standard notation for this concept that originated from Scheme programming language. Basically, the job is held to be continued later, hence the name of the method.- Specified by:
- holdccin interface- ComputeJobContinuation
- Type Parameters:
- T- Type of the job execution result.
- Returns:
- Always returns nullfor convenience to be used in code with return statement.
 
 - 
holdcc@Nullable public <T> T holdcc(long timeout) Holds (suspends) a given job for specified timeout or untilComputeJobContinuation.callcc()is called. Holds (suspends) a given job for specified timeout or untilComputeJobContinuation.callcc()is called. Job will remain in active queue, but itsComputeJobContinuation.heldcc()method will returntrue. Implementations ofCollisionSpishould check if jobs are held or not as needed.All jobs should stop their execution and return right after calling 'holdcc(..)'method. For convenience, this method always returnsnull, so you can hold and return in one line by calling'return holdcc()'.If job is not running or has completed its execution, then no-op. The 'cc'suffix stands for'current-continuation'which is a fairly standard notation for this concept. Basically, the job is held to be continued later, hence the name of the method.- Specified by:
- holdccin interface- ComputeJobContinuation
- Type Parameters:
- T- Type of the job execution result.
- Parameters:
- timeout- Timeout in milliseconds after which job will be automatically resumed.
- Returns:
- Always returns nullfor convenience to be used in code with return statement.
 
 
- 
 
-