Public Member Functions | Properties | List of all members
GridGain.Compute.ICompute Interface Reference

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

Inherits GridGain.Common.IAsyncSupport< ICompute >.

Public Member Functions

ICompute WithNoFailover ()
 Sets no-failover flag for the next executed task on this projection in the current thread. If flag is set, job will be never failed over even if remote node crashes or rejects execution. When task starts execution, the no-failover flag is reset, so all other task will use default failover policy, unless this flag is set again. More...
 
ICompute WithTimeout (long timeout)
 Sets task timeout for the next executed task on this projection in the current thread. When task starts execution, the timeout is reset, so one timeout is used only once. More...
 
ICompute WithKeepPortable ()
 Sets keep-portable flag for the next executed Java task on this projection in the current thread so that task argument passed to Java and returned task results will not be deserialized. More...
 
T ExecuteJavaTask< T > (string taskName, object taskArg)
 Executes given Java task on the grid projection. If task for given name has not been deployed yet, then 'taskName' will be used as task class name to auto-deploy the task. More...
 
R Execute< A, T, R > (IComputeTask< A, T, R > task, A taskArg)
 Executes given task on the grid projection. For step-by-step explanation of task execution process refer to IComputeTask<A,T,R> documentation. More...
 
R Execute< T, R > (IComputeTask< T, R > task)
 Executes given task on the grid projection. For step-by-step explanation of task execution process refer to IComputeTask<A,T,R> documentation. More...
 
R Execute< A, T, R > (Type taskType, A taskArg)
 Executes given task on the grid projection. For step-by-step explanation of task execution process refer to IComputeTask<A,T,R> documentation. More...
 
R Execute< T, R > (Type taskType)
 Executes given task on the grid projection. For step-by-step explanation of task execution process refer to IComputeTask<A,T,R> documentation. More...
 
R Call< R > (IComputeFunc< R > clo)
 Executes provided job on a node in this grid projection. The result of the job execution is returned from the result closure. More...
 
R AffinityCall< R > (string cacheName, object affinityKey, IComputeFunc< R > clo)
 Executes given job on the node where data for provided affinity key is located (a.k.a. affinity co-location). More...
 
R2 Call< R1, R2 > (IEnumerable< IComputeFunc< R1 >> clos, IComputeReducer< R1, R2 > rdc)
 Executes collection of jobs on nodes within this grid projection. More...
 
ICollection< R > Call< R > (IEnumerable< IComputeFunc< R >> clos)
 Executes collection of jobs on nodes within this grid projection. More...
 
ICollection< R > Broadcast< R > (IComputeFunc< R > clo)
 Broadcasts given job to all nodes in grid projection. Every participating node will return a job result. More...
 
ICollection< R > Broadcast< T, R > (IComputeFunc< T, R > clo, T arg)
 Broadcasts given closure job with passed in argument to all nodes in grid projection. Every participating node will return a job result. More...
 
void Broadcast (IComputeAction action)
 Broadcasts given job to all nodes in grid projection. More...
 
void Run (IComputeAction action)
 Executes provided job on a node in this grid projection. More...
 
void AffinityRun (string cacheName, object affinityKey, IComputeAction action)
 Executes given job on the node where data for provided affinity key is located (a.k.a. affinity co-location). More...
 
void Run (IEnumerable< IComputeAction > actions)
 Executes collection of jobs on grid nodes within this grid projection. More...
 
R Apply< T, R > (IComputeFunc< T, R > clo, T arg)
 Executes provided closure job on a node in this grid projection. More...
 
ICollection< R > Apply< T, R > (IComputeFunc< T, R > clo, IEnumerable< T > args)
 Executes provided closure job on nodes within this grid projection. A new job is executed for every argument in the passed in collection. The number of actual job executions will be equal to size of the job arguments collection. More...
 
R2 Apply< T, R1, R2 > (IComputeFunc< T, R1 > clo, IEnumerable< T > args, IComputeReducer< R1, R2 > rdc)
 Executes provided closure job on nodes within this grid projection. A new job is executed for every argument in the passed in collection. The number of actual job executions will be equal to size of the job arguments collection. The returned job results will be reduced into an individual result by provided reducer. More...
 
- Public Member Functions inherited from GridGain.Common.IAsyncSupport< ICompute >
TWithAsync WithAsync ()
 Gets component with asynchronous mode enabled. More...
 
IFuture GetFuture ()
 Gets and resets future for previous asynchronous operation. More...
 
IFuture< TResult > GetFuture< TResult > ()
 Gets and resets future for previous asynchronous operation. More...
 

Properties

IClusterGroup ClusterGroup [get]
 Grid projection to which this compute instance belongs. More...
 
- Properties inherited from GridGain.Common.IAsyncSupport< ICompute >
bool IsAsync [get]
 Gets a value indicating whether this instance is in asynchronous mode. More...
 

Detailed Description

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 future.

GridGain 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 grid configuration. If your logic requires some custom load balancing behavior, consider implementing ComputeTask in Java directly.

GridGain guarantees that as long as there is at least one grid 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 GridFailoverSpi in grid configuration.

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

Member Function Documentation

R GridGain.Compute.ICompute.AffinityCall< R > ( string  cacheName,
object  affinityKey,
IComputeFunc< R >  clo 
)
Parameters
cacheNameName of the cache to use for affinity co-location.
affinityKeyAffinity key.
cloJob to execute.
Returns
Job result for this execution.
Template Parameters
RType of job result.
void GridGain.Compute.ICompute.AffinityRun ( string  cacheName,
object  affinityKey,
IComputeAction  action 
)
Parameters
cacheNameName of the cache to use for affinity co-location.
affinityKeyAffinity key.
actionJob to execute.
R GridGain.Compute.ICompute.Apply< T, R > ( IComputeFunc< T, R >  clo,
T  arg 
)
Parameters
cloJob to run.
argJob argument.
Returns
Job result for this execution.
Template Parameters
TType of argument.
RType of job result.
ICollection<R> GridGain.Compute.ICompute.Apply< T, R > ( IComputeFunc< T, R >  clo,
IEnumerable< T >  args 
)
Parameters
cloJob to run.
argsJob arguments.
Returns
Collection of job results.
Template Parameters
TType of argument.
RType of job result.
R2 GridGain.Compute.ICompute.Apply< T, R1, R2 > ( IComputeFunc< T, R1 >  clo,
IEnumerable< T >  args,
IComputeReducer< R1, R2 >  rdc 
)
Parameters
cloJob to run.
argsJob arguments.
rdcReducer to reduce all job results into one individual return value.
Returns
Reduced job result for this execution.
Template Parameters
TType of argument.
R1Type of job result.
R2Type of reduced result.
void GridGain.Compute.ICompute.Broadcast ( IComputeAction  action)
Parameters
actionJob to broadcast to all projection nodes.
ICollection<R> GridGain.Compute.ICompute.Broadcast< R > ( IComputeFunc< R >  clo)
Parameters
cloJob to broadcast to all projection nodes.
Returns
Collection of results for this execution.
ICollection<R> GridGain.Compute.ICompute.Broadcast< T, R > ( IComputeFunc< T, R >  clo,
T  arg 
)
Parameters
cloJob to broadcast to all projection nodes.
argJob closure argument.
Returns
Collection of results for this execution.
Template Parameters
TType of argument.
RType of job result.
R GridGain.Compute.ICompute.Call< R > ( IComputeFunc< R >  clo)
Parameters
cloJob to execute.
Returns
Job result for this execution.
Template Parameters
RType of job result.
ICollection<R> GridGain.Compute.ICompute.Call< R > ( IEnumerable< IComputeFunc< R >>  clos)
Parameters
closCollection of jobs to execute.
Returns
Collection of job results for this execution.
Template Parameters
RType of job result.
R2 GridGain.Compute.ICompute.Call< R1, R2 > ( IEnumerable< IComputeFunc< R1 >>  clos,
IComputeReducer< R1, R2 >  rdc 
)
Parameters
closCollection of jobs to execute.
rdcReducer to reduce all job results into one individual return value.
Returns
Reduced job result for this execution.
Template Parameters
R1Type of job result.
R2Type of reduced result.
R GridGain.Compute.ICompute.Execute< A, T, R > ( IComputeTask< A, T, R >  task,
A  taskArg 
)
Parameters
taskTask to execute.
taskArgOptional task argument.
Returns
Task result.
Template Parameters
AArgument type.
TType of job result.
RType of reduce result.
R GridGain.Compute.ICompute.Execute< A, T, R > ( Type  taskType,
A  taskArg 
)
Parameters
taskTypeTask type.
taskArgOptional task argument.
Returns
Task result.
Template Parameters
AArgument type.
TType of job result.
RType of reduce result.
R GridGain.Compute.ICompute.Execute< T, R > ( IComputeTask< T, R >  task)
Parameters
taskTask to execute.
Returns
Task result.
Template Parameters
TType of job result.
RType of reduce result.
R GridGain.Compute.ICompute.Execute< T, R > ( Type  taskType)
Parameters
taskTypeTask type.
Returns
Task result.
Template Parameters
TType of job result.
RType of reduce result.
T GridGain.Compute.ICompute.ExecuteJavaTask< T > ( string  taskName,
object  taskArg 
)
Parameters
taskNameJava task name
taskArgOptional argument of task execution, can be null.
Returns
Task result.
Template Parameters
TType of task result.
void GridGain.Compute.ICompute.Run ( IComputeAction  action)
Parameters
actionJob to execute.
void GridGain.Compute.ICompute.Run ( IEnumerable< IComputeAction >  actions)
Parameters
actionsJobs to execute.
ICompute GridGain.Compute.ICompute.WithKeepPortable ( )
Returns
This compute instance for chaining calls.
ICompute GridGain.Compute.ICompute.WithNoFailover ( )
Returns
This compute instance for chaining calls.
ICompute GridGain.Compute.ICompute.WithTimeout ( long  timeout)
Parameters
timeoutComputation timeout in milliseconds.
Returns
This compute instance for chaining calls.

Property Documentation

IClusterGroup GridGain.Compute.ICompute.ClusterGroup
get