Class IgniteComputeImpl
- java.lang.Object
-
- org.apache.ignite.internal.AsyncSupportAdapter<IgniteCompute>
-
- org.apache.ignite.internal.IgniteComputeImpl
-
- All Implemented Interfaces:
Externalizable
,Serializable
,IgniteCompute
,IgniteAsyncSupport
public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute> implements IgniteCompute, Externalizable
IgniteCompute
implementation.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.ignite.internal.AsyncSupportAdapter
curFut
-
-
Constructor Summary
Constructors Constructor Description IgniteComputeImpl()
Required byExternalizable
.IgniteComputeImpl(GridKernalContext ctx, ClusterGroupAdapter prj)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> Map<IgniteUuid,ComputeTaskFuture<R>>
activeTaskFutures()
Gets tasks future for active tasks started on local node.<R> R
affinityCall(@NotNull Collection<String> cacheNames, int partId, IgniteCallable<R> job)
Executes given job on the node where partition is located (the partition is primary on the node)<R> R
affinityCall(@NotNull Collection<String> cacheNames, Object affKey, IgniteCallable<R> job)
Executes given job on the node where data for provided affinity key is located (a.k.a. affinity co-location).<R> R
affinityCall(String cacheName, Object affKey, IgniteCallable<R> job)
Executes given job on the node where data for provided affinity key is located (a.k.a. affinity co-location).<R> IgniteFuture<R>
affinityCallAsync(@NotNull Collection<String> cacheNames, int partId, IgniteCallable<R> job)
Executes given job asynchronously on the node where partition is located (the partition is primary on the node) The data of the partition will not be migrated from the target node while the job is executed.<R> IgniteFuture<R>
affinityCallAsync(@NotNull Collection<String> cacheNames, Object affKey, IgniteCallable<R> job)
Executes given job asynchronously on the node where data for provided affinity key is located (a.k.a. affinity co-location).<R> IgniteFuture<R>
affinityCallAsync(String cacheName, Object affKey, IgniteCallable<R> job)
Executes given job asynchronously on the node where data for provided affinity key is located (a.k.a. affinity co-location).void
affinityRun(@NotNull Collection<String> cacheNames, int partId, IgniteRunnable job)
Executes given job on the node where partition is located (the partition is primary on the node)void
affinityRun(@NotNull Collection<String> cacheNames, Object affKey, IgniteRunnable job)
Executes given job on the node where data for provided affinity key is located (a.k.a. affinity co-location).void
affinityRun(String cacheName, Object affKey, IgniteRunnable job)
Executes given job on the node where data for provided affinity key is located (a.k.a. affinity co-location).IgniteFuture<Void>
affinityRunAsync(@NotNull Collection<String> cacheNames, int partId, IgniteRunnable job)
Executes given job asynchronously on the node where partition is located (the partition is primary on the node) The data of the partition will not be migrated from the target node while the job is executed.IgniteFuture<Void>
affinityRunAsync(@NotNull Collection<String> cacheNames, Object affKey, IgniteRunnable job)
Executes given job asynchronously on the node where data for provided affinity key is located (a.k.a. affinity co-location).IgniteFuture<Void>
affinityRunAsync(String cacheName, Object affKey, IgniteRunnable job)
Executes given job asynchronously on the node where data for provided affinity key is located (a.k.a. affinity co-location).<T,R>
Collection<R>apply(IgniteClosure<T,R> job, @Nullable Collection<? extends T> args)
Executes provided closure job on nodes within the underlying cluster group.<R,T>
Rapply(IgniteClosure<T,R> job, T arg)
Executes provided closure job on a node within the underlying cluster group.<R1,R2,T>
R2apply(IgniteClosure<T,R1> job, Collection<? extends T> args, IgniteReducer<R1,R2> rdc)
Executes provided closure job on nodes within the underlying cluster group.<T,R>
IgniteFuture<Collection<R>>applyAsync(IgniteClosure<T,R> job, Collection<? extends T> args)
Executes provided closure job asynchronously on nodes within the underlying cluster group.<R,T>
IgniteFuture<R>applyAsync(IgniteClosure<T,R> job, T arg)
Executes provided closure job asynchronously on a node within the underlying cluster group.<R1,R2,T>
IgniteFuture<R2>applyAsync(IgniteClosure<T,R1> job, Collection<? extends T> args, IgniteReducer<R1,R2> rdc)
Executes provided closure job asynchronously on nodes within the underlying cluster group.<R> Collection<R>
broadcast(IgniteCallable<R> job)
Broadcasts given job to all nodes in cluster group.<R,T>
Collection<R>broadcast(IgniteClosure<T,R> job, T arg)
Broadcasts given closure job with passed in argument to all nodes in the cluster group.void
broadcast(IgniteRunnable job)
Broadcasts given job to all nodes in the cluster group.<R> IgniteFuture<Collection<R>>
broadcastAsync(IgniteCallable<R> job)
Broadcasts given job asynchronously to all nodes in cluster group.<R,T>
IgniteFuture<Collection<R>>broadcastAsync(IgniteClosure<T,R> job, T arg)
Broadcasts given closure job asynchronously with passed in argument to all nodes in the cluster group.IgniteFuture<Void>
broadcastAsync(IgniteRunnable job)
Broadcasts given job asynchronously to all nodes in the cluster group.<R> Collection<R>
call(Collection<? extends IgniteCallable<R>> jobs)
Executes collection of jobs on nodes within the underlying cluster group.<R1,R2>
R2call(Collection<? extends IgniteCallable<R1>> jobs, IgniteReducer<R1,R2> rdc)
Executes collection of jobs on nodes within the underlying cluster group.<R> R
call(IgniteCallable<R> job)
Executes provided job on a node within the underlying cluster group.<R> IgniteFuture<Collection<R>>
callAsync(Collection<? extends IgniteCallable<R>> jobs)
Executes collection of jobs asynchronously on nodes within the underlying cluster group.<R1,R2>
IgniteFuture<R2>callAsync(Collection<? extends IgniteCallable<R1>> jobs, IgniteReducer<R1,R2> rdc)
Executes collection of jobs asynchronously on nodes within the underlying cluster group.<R> IgniteFuture<R>
callAsync(IgniteCallable<R> job)
Executes provided job asynchronously on a node within the underlying cluster group.ClusterGroup
clusterGroup()
Gets cluster group to which thisIgniteCompute
instance belongs.protected IgniteCompute
createAsyncInstance()
Creates component with asynchronous mode enabled.protected <R> IgniteFuture<R>
createFuture(IgniteInternalFuture<R> fut)
<T,R>
Rexecute(Class<? extends ComputeTask<T,R>> taskCls, T arg)
Executes given task on within the cluster group.<T,R>
Rexecute(String taskName, T arg)
Executes given task within the cluster group.<T,R>
Rexecute(ComputeTask<T,R> task, T arg)
Executes given task within the cluster group.<T,R>
ComputeTaskFuture<R>executeAsync(Class<? extends ComputeTask<T,R>> taskCls, T arg)
Executes given task asynchronously on within the cluster group.<T,R>
ComputeTaskFuture<R>executeAsync(String taskName, T arg)
Executes given task asynchronously within the cluster group.<T,R>
ComputeTaskFuture<R>executeAsync(ComputeTask<T,R> task, T arg)
Executes given task asynchronously within the cluster group.<R> ComputeTaskFuture<R>
future()
Gets and resets future for previous asynchronous operation.void
localDeployTask(Class<? extends ComputeTask> taskCls, ClassLoader clsLdr)
Explicitly deploys a task with given class loader on the local node.Map<String,Class<? extends ComputeTask<?,?>>>
localTasks()
Gets map of all locally deployed tasks keyed by their task name .void
readExternal(ObjectInput in)
protected Object
readResolve()
Reconstructs object on unmarshalling.void
run(Collection<? extends IgniteRunnable> jobs)
Executes collection of jobs on grid nodes within the underlying cluster group.void
run(IgniteRunnable job)
Executes provided job on a node within the underlying cluster group.IgniteFuture<Void>
runAsync(Collection<? extends IgniteRunnable> jobs)
Executes collection of jobs asynchronously on grid nodes within the underlying cluster group.IgniteFuture<Void>
runAsync(IgniteRunnable job)
Executes provided job asynchronously on a node within the underlying cluster group.void
undeployTask(String taskName)
Makes the best attempt to undeploy a task with given name within the underlying cluster group.IgniteCompute
withExecutor(@NotNull String name)
Gets instance of the compute API associated with custom executor.IgniteCompute
withName(String taskName)
Sets task name for the next executed task in the current thread.IgniteCompute
withNoFailover()
Sets no-failover flag for the next task executed in the current thread.IgniteCompute
withNoResultCache()
Disables caching for the next executed task in the current thread.IgniteCompute
withTimeout(long timeout)
Sets task timeout for the next executed task in the current thread.void
writeExternal(ObjectOutput out)
-
Methods inherited from class org.apache.ignite.internal.AsyncSupportAdapter
future, isAsync, saveOrGet, withAsync
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.ignite.lang.IgniteAsyncSupport
isAsync
-
Methods inherited from interface org.apache.ignite.IgniteCompute
withAsync
-
-
-
-
Constructor Detail
-
IgniteComputeImpl
public IgniteComputeImpl()
Required byExternalizable
.
-
IgniteComputeImpl
public IgniteComputeImpl(GridKernalContext ctx, ClusterGroupAdapter prj)
- Parameters:
ctx
- Kernal context.prj
- Projection.
-
-
Method Detail
-
createAsyncInstance
protected IgniteCompute createAsyncInstance()
Creates component with asynchronous mode enabled.- Overrides:
createAsyncInstance
in classAsyncSupportAdapter<IgniteCompute>
- Returns:
- Component with asynchronous mode enabled.
-
clusterGroup
public ClusterGroup clusterGroup()
Gets cluster group to which thisIgniteCompute
instance belongs.- Specified by:
clusterGroup
in interfaceIgniteCompute
- Returns:
- Cluster group to which this
IgniteCompute
instance belongs.
-
affinityRun
public void affinityRun(String cacheName, Object affKey, IgniteRunnable job)
Executes given job on the node where data for provided affinity key is located (a.k.a. affinity co-location). It's guaranteed that the data of the whole partition, the affinity key belongs to, will present on the destination node throughout the job execution.- Specified by:
affinityRun
in interfaceIgniteCompute
- Parameters:
cacheName
- Name of the cache to use for affinity co-location.affKey
- Affinity key.job
- Job which will be co-located on the node with given affinity key.
-
affinityRunAsync
public IgniteFuture<Void> affinityRunAsync(String cacheName, Object affKey, IgniteRunnable job) throws IgniteException
Executes given job asynchronously on the node where data for provided affinity key is located (a.k.a. affinity co-location). The data of the partition where affKey is stored will not be migrated from the target node while the job is executed.- Specified by:
affinityRunAsync
in interfaceIgniteCompute
- Parameters:
cacheName
- Name of the cache to use for affinity co-location.affKey
- Affinity key.job
- Job which will be co-located on the node with given affinity key.- Returns:
- a Future representing pending completion of the affinity run.
- Throws:
IgniteException
- If job failed.
-
affinityRun
public void affinityRun(@NotNull @NotNull Collection<String> cacheNames, Object affKey, IgniteRunnable job)
Executes given job on the node where data for provided affinity key is located (a.k.a. affinity co-location). It's guaranteed that the data of all the partitions of all participating caches, the affinity key belongs to, will present on the destination node throughout the job execution.- Specified by:
affinityRun
in interfaceIgniteCompute
- Parameters:
cacheNames
- Names of the caches to to reserve the partition. The first cache is used for affinity co-location.affKey
- Affinity key.job
- Job which will be co-located on the node with given affinity key.
-
affinityRunAsync
public IgniteFuture<Void> affinityRunAsync(@NotNull @NotNull Collection<String> cacheNames, Object affKey, IgniteRunnable job) throws IgniteException
Executes given job asynchronously on the node where data for provided affinity key is located (a.k.a. affinity co-location). The data of the partition where affKey is stored will not be migrated from the target node while the job is executed. The data of the extra caches' partitions with the same partition number also will not be migrated.- Specified by:
affinityRunAsync
in interfaceIgniteCompute
- Parameters:
cacheNames
- Names of the caches to to reserve the partition. The first cache uses for affinity co-location.affKey
- Affinity key.job
- Job which will be co-located on the node with given affinity key.- Returns:
- a Future representing pending completion of the affinity run.
- Throws:
IgniteException
- If job failed.
-
affinityRun
public void affinityRun(@NotNull @NotNull Collection<String> cacheNames, int partId, IgniteRunnable job)
Executes given job on the node where partition is located (the partition is primary on the node) It's guaranteed that the data of all the partitions of all participating caches, the affinity key belongs to, will present on the destination node throughout the job execution.- Specified by:
affinityRun
in interfaceIgniteCompute
- Parameters:
cacheNames
- Names of the caches to to reserve the partition. The first cache is used for affinity co-location.partId
- Partition number.job
- Job which will be co-located on the node with given affinity key.
-
affinityRunAsync
public IgniteFuture<Void> affinityRunAsync(@NotNull @NotNull Collection<String> cacheNames, int partId, IgniteRunnable job) throws IgniteException
Executes given job asynchronously on the node where partition is located (the partition is primary on the node) The data of the partition will not be migrated from the target node while the job is executed. The data of the extra caches' partitions with the same partition number also will not be migrated.- Specified by:
affinityRunAsync
in interfaceIgniteCompute
- Parameters:
cacheNames
- Names of the caches to to reserve the partition. The first cache uses for affinity co-location.partId
- Partition number.job
- Job which will be co-located on the node with given affinity key.- Returns:
- a Future representing pending completion of the affinity run.
- Throws:
IgniteException
- If job failed.
-
affinityCall
public <R> R affinityCall(String cacheName, Object affKey, IgniteCallable<R> job)
Executes given job on the node where data for provided affinity key is located (a.k.a. affinity co-location). It's guaranteed that the data of the whole partition, the affinity key belongs to, will present on the destination node throughout the job execution.- Specified by:
affinityCall
in interfaceIgniteCompute
- Type Parameters:
R
- Type of the job result.- Parameters:
cacheName
- Name of the cache to use for affinity co-location.affKey
- Affinity key.job
- Job which will be co-located on the node with given affinity key.- Returns:
- Job result.
-
affinityCallAsync
public <R> IgniteFuture<R> affinityCallAsync(String cacheName, Object affKey, IgniteCallable<R> job) throws IgniteException
Executes given job asynchronously on the node where data for provided affinity key is located (a.k.a. affinity co-location). The data of the partition where affKey is stored will not be migrated from the target node while the job is executed.- Specified by:
affinityCallAsync
in interfaceIgniteCompute
- Type Parameters:
R
- Type of the job result.- Parameters:
cacheName
- Name of the cache to use for affinity co-location.affKey
- Affinity key.job
- Job which will be co-located on the node with given affinity key.- Returns:
- a Future representing pending completion of the affinity call.
- Throws:
IgniteException
- If job failed.
-
affinityCall
public <R> R affinityCall(@NotNull @NotNull Collection<String> cacheNames, Object affKey, IgniteCallable<R> job)
Executes given job on the node where data for provided affinity key is located (a.k.a. affinity co-location). It's guaranteed that the data of all the partitions of all participating caches, the affinity key belongs to, will present on the destination node throughout the job execution.- Specified by:
affinityCall
in interfaceIgniteCompute
- Type Parameters:
R
- Type of the job result.- Parameters:
cacheNames
- Names of the caches to to reserve the partition. The first cache uses for affinity co-location.affKey
- Affinity key.job
- Job which will be co-located on the node with given affinity key.- Returns:
- Job result.
-
affinityCallAsync
public <R> IgniteFuture<R> affinityCallAsync(@NotNull @NotNull Collection<String> cacheNames, Object affKey, IgniteCallable<R> job) throws IgniteException
Executes given job asynchronously on the node where data for provided affinity key is located (a.k.a. affinity co-location). The data of the partition where affKey is stored will not be migrated from the target node while the job is executed. The data of the extra caches' partitions with the same partition number also will not be migrated.- Specified by:
affinityCallAsync
in interfaceIgniteCompute
- Type Parameters:
R
- Type of the job result.- Parameters:
cacheNames
- Names of the caches to to reserve the partition. The first cache uses for affinity co-location.affKey
- Affinity key.job
- Job which will be co-located on the node with given affinity key.- Returns:
- a Future representing pending completion of the affinity call.
- Throws:
IgniteException
- If job failed.
-
affinityCall
public <R> R affinityCall(@NotNull @NotNull Collection<String> cacheNames, int partId, IgniteCallable<R> job)
Executes given job on the node where partition is located (the partition is primary on the node) It's guaranteed that the data of all the partitions of all participating caches, the affinity key belongs to, will present on the destination node throughout the job execution.- Specified by:
affinityCall
in interfaceIgniteCompute
- Type Parameters:
R
- Type of the job result.- Parameters:
cacheNames
- Names of the caches to to reserve the partition. The first cache uses for affinity co-location.partId
- Partition to reserve.job
- Job which will be co-located on the node with given affinity key.- Returns:
- Job result.
-
affinityCallAsync
public <R> IgniteFuture<R> affinityCallAsync(@NotNull @NotNull Collection<String> cacheNames, int partId, IgniteCallable<R> job) throws IgniteException
Executes given job asynchronously on the node where partition is located (the partition is primary on the node) The data of the partition will not be migrated from the target node while the job is executed. The data of the extra caches' partitions with the same partition number also will not be migrated.- Specified by:
affinityCallAsync
in interfaceIgniteCompute
- Type Parameters:
R
- Type of the job result.- Parameters:
cacheNames
- Names of the caches to to reserve the partition. The first cache uses for affinity co-location.partId
- Partition to reserve.job
- Job which will be co-located on the node with given affinity key.- Returns:
- a Future representing pending completion of the affinity call.
- Throws:
IgniteException
- If job failed.
-
execute
public <T,R> R execute(String taskName, @Nullable T arg)
Executes given task within the cluster group. For step-by-step explanation of task execution process refer toComputeTask
documentation.If task for given name has not been deployed yet, then
taskName
will be used as task class name to auto-deploy the task (seeIgniteCompute.localDeployTask(Class, ClassLoader)
method).If class with the same name was deployed more than once, the last deployed version is used. If method is called when other threads are deploying other versions of class with the same name there are no guarantees which version of the class will be executed.
- Specified by:
execute
in interfaceIgniteCompute
- Type Parameters:
T
- Type of the task argument.R
- Type of the task result.- Parameters:
taskName
- Name of the task to execute.arg
- Optional argument of task execution, can benull
.- Returns:
- Task result.
- See Also:
for information about task execution.
-
executeAsync
public <T,R> ComputeTaskFuture<R> executeAsync(String taskName, @Nullable T arg) throws IgniteException
Executes given task asynchronously within the cluster group. For step-by-step explanation of task execution process refer toComputeTask
documentation.If task for given name has not been deployed yet, then
taskName
will be used as task class name to auto-deploy the task (seeIgniteCompute.localDeployTask(Class, ClassLoader)
method).- Specified by:
executeAsync
in interfaceIgniteCompute
- Type Parameters:
T
- Type of the task argument.R
- Type of the task result.- Parameters:
taskName
- Name of the task to execute.arg
- Optional argument of task execution, can benull
.- Returns:
- a Future representing pending completion of the task.
- Throws:
IgniteException
- If task failed.- See Also:
for information about task execution.
-
execute
public <T,R> R execute(Class<? extends ComputeTask<T,R>> taskCls, @Nullable T arg)
Executes given task on within the cluster group. For step-by-step explanation of task execution process refer toComputeTask
documentation.- Specified by:
execute
in interfaceIgniteCompute
- Type Parameters:
T
- Type of the task argument.R
- Type of the task result.- Parameters:
taskCls
- Class of the task to execute. If class hasComputeTaskName
annotation, then task is deployed under a name specified within annotation. Otherwise, full class name is used as task name.arg
- Optional argument of task execution, can benull
.- Returns:
- Task result.
-
executeAsync
public <T,R> ComputeTaskFuture<R> executeAsync(Class<? extends ComputeTask<T,R>> taskCls, @Nullable T arg) throws IgniteException
Executes given task asynchronously on within the cluster group. For step-by-step explanation of task execution process refer toComputeTask
documentation.- Specified by:
executeAsync
in interfaceIgniteCompute
- Type Parameters:
T
- Type of the task argument.R
- Type of the task result.- Parameters:
taskCls
- Class of the task to execute. If class hasComputeTaskName
annotation, then task is deployed under a name specified within annotation. Otherwise, full class name is used as task name.arg
- Optional argument of task execution, can benull
.- Returns:
- a Future representing pending completion of the task.
- Throws:
IgniteException
- If task failed.
-
execute
public <T,R> R execute(ComputeTask<T,R> task, @Nullable T arg)
Executes given task within the cluster group. For step-by-step explanation of task execution process refer toComputeTask
documentation.- Specified by:
execute
in interfaceIgniteCompute
- Type Parameters:
T
- Type of the task argument.R
- Type of the task result.- Parameters:
task
- Instance of task to execute. If task class hasComputeTaskName
annotation, then task is deployed under a name specified within annotation. Otherwise, full class name is used as task name.arg
- Optional argument of task execution, can benull
.- Returns:
- Task result.
-
executeAsync
public <T,R> ComputeTaskFuture<R> executeAsync(ComputeTask<T,R> task, @Nullable T arg) throws IgniteException
Executes given task asynchronously within the cluster group. For step-by-step explanation of task execution process refer toComputeTask
documentation.- Specified by:
executeAsync
in interfaceIgniteCompute
- Type Parameters:
T
- type.R
- type.- Parameters:
task
- Instance of task to execute. If task class hasComputeTaskName
annotation, then task is deployed under a name specified within annotation. Otherwise, full class name is used as task name.arg
- Optional argument of task execution, can benull
.- Returns:
- a Future representing pending completion of the task.
- Throws:
IgniteException
- If task failed.
-
broadcast
public void broadcast(IgniteRunnable job)
Broadcasts given job to all nodes in the cluster group.- Specified by:
broadcast
in interfaceIgniteCompute
- Parameters:
job
- Job to broadcast to all cluster group nodes.
-
broadcastAsync
public IgniteFuture<Void> broadcastAsync(IgniteRunnable job) throws IgniteException
Broadcasts given job asynchronously to all nodes in the cluster group.- Specified by:
broadcastAsync
in interfaceIgniteCompute
- Parameters:
job
- Job to broadcast to all cluster group nodes.- Returns:
- a Future representing pending completion of the broadcast execution of the job.
- Throws:
IgniteException
- If job failed.
-
broadcast
public <R> Collection<R> broadcast(IgniteCallable<R> job)
Broadcasts given job to all nodes in cluster group. Every participating node will return a job result. Collection of all returned job results is returned from the result future.- Specified by:
broadcast
in interfaceIgniteCompute
- Type Parameters:
R
- Type of the job result.- Parameters:
job
- Job to broadcast to all cluster group nodes.- Returns:
- Collection of results for this execution.
-
broadcastAsync
public <R> IgniteFuture<Collection<R>> broadcastAsync(IgniteCallable<R> job) throws IgniteException
Broadcasts given job asynchronously to all nodes in cluster group. Every participating node will return a job result. Collection of all returned job results is returned from the result future.- Specified by:
broadcastAsync
in interfaceIgniteCompute
- Type Parameters:
R
- Type of the job result.- Parameters:
job
- Job to broadcast to all cluster group nodes.- Returns:
- a Future representing pending completion of the broadcast execution of the job.
- Throws:
IgniteException
- If execution failed.
-
broadcast
public <R,T> Collection<R> broadcast(IgniteClosure<T,R> job, @Nullable T arg)
Broadcasts given closure job with passed in argument to all nodes in the cluster group. Every participating node will return a job result. Collection of all returned job results is returned from the result future.- Specified by:
broadcast
in interfaceIgniteCompute
- Type Parameters:
R
- Type of the job result.T
- Type of the job argument.- Parameters:
job
- Job to broadcast to all cluster group nodes.arg
- Job closure argument.- Returns:
- Collection of results for this execution.
-
broadcastAsync
public <R,T> IgniteFuture<Collection<R>> broadcastAsync(IgniteClosure<T,R> job, @Nullable T arg) throws IgniteException
Broadcasts given closure job asynchronously with passed in argument to all nodes in the cluster group. Every participating node will return a job result. Collection of all returned job results is returned from the result future.- Specified by:
broadcastAsync
in interfaceIgniteCompute
- Type Parameters:
R
- Type of the job result.T
- Type of the job argument.- Parameters:
job
- Job to broadcast to all cluster group nodes.arg
- Job closure argument.- Returns:
- a Future representing pending completion of the broadcast execution of the job.
- Throws:
IgniteException
- If execution failed.
-
run
public void run(IgniteRunnable job)
Executes provided job on a node within the underlying cluster group.- Specified by:
run
in interfaceIgniteCompute
- Parameters:
job
- Job closure to execute.
-
runAsync
public IgniteFuture<Void> runAsync(IgniteRunnable job) throws IgniteException
Executes provided job asynchronously on a node within the underlying cluster group.- Specified by:
runAsync
in interfaceIgniteCompute
- Parameters:
job
- Job closure to execute.- Returns:
- a Future representing pending completion of the job.
- Throws:
IgniteException
- If execution failed.
-
run
public void run(Collection<? extends IgniteRunnable> jobs)
Executes collection of jobs on grid nodes within the underlying cluster group.- Specified by:
run
in interfaceIgniteCompute
- Parameters:
jobs
- Collection of jobs to execute.
-
runAsync
public IgniteFuture<Void> runAsync(Collection<? extends IgniteRunnable> jobs) throws IgniteException
Executes collection of jobs asynchronously on grid nodes within the underlying cluster group. Executes asynchronously. Returns control immediately.- Specified by:
runAsync
in interfaceIgniteCompute
- Parameters:
jobs
- Collection of jobs to execute.- Returns:
- a Future representing pending completion of the job.
- Throws:
IgniteException
- If execution failed.
-
apply
public <R,T> R apply(IgniteClosure<T,R> job, @Nullable T arg)
Executes provided closure job on a node within the underlying cluster group. This method is different fromrun(...)
andcall(...)
methods in a way that it receives job argument which is then passed into the closure at execution time.- Specified by:
apply
in interfaceIgniteCompute
- Type Parameters:
R
- Type of the job result.T
- Type of the job argument.- Parameters:
job
- Job to run.arg
- Job argument.- Returns:
- Job result.
-
applyAsync
public <R,T> IgniteFuture<R> applyAsync(IgniteClosure<T,R> job, @Nullable T arg) throws IgniteException
Executes provided closure job asynchronously on a node within the underlying cluster group. This method is different fromrun(...)
andcall(...)
methods in a way that it receives job argument which is then passed into the closure at execution time.- Specified by:
applyAsync
in interfaceIgniteCompute
- Type Parameters:
R
- Type of the job result.T
- Type of the job argument.- Parameters:
job
- Job to run.arg
- Job argument.- Returns:
- a Future representing pending completion of the job.
- Throws:
IgniteException
- If execution failed.
-
call
public <R> R call(IgniteCallable<R> job)
Executes provided job on a node within the underlying cluster group. The result of the job execution is returned from the result closure.- Specified by:
call
in interfaceIgniteCompute
- Type Parameters:
R
- Type of the job result.- Parameters:
job
- Job to execute.- Returns:
- Job result.
-
callAsync
public <R> IgniteFuture<R> callAsync(IgniteCallable<R> job) throws IgniteException
Executes provided job asynchronously on a node within the underlying cluster group. The result of the job execution is returned from the result closure.- Specified by:
callAsync
in interfaceIgniteCompute
- Type Parameters:
R
- Type of the job result.- Parameters:
job
- Job to execute.- Returns:
- a Future representing pending completion of the job.
- Throws:
IgniteException
- If execution failed.
-
call
public <R> Collection<R> call(Collection<? extends IgniteCallable<R>> jobs)
Executes collection of jobs on nodes within the underlying cluster group. Collection of all returned job results is returned from the result future.- Specified by:
call
in interfaceIgniteCompute
- Type Parameters:
R
- Type of the jobs result.- Parameters:
jobs
- Non-empty collection of jobs to execute.- Returns:
- Collection of job results for this execution.
-
callAsync
public <R> IgniteFuture<Collection<R>> callAsync(Collection<? extends IgniteCallable<R>> jobs) throws IgniteException
Executes collection of jobs asynchronously on nodes within the underlying cluster group. Collection of all returned job results is returned from the result future.- Specified by:
callAsync
in interfaceIgniteCompute
- Type Parameters:
R
- Type of the job result.- Parameters:
jobs
- Non-empty collection of jobs to execute.- Returns:
- a Future representing pending completion of the job.
- Throws:
IgniteException
- If execution failed.
-
apply
public <T,R> Collection<R> apply(IgniteClosure<T,R> job, @Nullable @Nullable Collection<? extends T> args)
Executes provided closure job on nodes within the underlying cluster group. 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.- Specified by:
apply
in interfaceIgniteCompute
- Type Parameters:
T
- Type of the job argument.R
- Type of the job result.- Parameters:
job
- Job to run.args
- Job arguments.- Returns:
- Collection of job results.
-
applyAsync
public <T,R> IgniteFuture<Collection<R>> applyAsync(IgniteClosure<T,R> job, Collection<? extends T> args) throws IgniteException
Executes provided closure job asynchronously on nodes within the underlying cluster group. 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.- Specified by:
applyAsync
in interfaceIgniteCompute
- Type Parameters:
T
- Type of the job argument.R
- Type of the job result.- Parameters:
job
- Job to run.args
- Job arguments.- Returns:
- a Future representing pending completion of the job.
- Throws:
IgniteException
- If execution failed.
-
call
public <R1,R2> R2 call(Collection<? extends IgniteCallable<R1>> jobs, IgniteReducer<R1,R2> rdc)
Executes collection of jobs on nodes within the underlying cluster group. The returned job results will be reduced into an individual result by provided reducer.- Specified by:
call
in interfaceIgniteCompute
- Type Parameters:
R1
- Type of the job result.R2
- Type of the result returned by reducer.- Parameters:
jobs
- Non-empty collection of jobs to execute.rdc
- Reducer to reduce all job results into one individual return value.- Returns:
- Reduced job result for this execution.
-
callAsync
public <R1,R2> IgniteFuture<R2> callAsync(Collection<? extends IgniteCallable<R1>> jobs, IgniteReducer<R1,R2> rdc) throws IgniteException
Executes collection of jobs asynchronously on nodes within the underlying cluster group. The returned job results will be reduced into an individual result by provided reducer.- Specified by:
callAsync
in interfaceIgniteCompute
- Type Parameters:
R1
- Type of the job result.R2
- Type of the result returned by reducer.- Parameters:
jobs
- Non-empty collection of jobs to execute.rdc
- Reducer to reduce all job results into one individual return value.- Returns:
- a Future with reduced job result for this execution.
- Throws:
IgniteException
- If execution failed.
-
apply
public <R1,R2,T> R2 apply(IgniteClosure<T,R1> job, Collection<? extends T> args, IgniteReducer<R1,R2> rdc)
Executes provided closure job on nodes within the underlying cluster group. 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.- Specified by:
apply
in interfaceIgniteCompute
- Type Parameters:
R1
- Type of the job result.R2
- Type of the reducer argument.T
- Type of the job argument.- Parameters:
job
- Job to run.args
- Job arguments.rdc
- Reducer to reduce all job results into one individual return value.- Returns:
- Reduced job result for this execution.
-
applyAsync
public <R1,R2,T> IgniteFuture<R2> applyAsync(IgniteClosure<T,R1> job, Collection<? extends T> args, IgniteReducer<R1,R2> rdc) throws IgniteException
Executes provided closure job asynchronously on nodes within the underlying cluster group. 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.- Specified by:
applyAsync
in interfaceIgniteCompute
- Type Parameters:
R1
- Type of the job result.R2
- Type of the reducer argument.T
- Type of the job argument.- Parameters:
job
- Job to run.args
- Job arguments.rdc
- Reducer to reduce all job results into one individual return value.- Returns:
- a Future with reduced job result for this execution.
- Throws:
IgniteException
- If execution failed.
-
activeTaskFutures
public <R> Map<IgniteUuid,ComputeTaskFuture<R>> activeTaskFutures()
Gets tasks future for active tasks started on local node.- Specified by:
activeTaskFutures
in interfaceIgniteCompute
- Type Parameters:
R
- Type of the task result.- Returns:
- Map of active tasks keyed by their task task session ID.
-
withName
public IgniteCompute withName(String taskName)
Sets task name for the next executed task in the current thread. When task starts execution, the name is reset, so one name is used only once. You may use this method to set task name when executing jobs directly, without explicitly definingComputeTask
.Here is an example.
ignite.withName("MyTask").run(new IgniteRunnable() {...});
- Specified by:
withName
in interfaceIgniteCompute
- Parameters:
taskName
- Task name.- Returns:
- This
IgniteCompute
instance for chaining calls.
-
withTimeout
public IgniteCompute withTimeout(long timeout)
Sets task timeout for the next executed task in the current thread. When task starts execution, the timeout is reset, so one timeout is used only once.Here is an example.
ignite.withTimeout(10000).run(new IgniteRunnable() {...});
- Specified by:
withTimeout
in interfaceIgniteCompute
- Parameters:
timeout
- Computation timeout in milliseconds.- Returns:
- This
IgniteCompute
instance for chaining calls.
-
withNoFailover
public IgniteCompute withNoFailover()
Sets no-failover flag for the next task executed 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.Here is an example.
ignite.compute().withNoFailover().run(new IgniteRunnable() {...});
- Specified by:
withNoFailover
in interfaceIgniteCompute
- Returns:
- This
IgniteCompute
instance for chaining calls.
-
withNoResultCache
public IgniteCompute withNoResultCache()
Disables caching for the next executed task in the current thread. Has the same behaviour as annotationComputeTaskNoResultCache
.Here is an example.
ignite.compute().withNoResultCache().run(new IgniteRunnable() {...});
- Specified by:
withNoResultCache
in interfaceIgniteCompute
- Returns:
- This
IgniteCompute
instance for chaining calls.
-
localDeployTask
public void localDeployTask(Class<? extends ComputeTask> taskCls, ClassLoader clsLdr)
Explicitly deploys a task with given class loader on the local node. Upon completion of this method, a task can immediately be executed on the grid, considering that all participating remote nodes also have this task deployed.Note that tasks are automatically deployed upon first execution (if peer-class-loading is enabled), so use this method only when the provided class loader is different from the
taskClass.getClassLoader()
.Another way of class deployment is deployment from local class path. Classes from local class path always have a priority over P2P deployed ones.
Note that class can be deployed multiple times on remote nodes, i.e. re-deployed. Ignition maintains internal version of deployment for each instance of deployment (analogous to class and class loader in Java). Execution happens always on the latest deployed instance.
This method has no effect if the class passed in was already deployed.
- Specified by:
localDeployTask
in interfaceIgniteCompute
- Parameters:
taskCls
- Task class to deploy. If task class hasComputeTaskName
annotation, then task will be deployed under the name specified within annotation. Otherwise, full class name will be used as task's name.clsLdr
- Task class loader. This class loader is in charge of loading all necessary resources for task execution.
-
localTasks
public Map<String,Class<? extends ComputeTask<?,?>>> localTasks()
Gets map of all locally deployed tasks keyed by their task name .- Specified by:
localTasks
in interfaceIgniteCompute
- Returns:
- Map of locally deployed tasks keyed by their task name.
-
undeployTask
public void undeployTask(String taskName)
Makes the best attempt to undeploy a task with given name within the underlying cluster group. Note that this method returns immediately and does not wait until the task will actually be undeployed on every node.- Specified by:
undeployTask
in interfaceIgniteCompute
- Parameters:
taskName
- Name of the task to undeploy.
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
readResolve
protected Object readResolve() throws ObjectStreamException
Reconstructs object on unmarshalling.- Returns:
- Reconstructed object.
- Throws:
ObjectStreamException
- Thrown in case of unmarshalling error.
-
createFuture
protected <R> IgniteFuture<R> createFuture(IgniteInternalFuture<R> fut)
- Overrides:
createFuture
in classAsyncSupportAdapter<IgniteCompute>
- Parameters:
fut
- Internal future.- Returns:
- Public API future.
-
future
public <R> ComputeTaskFuture<R> future()
Gets and resets future for previous asynchronous operation.- Specified by:
future
in interfaceIgniteAsyncSupport
- Specified by:
future
in interfaceIgniteCompute
- Overrides:
future
in classAsyncSupportAdapter<IgniteCompute>
- Type Parameters:
R
- Type of the future result.- Returns:
- Future for previous asynchronous operation.
-
withExecutor
public IgniteCompute withExecutor(@NotNull @NotNull String name)
Gets instance of the compute API associated with custom executor. All tasks and closures submitted to returned instance will be processed by this executor on both remote and local nodes. If executor with the given name doesn't exist, task will be processed in default ("public") pool.Executor should be defined in
IgniteConfiguration.setExecutorConfiguration(ExecutorConfiguration...)
.- Specified by:
withExecutor
in interfaceIgniteCompute
- Parameters:
name
- Custom executor name.- Returns:
- Instance of compute API associated with custom executor.
-
-