public class IgniteComputeImpl extends AsyncSupportAdapter<IgniteCompute> implements IgniteCompute, Externalizable
IgniteCompute
implementation.curFut
Constructor and Description |
---|
IgniteComputeImpl()
Required by
Externalizable . |
IgniteComputeImpl(GridKernalContext ctx,
ClusterGroupAdapter prj,
UUID subjId) |
Modifier and Type | Method and Description |
---|---|
<R> Map<IgniteUuid,ComputeTaskFuture<R>> |
activeTaskFutures()
Gets tasks future for active tasks started on local node.
|
<R> R |
affinityCall(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.
|
<R> R |
affinityCall(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(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(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(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.
|
void |
affinityRun(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(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(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,
Collection<? extends T> args)
Executes provided closure job on nodes within the underlying cluster group.
|
<R,T> R |
apply(IgniteClosure<T,R> job,
T arg)
Executes provided closure job on a node within the underlying cluster group.
|
<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.
|
<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> R2 |
call(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 this
IgniteCompute instance belongs. |
protected IgniteCompute |
createAsyncInstance()
Creates component with asynchronous mode enabled.
|
protected <R> IgniteFuture<R> |
createFuture(IgniteInternalFuture<R> fut) |
<T,R> R |
execute(Class<? extends ComputeTask<T,R>> taskCls,
T arg)
Executes given task on within the cluster group.
|
<T,R> R |
execute(ComputeTask<T,R> task,
T arg)
Executes given task within the cluster group.
|
<T,R> R |
execute(String taskName,
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(ComputeTask<T,R> task,
T arg)
Executes given task asynchronously within the cluster group.
|
<T,R> ComputeTaskFuture<R> |
executeAsync(String taskName,
T arg)
Executes given task asynchronously within the cluster group.
|
<T,R> ComputeTaskInternalFuture<R> |
executeAsync0(ComputeTask<T,R> task,
T arg)
Execute implementation.
|
<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(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 |
withTimeout(long timeout)
Sets task timeout for the next executed task in the current thread.
|
void |
writeExternal(ObjectOutput out) |
future, isAsync, saveOrGet, withAsync
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
withAsync
isAsync
public IgniteComputeImpl()
Externalizable
.public IgniteComputeImpl(GridKernalContext ctx, ClusterGroupAdapter prj, UUID subjId)
ctx
- Kernal context.prj
- Projection.subjId
- Subject ID.protected IgniteCompute createAsyncInstance()
createAsyncInstance
in class AsyncSupportAdapter<IgniteCompute>
public ClusterGroup clusterGroup()
IgniteCompute
instance belongs.clusterGroup
in interface IgniteCompute
IgniteCompute
instance belongs.public void affinityRun(String cacheName, Object affKey, IgniteRunnable job)
affinityRun
in interface IgniteCompute
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.public IgniteFuture<Void> affinityRunAsync(String cacheName, Object affKey, IgniteRunnable job) throws IgniteException
affinityRunAsync
in interface IgniteCompute
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.IgniteException
- If job failed.public void affinityRun(@NotNull Collection<String> cacheNames, Object affKey, IgniteRunnable job)
affinityRun
in interface IgniteCompute
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.public IgniteFuture<Void> affinityRunAsync(@NotNull Collection<String> cacheNames, Object affKey, IgniteRunnable job) throws IgniteException
affinityRunAsync
in interface IgniteCompute
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.IgniteException
- If job failed.public void affinityRun(@NotNull Collection<String> cacheNames, int partId, IgniteRunnable job)
affinityRun
in interface IgniteCompute
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.public IgniteFuture<Void> affinityRunAsync(@NotNull Collection<String> cacheNames, int partId, IgniteRunnable job) throws IgniteException
affinityRunAsync
in interface IgniteCompute
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.IgniteException
- If job failed.public <R> R affinityCall(String cacheName, Object affKey, IgniteCallable<R> job)
affinityCall
in interface IgniteCompute
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.public <R> IgniteFuture<R> affinityCallAsync(String cacheName, Object affKey, IgniteCallable<R> job) throws IgniteException
affinityCallAsync
in interface IgniteCompute
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.IgniteException
- If job failed.public <R> R affinityCall(@NotNull Collection<String> cacheNames, Object affKey, IgniteCallable<R> job)
affinityCall
in interface IgniteCompute
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.public <R> IgniteFuture<R> affinityCallAsync(@NotNull Collection<String> cacheNames, Object affKey, IgniteCallable<R> job) throws IgniteException
affinityCallAsync
in interface IgniteCompute
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.IgniteException
- If job failed.public <R> R affinityCall(@NotNull Collection<String> cacheNames, int partId, IgniteCallable<R> job)
affinityCall
in interface IgniteCompute
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.public <R> IgniteFuture<R> affinityCallAsync(@NotNull Collection<String> cacheNames, int partId, IgniteCallable<R> job) throws IgniteException
affinityCallAsync
in interface IgniteCompute
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.IgniteException
- If job failed.public <T,R> R execute(String taskName, @Nullable T arg)
ComputeTask
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 (see IgniteCompute.localDeployTask(Class, ClassLoader)
method).
execute
in interface IgniteCompute
taskName
- Name of the task to execute.arg
- Optional argument of task execution, can be null
.for information about task execution.
public <T,R> ComputeTaskFuture<R> executeAsync(String taskName, @Nullable T arg) throws IgniteException
ComputeTask
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 (see IgniteCompute.localDeployTask(Class, ClassLoader)
method).
executeAsync
in interface IgniteCompute
taskName
- Name of the task to execute.arg
- Optional argument of task execution, can be null
.IgniteException
- If task failed.for information about task execution.
public <T,R> R execute(Class<? extends ComputeTask<T,R>> taskCls, @Nullable T arg)
ComputeTask
documentation.execute
in interface IgniteCompute
taskCls
- Class of the task to execute. If class has ComputeTaskName
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 be null
.public <T,R> ComputeTaskFuture<R> executeAsync(Class<? extends ComputeTask<T,R>> taskCls, @Nullable T arg) throws IgniteException
ComputeTask
documentation.executeAsync
in interface IgniteCompute
taskCls
- Class of the task to execute. If class has ComputeTaskName
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 be null
.IgniteException
- If task failed.public <T,R> R execute(ComputeTask<T,R> task, @Nullable T arg)
ComputeTask
documentation.execute
in interface IgniteCompute
task
- Instance of task to execute. If task class has ComputeTaskName
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 be null
.public <T,R> ComputeTaskFuture<R> executeAsync(ComputeTask<T,R> task, @Nullable T arg) throws IgniteException
ComputeTask
documentation.executeAsync
in interface IgniteCompute
task
- Instance of task to execute. If task class has ComputeTaskName
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 be null
.IgniteException
- If task failed.public <T,R> ComputeTaskInternalFuture<R> executeAsync0(ComputeTask<T,R> task, @Nullable T arg)
task
- Task.arg
- Task argument.public void broadcast(IgniteRunnable job)
broadcast
in interface IgniteCompute
job
- Job to broadcast to all cluster group nodes.public IgniteFuture<Void> broadcastAsync(IgniteRunnable job) throws IgniteException
broadcastAsync
in interface IgniteCompute
job
- Job to broadcast to all cluster group nodes.IgniteException
- If job failed.public <R> Collection<R> broadcast(IgniteCallable<R> job)
broadcast
in interface IgniteCompute
job
- Job to broadcast to all cluster group nodes.public <R> IgniteFuture<Collection<R>> broadcastAsync(IgniteCallable<R> job) throws IgniteException
broadcastAsync
in interface IgniteCompute
job
- Job to broadcast to all cluster group nodes.IgniteException
- If execution failed.public <R,T> Collection<R> broadcast(IgniteClosure<T,R> job, @Nullable T arg)
broadcast
in interface IgniteCompute
job
- Job to broadcast to all cluster group nodes.arg
- Job closure argument.public <R,T> IgniteFuture<Collection<R>> broadcastAsync(IgniteClosure<T,R> job, @Nullable T arg) throws IgniteException
broadcastAsync
in interface IgniteCompute
job
- Job to broadcast to all cluster group nodes.arg
- Job closure argument.IgniteException
- If execution failed.public void run(IgniteRunnable job)
run
in interface IgniteCompute
job
- Job closure to execute.public IgniteFuture<Void> runAsync(IgniteRunnable job) throws IgniteException
runAsync
in interface IgniteCompute
job
- Job closure to execute.IgniteException
- If execution failed.public void run(Collection<? extends IgniteRunnable> jobs)
run
in interface IgniteCompute
jobs
- Collection of jobs to execute.public IgniteFuture<Void> runAsync(Collection<? extends IgniteRunnable> jobs) throws IgniteException
runAsync
in interface IgniteCompute
jobs
- Collection of jobs to execute.IgniteException
- If execution failed.public <R,T> R apply(IgniteClosure<T,R> job, @Nullable T arg)
run(...)
and call(...)
methods in a way that it receives job argument
which is then passed into the closure at execution time.apply
in interface IgniteCompute
job
- Job to run.arg
- Job argument.public <R,T> IgniteFuture<R> applyAsync(IgniteClosure<T,R> job, @Nullable T arg) throws IgniteException
run(...)
and call(...)
methods in a way that
it receives job argument which is then passed into the closure at execution time.applyAsync
in interface IgniteCompute
job
- Job to run.arg
- Job argument.IgniteException
- If execution failed.public <R> R call(IgniteCallable<R> job)
call
in interface IgniteCompute
job
- Job to execute.public <R> IgniteFuture<R> callAsync(IgniteCallable<R> job) throws IgniteException
callAsync
in interface IgniteCompute
job
- Job to execute.IgniteException
- If execution failed.public <R> Collection<R> call(Collection<? extends IgniteCallable<R>> jobs)
call
in interface IgniteCompute
jobs
- Collection of jobs to execute.public <R> IgniteFuture<Collection<R>> callAsync(Collection<? extends IgniteCallable<R>> jobs) throws IgniteException
callAsync
in interface IgniteCompute
jobs
- Collection of jobs to execute.IgniteException
- If execution failed.public <T,R> Collection<R> apply(IgniteClosure<T,R> job, @Nullable Collection<? extends T> args)
apply
in interface IgniteCompute
job
- Job to run.args
- Job arguments.public <T,R> IgniteFuture<Collection<R>> applyAsync(IgniteClosure<T,R> job, Collection<? extends T> args) throws IgniteException
applyAsync
in interface IgniteCompute
job
- Job to run.args
- Job arguments.IgniteException
- If execution failed.public <R1,R2> R2 call(Collection<? extends IgniteCallable<R1>> jobs, IgniteReducer<R1,R2> rdc)
call
in interface IgniteCompute
jobs
- Collection of jobs to execute.rdc
- Reducer to reduce all job results into one individual return value.public <R1,R2> IgniteFuture<R2> callAsync(Collection<? extends IgniteCallable<R1>> jobs, IgniteReducer<R1,R2> rdc) throws IgniteException
callAsync
in interface IgniteCompute
jobs
- Collection of jobs to execute.rdc
- Reducer to reduce all job results into one individual return value.IgniteException
- If execution failed.public <R1,R2,T> R2 apply(IgniteClosure<T,R1> job, Collection<? extends T> args, IgniteReducer<R1,R2> rdc)
apply
in interface IgniteCompute
job
- Job to run.args
- Job arguments.rdc
- Reducer to reduce all job results into one individual return value.public <R1,R2,T> IgniteFuture<R2> applyAsync(IgniteClosure<T,R1> job, Collection<? extends T> args, IgniteReducer<R1,R2> rdc) throws IgniteException
applyAsync
in interface IgniteCompute
job
- Job to run.args
- Job arguments.rdc
- Reducer to reduce all job results into one individual return value.IgniteException
- If execution failed.public <R> Map<IgniteUuid,ComputeTaskFuture<R>> activeTaskFutures()
activeTaskFutures
in interface IgniteCompute
public IgniteCompute withName(String taskName)
ComputeTask
.
Here is an example.
ignite.withName("MyTask").run(new IgniteRunnable() {...});
withName
in interface IgniteCompute
taskName
- Task name.IgniteCompute
instance for chaining calls.public IgniteCompute withTimeout(long timeout)
ComputeTask
.
Here is an example.
ignite.withTimeout(10000).run(new IgniteRunnable() {...});
withTimeout
in interface IgniteCompute
timeout
- Computation timeout in milliseconds.IgniteCompute
instance for chaining calls.public IgniteCompute withNoFailover()
Here is an example.
ignite.compute().withNoFailover().run(new IgniteRunnable() {...});
withNoFailover
in interface IgniteCompute
IgniteCompute
instance for chaining calls.public void localDeployTask(Class<? extends ComputeTask> taskCls, ClassLoader clsLdr)
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.
localDeployTask
in interface IgniteCompute
taskCls
- Task class to deploy. If task class has ComputeTaskName
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.public Map<String,Class<? extends ComputeTask<?,?>>> localTasks()
localTasks
in interface IgniteCompute
public void undeployTask(String taskName)
undeployTask
in interface IgniteCompute
taskName
- Name of the task to undeploy.public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
protected Object readResolve() throws ObjectStreamException
ObjectStreamException
- Thrown in case of unmarshalling error.protected <R> IgniteFuture<R> createFuture(IgniteInternalFuture<R> fut)
createFuture
in class AsyncSupportAdapter<IgniteCompute>
fut
- Internal future.public <R> ComputeTaskFuture<R> future()
future
in interface IgniteCompute
future
in interface IgniteAsyncSupport
future
in class AsyncSupportAdapter<IgniteCompute>
public IgniteCompute withExecutor(@NotNull String name)
Executor should be defined in IgniteConfiguration.setExecutorConfiguration(ExecutorConfiguration...)
.
withExecutor
in interface IgniteCompute
name
- Custom executor name.
Follow @ApacheIgnite
Ignite Fabric : ver. 2.0.0 Release Date : April 30 2017