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,
boolean async) |
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(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).
|
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).
|
<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.
|
<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> 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.
|
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> ComputeTaskInternalFuture<R> |
executeAsync(ComputeTask<T,R> task,
T arg) |
<T,R> ComputeTaskInternalFuture<R> |
executeAsync(String taskName,
T arg) |
<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.
|
void |
undeployTask(String taskName)
Makes the best attempt to undeploy a task with given name within the underlying cluster group.
|
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, boolean async)
ctx
- Kernal context.prj
- Projection.subjId
- Subject ID.async
- Async support flag.protected IgniteCompute createAsyncInstance()
createAsyncInstance
in class AsyncSupportAdapter<IgniteCompute>
public ClusterGroup clusterGroup()
IgniteCompute
instance belongs.clusterGroup
in interface IgniteCompute
IgniteCompute
instance belongs.public void affinityRun(@Nullable 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 <R> R affinityCall(@Nullable 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 <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> 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> 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> ComputeTaskInternalFuture<R> executeAsync(ComputeTask<T,R> task, @Nullable T arg)
task
- Task.arg
- Task argument.public <T,R> ComputeTaskInternalFuture<R> executeAsync(String taskName, @Nullable T arg)
taskName
- Task name.arg
- Task argument.public void broadcast(IgniteRunnable job)
broadcast
in interface IgniteCompute
job
- Job to broadcast to all cluster group nodes.public <R> Collection<R> broadcast(IgniteCallable<R> job)
broadcast
in interface IgniteCompute
job
- Job to broadcast to all cluster group nodes.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 void run(IgniteRunnable job)
run
in interface IgniteCompute
job
- Job closure to execute.public void run(Collection<? extends IgniteRunnable> jobs)
run
in interface IgniteCompute
jobs
- Collection of jobs to execute.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> R call(IgniteCallable<R> job)
call
in interface IgniteCompute
job
- Job to execute.public <R> Collection<R> call(Collection<? extends IgniteCallable<R>> jobs)
call
in interface IgniteCompute
jobs
- Collection of jobs to execute.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 <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,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 <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>
Follow @ApacheIgnite
Ignite Fabric : ver. 1.0.0 Release Date : March 31 2015