Search Results for

Show / Hide Table of Contents

# Class ComputeTaskAdapter<TArg, TJobRes, TTaskRes>

Convenience adapter for IComputeTask<TArg, TJobRes, TRes> interface

##### Inheritance

System.Object
ComputeTaskAdapter<TArg, TJobRes, TTaskRes>
ComputeTaskSplitAdapter<TArg, TJobRes, TTaskRes>

##### Implements

IComputeTask<TArg, TJobRes, TTaskRes>

###### Namespace: Apache.Ignite.Core.Compute

###### Assembly: Apache.Ignite.Core.dll

##### Syntax

    public abstract class ComputeTaskAdapter<TArg, TJobRes, TTaskRes> : object, IComputeTask<TArg, TJobRes, TTaskRes>

##### Type Parameters

Name | Description
--- | ---
TArg |
TJobRes |
TTaskRes |

### Methods

#### Map(IList<IClusterNode>, TArg)

This method is called to map or split Ignite task into multiple Ignite jobs. This is the first method that gets called when task execution starts.

##### Declaration

    public abstract IDictionary<IComputeJob<TJobRes>, IClusterNode> Map(IList<IClusterNode> subgrid, TArg arg)

##### Parameters

Type | Name | Description
--- | --- | ---
IList<IClusterNode> | subgrid | Nodes available for this task execution. Note that order of nodes is guaranteed to be randomized by container. This ensures that every time you simply iterate through Ignite nodes, the order of nodes will be random which over time should result into all nodes being used equally.
TArg | arg | Task execution argument. Can be `null`. This is the same argument as the one passed into `ICompute.Execute()` methods.

##### Returns

Type | Description
--- | ---
IDictionary<IComputeJob<TJobRes>, IClusterNode> | Map of Ignite jobs assigned to subgrid node. If `null` or empty map is returned, exception will be thrown.

#### OnResult(IComputeJobResult<TJobRes>, IList<IComputeJobResult<TJobRes>>)

Default implementation which will wait for all jobs to complete before calling Reduce(IList<IComputeJobResult<TJobRes>>) method.

If remote job resulted in exception Exception is not `null`), then 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.

##### Declaration

    public virtual ComputeJobResultPolicy OnResult(IComputeJobResult<TJobRes> res, IList<IComputeJobResult<TJobRes>> rcvd)

##### Parameters

Type | Name | Description
--- | --- | ---
IComputeJobResult<TJobRes> | res | Received remote Ignite executable result.
IList<IComputeJobResult<TJobRes>> | rcvd | All previously received results.

##### Returns

Type | Description
--- | ---
ComputeJobResultPolicy | Result policy that dictates how to process further upcoming job results.

#### Reduce(IList<IComputeJobResult<TJobRes>>)

Reduces (or aggregates) results received so far into one compound result to be returned to caller via task.

Note, that if some jobs did not succeed and could not be failed over then the list of results passed into this method will include the failed results. Otherwise, failed results will not be in the list.

##### Declaration

    public abstract TTaskRes Reduce(IList<IComputeJobResult<TJobRes>> results)

##### Parameters

Type | Name | Description
--- | --- | ---
IList<IComputeJobResult<TJobRes>> | results | Received job results. Note that if task class has ComputeTaskNoResultCacheAttribute attribute, then this list will be empty.

##### Returns

Type | Description
--- | ---
TTaskRes | Task result constructed from results of remote executions.

### Implements

IComputeTask<TArg, TJobRes, TRes>