T
- Type of the task argument.R
- Type of the task result returning from ComputeTask.reduce(List)
method.public abstract class ComputeTaskAdapter<T,R> extends Object implements ComputeTask<T,R>
ComputeTask
interface. Here is an example of
how ComputeTaskAdapter
can be used:
public class MyFooBarTask extends ComputeTaskAdapter<String, String> { // Inject load balancer. @LoadBalancerResource ComputeLoadBalancer balancer; // Map jobs to grid nodes. public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, String arg) throws IgniteCheckedException { Map<MyFooBarJob, ClusterNode> jobs = new HashMap<MyFooBarJob, ClusterNode>(subgrid.size()); // In more complex cases, you can actually do // more complicated assignments of jobs to nodes. for (int i = 0; i < subgrid.size(); i++) { // Pick the next best balanced node for the job. jobs.put(new MyFooBarJob(arg), balancer.getBalancedNode()) } return jobs; } // Aggregate results into one compound result. public String reduce(List<ComputeJobResult> results) throws IgniteCheckedException { // For the purpose of this example we simply // concatenate string representation of every // job result StringBuilder buf = new StringBuilder(); for (ComputeJobResult res : results) { // Append string representation of result // returned by every job. buf.append(res.getData().string()); } return buf.string(); } }For more information refer to
ComputeTask
documentation.Constructor and Description |
---|
ComputeTaskAdapter() |
Modifier and Type | Method and Description |
---|---|
ComputeJobResultPolicy |
result(ComputeJobResult res,
List<ComputeJobResult> rcvd)
Default implementation which will wait for all jobs to complete before
calling
ComputeTask.reduce(List) method. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
map, reduce
public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult> rcvd) throws IgniteException
ComputeTask.reduce(List)
method.
If remote job resulted in exception (ComputeJobResult.getException()
is not null
),
then ComputeJobResultPolicy.FAILOVER
policy will be returned if the exception is instance
of ClusterTopologyException
or ComputeExecutionRejectedException
, which means that
remote node either failed or job execution was rejected before it got a chance to start. In all
other cases the exception will be rethrown which will ultimately cause task to fail.
result
in interface ComputeTask<T,R>
res
- Received remote grid executable result.rcvd
- All previously received results.IgniteException
- If handling a job result caused an error effectively rejecting
a failover. This exception will be thrown out of ComputeTaskFuture.get()
method.
GridGain In-Memory Computing Platform : ver. 8.9.14 Release Date : November 5 2024