Search Results for

Show / Hide Table of Contents

# Namespace Apache.Ignite.Core.Compute

### Classes

#### ComputeExecutionRejectedException

Indicates a situation when execution service provided by the user in configuration rejects execution.

#### ComputeJobAdapter<T>

Convenience adapter for IComputeJob<TRes> implementations. It provides the following functionality:

- Default implementation of Cancel() method and ability to check whether cancellation occurred with IsCancelled() method.
- Ability to set and get job arguments via SetArguments(Object[]) and GetArgument<TArg>(Int32) methods.

#### ComputeJobFailoverException

This runtime exception can be thrown from Execute() method to force job failover to another node within task topology. IComputeFunc<TArg, TRes> or IComputeFunc<TRes> passed into any of the ICompute methods can also throw this exception to force failover.

#### ComputeTaskAdapter<TArg, TJobRes, TTaskRes>

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

#### ComputeTaskCancelledException

This exception indicates that Ignite task was cancelled.

#### ComputeTaskNoResultCacheAttribute

This attribute disables caching of task results when attached to IComputeTask<TArg, TJobRes, TRes> instance. Use it when number of jobs within task grows too big, or jobs themselves are too large to keep in memory throughout task execution. By default all results are cached and passed into OnResult(IComputeJobResult<TJobRes>, IList<IComputeJobResult<TJobRes>>) and Reduce(IList<IComputeJobResult<TJobRes>>) methods. When this attribute is attached to a task class, then this list of job results will always be empty.

#### ComputeTaskSplitAdapter<TArg, TJobRes, TTaskRes>

This class defines simplified adapter for IComputeTask<TArg, TJobRes, TRes>. This adapter can be used when jobs can be randomly assigned to available Ignite nodes. This adapter is sufficient in most homogeneous environments where all nodes are equally suitable for executing grid job, see Split(Int32, TArg) method for more details.

#### ComputeTaskTimeoutException

Indicates that task execution timed out.

#### ComputeUserUndeclaredException

This exception is thrown when user's code throws undeclared runtime exception. By user core it is assumed the code in Ignite task, Ignite job or SPI. In most cases it should be an indication of unrecoverable error condition such as assertion, out of memory error, etc.

### Interfaces

#### ICompute

Defines Ignite functionality for executing tasks and closures over nodes in the IClusterGroup. Instance of ICompute is obtained from grid projection using GetCompute() method.

Note that if attempt is made to execute a computation over an empty projection (i.e. projection that does not have any alive nodes), `ClusterGroupEmptyException` will be thrown out of result task.

Ignite must select a node for a computation to be executed. The node will be selected based on the underlying `GridLoadBalancingSpi`, which by default sequentially picks next available node from grid projection. Other load balancing policies, such as `random` or `adaptive`, can be configured as well by selecting different load balancing SPI in Ignite configuration. If your logic requires some custom load balancing behavior, consider implementing `ComputeTask` in Java directly.

Ignite guarantees that as long as there is at least one Ignite node standing, every job will be executed. Jobs will automatically failover to another node if a remote node crashed or has rejected execution due to lack of resources. By default, in case of failover, next load balanced node will be picked for job execution. Also jobs will never be re-routed to the nodes they have failed on. This behavior can be changed by configuring any of the existing or a custom `FailoverSpi` in Ignite configuration.

All members are thread-safe and may be used concurrently from multiple threads.

#### IComputeAction

Defines a void function having no arguments.

#### IComputeFunc<TRes>

Defines function having no arguments.

#### IComputeFunc<TArg, TRes>

Defines function having a single argument.

#### IComputeJob<TRes>

Defines executable unit for IComputeTask<TArg, TJobRes, TRes>. Ignite task gets split into jobs when Map(IList<IClusterNode>, TArg) method is called. This method returns all jobs for the task mapped to their corresponding Ignite nodes for execution. Grid will then serialize this jobs and send them to requested nodes for execution.

Once job execution is complete, the return value will be sent back to parent task and will be passed into OnResult(IComputeJobResult<TJobRes>, IList<IComputeJobResult<TJobRes>>) method via IComputeJobResult<TRes> instance.

Ignite job implementation can be injected with IIgnite using InstanceResourceAttribute attribute.

#### IComputeJobResult<TRes>

Job execution result which gets passed to OnResult(IComputeJobResult<TJobRes>, IList<IComputeJobResult<TJobRes>>) method.

#### IComputeReducer<TRes, TReduceRes>

Compute reducer which is capable of result collecting and reducing.

#### IComputeTask<TJobRes, TReduceRes>

IComputeTask without an argument.

#### IComputeTask<TArg, TJobRes, TRes>

Ignite task interface defines a task that can be executed on the grid. Ignite task is responsible for splitting business logic into multiple Ignite jobs, receiving results from individual Ignite jobs executing on remote nodes, and reducing (aggregating) received jobs' results into final Ignite task result.

Upon request to execute a task, the system will do the following:

- Inject annotated resources into task instance.
- Apply Map(IList<IClusterNode>, TArg). This method is responsible for splitting business logic into multiple jobs (units of execution) and mapping them to Ignite nodes.
- System will send mapped Ignite jobs to their respective nodes.
- Once job execution results become available, OnResult(IComputeJobResult<TJobRes>, IList<IComputeJobResult<TJobRes>>) method will be called for ech received job result. The policy returned by this method will determine the way task reacts to every job result.

  If Wait is returned, task will continue to wait for other job results. If this result is the last job result, then reduce phase will be started.

  If Reduce is returned, reduce phase will be started right away without waiting for other jobs completion (all remaining jobs will receive cancel request).

  If Failover is returned, job will be failed over to another node for execution. Note that if you use ComputeTaskAdapter<TArg, TJobRes, TTaskRes>, it will automatically fail jobs to another node for 2 well-known failure cases: 1) job has failed to due to node crash (in this case Exception will return ClusterTopologyException); 2) job execution was rejected, i.e. remote node has cancelled job before it got a chance to execute, while it still was on the waiting list. (in this case Exception will return ComputeExecutionRejectedException).

- Once all results are received or OnResult(IComputeJobResult<TJobRes>, IList<IComputeJobResult<TJobRes>>) method returned Reduce policy, method Reduce(IList<IComputeJobResult<TJobRes>>) is called to aggregate received results into one final result. Once this method is finished the execution of the Ignite task is complete. This result will be returned to the user through future.

### Enums

#### ComputeJobResultPolicy

This enumeration provides different types of actions following the last received job result. See OnResult(IComputeJobResult<TJobRes>, IList<IComputeJobResult<TJobRes>>) for more details.