|
GridGain 3.6.0e
Enterprise Edition |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gridgain.grid.lang.GridMetadataAwareAdapter
org.gridgain.grid.GridSpringBean
public class GridSpringBean
Grid Spring bean allows to bypass GridFactory methods.
In other words, this bean class allows to inject new grid instance from
Spring configuration file directly without invoking static
GridFactory methods. This class can be wired directly from
Spring and can be referenced from within other Spring beans.
By virtue of implementing DisposableBean and InitializingBean
interfaces, GridSpringBean automatically starts and stops underlying
grid instance.
<bean id="mySpringBean" class="org.gridgain.grid.GridSpringBean" scope="singleton">
<property name="configuration">
<bean id="grid.cfg" class="org.gridgain.grid.GridConfigurationAdapter" scope="singleton">
<property name="gridName" value="mySpringGrid"/>
</bean>
</property>
</bean>
Or use default configuration:
<bean id="mySpringBean" class="org.gridgain.grid.GridSpringBean" scope="singleton"/>
AbstractApplicationContext ctx = new FileSystemXmlApplicationContext("/path/to/spring/file");
// Register Spring hook to destroy bean automatically.
ctx.registerShutdownHook();
Grid grid = (Grid)ctx.getBean("mySpringBean");
| Wiki | |
| Forum |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| Constructor Summary | |
|---|---|
GridSpringBean()
|
|
| Method Summary | ||
|---|---|---|
void |
addLocalEventListener(GridLocalEventListener lsnr,
int[] types)
Adds an event listener for local events. |
|
void |
addLocalEventListener(GridLocalEventListener lsnr,
int type,
int... types)
Adds an event listener for local events. |
|
void |
addMessageListener(GridMessageListener lsnr,
GridPredicate<Object>... p)
Register a message listener to receive messages that are sent by remote nodes and which pass all provided message filters. |
|
|
affinityCall(String cacheName,
Collection<?> affKeys,
Callable<R> job,
GridPredicate<? super GridRichNode>... p)
Executes given closure on the nodes where data for provided affinity keys are located. |
|
|
affinityCall(String cacheName,
Object affKey,
Callable<R> job,
GridPredicate<? super GridRichNode>... p)
Executes given closure on the node where data for provided affinity key is located. |
|
|
affinityCallAsync(String cacheName,
Collection<?> affKeys,
Callable<R> job,
GridPredicate<? super GridRichNode>... p)
Executes given closure on the nodes where data for provided affinity keys are located. |
|
|
affinityCallAsync(String cacheName,
Object affKey,
Callable<R> job,
GridPredicate<? super GridRichNode>... p)
Executes given closure on the node where data for provided affinity key is located. |
|
void |
affinityRun(String cacheName,
Collection<?> affKeys,
Runnable job,
GridPredicate<? super GridRichNode>... p)
Executes given closure on the nodes where data for provided affinity keys are located. |
|
void |
affinityRun(String cacheName,
Object affKey,
Runnable job,
GridPredicate<? super GridRichNode>... p)
Executes given closure on the node where data for provided affinity key is located. |
|
GridFuture<?> |
affinityRunAsync(String cacheName,
Collection<?> affKeys,
Runnable job,
GridPredicate<? super GridRichNode>... p)
Executes given closure on the nodes where data for provided affinity keys are located. |
|
GridFuture<?> |
affinityRunAsync(String cacheName,
Object affKey,
Runnable job,
GridPredicate<? super GridRichNode>... p)
Executes given closure on the node where data for provided affinity key is located. |
|
void |
afterPropertiesSet()
|
|
String |
build()
Gets build number of this GridGain instance. |
|
|
cache()
Gets default cache instance if one is configured or null otherwise. |
|
|
cache(String name)
Gets the cache instance for the given name if one is configured or null otherwise. |
|
Collection<GridCache<?,?>> |
caches(GridPredicate<? super GridCache<?,?>>... p)
Gets configured cache instance that satisfy all provided predicates. |
|
|
call(GridClosureCallMode mode,
Callable<R> job,
GridPredicate<? super GridRichNode>... p)
Executes given closure on this projection. |
|
|
call(GridClosureCallMode mode,
Collection<? extends Callable<R>> jobs,
GridPredicate<? super GridRichNode>... p)
Executes given closures on this projection. |
|
|
call(GridClosureCallMode mode,
Collection<? extends GridClosure<? super T,R>> jobs,
Collection<? extends T> args,
GridPredicate<? super GridRichNode>... p)
Runs given collection of jobs taking argument and producing result on this projection with given collection of arguments using given distribution mode. |
|
|
call(GridClosureCallMode mode,
GridClosure<? super T,R> job,
Collection<? extends T> args,
GridPredicate<? super GridRichNode>... p)
Runs job taking argument and producing result on this projection with given collection of arguments using given distribution mode. |
|
|
call(GridClosureCallMode mode,
GridClosure<? super T,R> job,
GridOutClosure<T> pdc,
int cnt,
GridPredicate<? super GridRichNode>... p)
Runs job taking argument and producing result on this projection with given producer of arguments using given distribution mode. |
|
|
call(GridClosureCallMode mode,
GridClosure<? super T,R> job,
T arg,
GridPredicate<? super GridRichNode>... p)
Runs job producing result with given argument on this projection using given distribution mode. |
|
|
call(GridMapper<Callable<R>,GridRichNode> mapper,
Collection<? extends Callable<R>> jobs,
GridPredicate<? super GridRichNode>... p)
Runs given collection of jobs producing result on this projection using given mapper to map jobs to nodes. |
|
|
callAsync(GridClosureCallMode mode,
Callable<R> job,
GridPredicate<? super GridRichNode>... p)
Asynchronously executes given closure on this projection. |
|
|
callAsync(GridClosureCallMode mode,
Collection<? extends Callable<R>> jobs,
GridPredicate<? super GridRichNode>... p)
Asynchronously executes given closures on this projection. |
|
|
callAsync(GridClosureCallMode mode,
Collection<? extends GridClosure<? super T,R>> jobs,
Collection<? extends T> args,
GridPredicate<? super GridRichNode>... p)
Runs given collection of jobs taking argument and producing result on this projection with given collection of arguments using given distribution mode. |
|
|
callAsync(GridClosureCallMode mode,
GridClosure<? super T,R> job,
Collection<? extends T> args,
GridPredicate<? super GridRichNode>... p)
Runs job taking argument and producing result on this projection with given collection of arguments using given distribution mode. |
|
|
callAsync(GridClosureCallMode mode,
GridClosure<? super T,R> job,
GridOutClosure<T> pdc,
int cnt,
GridPredicate<? super GridRichNode>... p)
Runs job taking argument and producing result on this projection with given producer of arguments using given distribution mode. |
|
|
callAsync(GridClosureCallMode mode,
GridClosure<? super T,R> job,
T arg,
GridPredicate<? super GridRichNode>... p)
Runs job producing result with given argument on this projection using given distribution mode. |
|
|
callAsync(GridMapper<Callable<R>,GridRichNode> mapper,
Collection<? extends Callable<R>> jobs,
GridPredicate<? super GridRichNode>... p)
Runs given collection of jobs producing result on this projection using given mapper to map jobs to nodes. |
|
|
callLocal(Callable<R> c)
Executes given callable on internal system thread pool asynchronously. |
|
|
callOptimistic(GridOutClosure<R> c,
int attempts,
R dfltVal,
GridAbsClosure rollback,
GridPredicate<? super GridRichNode>... p)
Executes given closure in optimistic topology transaction, i.e. ensuring that grid topology doesn't change during the closure execution. |
|
|
callOptimisticAsync(GridOutClosure<R> c,
int attempts,
R dfltVal,
GridAbsClosure rollback,
GridPredicate<? super GridRichNode>... p)
Executes given closure locally in optimistic topology transaction, i.e. ensuring that grid topology doesn't change during the closure execution. |
|
void |
clearSwapSpace(String space)
Clears all entry from the specified swap space. |
|
GridConfiguration |
configuration()
Gets the configuration of this grid instance. |
|
boolean |
contains(GridNode node,
GridPredicate<? super GridRichNode>... p)
Tests whether or not this optionally filtered projection contains given node. |
|
boolean |
contains(UUID nodeId,
GridPredicate<? super GridRichNode>... p)
Tests whether or not this optionally filtered projection contains a node with given node ID. |
|
String |
copyright()
Copyright statement for GridGain code. |
|
int |
cpus()
Gets total number of CPUs for the nodes in this projection. |
|
GridProjection |
cross(Collection<? extends GridNode> nodes)
Creates cross product of this projection and a set of nodes. |
|
GridProjection |
cross(GridProjection... prjs)
Creates cross product of this projection and given projections. |
|
GridProjection |
cross0(GridRichNode... nodes)
Creates cross product of this projection and a set of nodes. |
|
Collection<GridRichNode> |
daemonNodes(GridPredicate<? super GridRichNode>... p)
Gets collection of daemon nodes in this projection. |
|
void |
deployTask(Class<? extends GridTask> taskCls)
Explicitly deploys given grid task on the local node. |
|
void |
deployTask(Class<? extends GridTask> taskCls,
ClassLoader clsLdr)
Explicitly deploys given grid task on the local node. |
|
void |
destroy()
|
|
boolean |
dynamic()
Tells whether or not this projection is dynamic. |
|
|
execute(Class<? extends GridTask<T,R>> taskCls,
T arg,
GridPredicate<? super GridRichNode>... p)
Executes a task on the grid. |
|
|
execute(Class<? extends GridTask<T,R>> taskCls,
T arg,
GridTaskListener lsnr,
GridPredicate<? super GridRichNode>... p)
Asynchronously executes a task on the grid. |
|
|
execute(Class<? extends GridTask<T,R>> taskCls,
T arg,
long timeout,
GridPredicate<? super GridRichNode>... p)
Executes a task on the grid. |
|
|
execute(Class<? extends GridTask<T,R>> taskCls,
T arg,
long timeout,
GridTaskListener lsnr,
GridPredicate<? super GridRichNode>... p)
Asynchronously executes a task on the grid. |
|
|
execute(GridTask<T,R> task,
T arg,
GridPredicate<? super GridRichNode>... p)
Executes a task on the grid. |
|
|
execute(GridTask<T,R> task,
T arg,
GridTaskListener lsnr,
GridPredicate<? super GridRichNode>... p)
Asynchronously executes a task on the grid. |
|
|
execute(GridTask<T,R> task,
T arg,
long timeout,
GridPredicate<? super GridRichNode>... p)
Executes a task on the grid. |
|
|
execute(GridTask<T,R> task,
T arg,
long timeout,
GridTaskListener lsnr,
GridPredicate<? super GridRichNode>... p)
Asynchronously executes a task on the grid. |
|
|
execute(String taskName,
T arg,
GridPredicate<? super GridRichNode>... p)
Executes a task on the grid. |
|
|
execute(String taskName,
T arg,
GridTaskListener lsnr,
GridPredicate<? super GridRichNode>... p)
Asynchronously executes a task on the grid. |
|
|
execute(String taskName,
T arg,
long timeout,
GridPredicate<? super GridRichNode>... p)
Executes a task on the grid. |
|
|
execute(String taskName,
T arg,
long timeout,
GridTaskListener lsnr,
GridPredicate<? super GridRichNode>... p)
Asynchronously executes a task on the grid. |
|
|
executeSync(Class<? extends GridTask<T,R>> taskCls,
T arg,
long timeout,
GridPredicate<? super GridRichNode>... p)
Companion to GridProjection.execute(Class, Object, GridPredicate[]) this method executes given
task synchronously. |
|
|
executeSync(GridTask<T,R> task,
T arg,
long timeout,
GridPredicate<? super GridRichNode>... p)
Companion to GridProjection.execute(Class, Object, GridPredicate[]) this method
executes given task synchronously. |
|
|
executeSync(String taskName,
T arg,
long timeout,
GridPredicate<? super GridRichNode>... p)
Companion to GridProjection.execute(String, Object, GridPredicate[]) this method executes given task synchronously. |
|
ExecutorService |
executor(GridPredicate<? super GridRichNode>... p)
Creates new ExecutorService which will execute all submitted
Callable and Runnable tasks on this projection. |
|
Grid |
grid()
Gets grid instance associated with this projection. |
|
|
gridify(GridClosureCallMode mode,
Callable<T> c,
GridPredicate<? super GridRichNode>... p)
Curries given closure into distribution version of it. |
|
GridOutClosure<GridFuture<Boolean>> |
gridify(GridClosureCallMode mode,
GridAbsPredicate c,
GridPredicate<? super GridRichNode>... p)
Curries given predicate into distribution version of it. |
|
|
gridify(GridClosureCallMode mode,
GridClosure<E,T> c,
GridPredicate<? super GridRichNode>... p)
Curries given closure into distribution version of it. |
|
|
gridify(GridClosureCallMode mode,
GridClosure2<E1,E2,T> c,
GridPredicate<? super GridRichNode>... p)
Curries given closure into distribution version of it. |
|
|
gridify(GridClosureCallMode mode,
GridClosure3<E1,E2,E3,T> c,
GridPredicate<? super GridRichNode>... p)
Curries given closure into distribution version of it. |
|
|
gridify(GridClosureCallMode mode,
GridInClosure<E> c,
GridPredicate<? super GridRichNode>... p)
Curries given closure into distribution version of it. |
|
|
gridify(GridClosureCallMode mode,
GridInClosure2<E1,E2> c,
GridPredicate<? super GridRichNode>... p)
Curries given closure into distribution version of it. |
|
|
gridify(GridClosureCallMode mode,
GridInClosure3<E1,E2,E3> c,
GridPredicate<? super GridRichNode>... p)
Curries given closure into distribution version of it. |
|
|
gridify(GridClosureCallMode mode,
GridPredicate<E> c,
GridPredicate<? super GridRichNode>... p)
Curries given predicate into distribution version of it. |
|
|
gridify(GridClosureCallMode mode,
GridPredicate2<E1,E2> c,
GridPredicate<? super GridRichNode>... p)
Curries given predicate into distribution version of it. |
|
|
gridify(GridClosureCallMode mode,
GridPredicate3<E1,E2,E3> c,
GridPredicate<? super GridRichNode>... p)
Curries given predicate into distribution version of it. |
|
GridOutClosure<GridFuture<?>> |
gridify(GridClosureCallMode mode,
Runnable r,
GridPredicate<? super GridRichNode>... p)
Curries given closure into distribution version of it. |
|
boolean |
hasLocalNode()
Tests whether or not this projection has local node in it. |
|
boolean |
hasRemoteNodes()
Tests whether or not this projection has any remote nodes. |
|
int |
hosts()
Gets number of unique hosts for nodes in this projection. |
|
boolean |
isEmpty()
Tests whether this projection has any nodes in it. |
|
boolean |
isEmptyFor(GridPredicate<? super GridRichNode>... p)
Tests whether this optionally filtered projection has any nodes in it. |
|
boolean |
isEnterprise()
Tests whether or not this GridGain runtime runs on an enterprise edition. |
|
boolean |
isJmxRemoteEnabled()
Whether or not remote JMX management is enabled for this node. |
|
boolean |
isRestartEnabled()
Whether or not node restart is enabled. |
|
boolean |
isSmtpEnabled()
Whether or not SMTP is configured. |
|
Iterator<GridRichNode> |
iterator()
|
|
GridEnterpriseLicense |
license()
Gets enterprise license descriptor. |
|
|
listen(GridPredicate2<UUID,? super T>... p)
Convenient utility listening method for messages from the nodes in this projection. |
|
Collection<GridEvent> |
localEvents(GridPredicate<? super GridEvent>... p)
Queries local node for events using passed-in predicate filters for event selection. |
|
GridRichNode |
localNode()
Gets local grid node. |
|
Map<String,Class<? extends GridTask<?,?>>> |
localTasks(GridPredicate<? super Class<? extends GridTask<?,?>>>... p)
Gets map of all locally deployed tasks keyed by their task name satisfying all given predicates. |
|
GridLogger |
log()
Gets grid's logger. |
|
|
mapKeysToNodes(Collection<? extends K> keys)
This method provides ability to detect which cache keys are mapped to which nodes on default unnamed cache instance. |
|
|
mapKeysToNodes(String cacheName,
Collection<? extends K> keys)
This method provides ability to detect which cache keys are mapped to which nodes on cache instance with given name. |
|
|
mapKeyToNode(K key)
This method provides ability to detect which keys are mapped to which nodes on default unnamed cache instance. |
|
|
mapKeyToNode(String cacheName,
K key)
This method provides ability to detect which cache keys are mapped to which nodes on cache instance with given name. |
|
|
mapreduce(GridMapper<GridOutClosure<R1>,GridRichNode> mapper,
Collection<? extends GridClosure<? super T,R1>> jobs,
Collection<? extends T> args,
GridReducer<R1,R2> rdc,
GridPredicate<? super GridRichNode>... p)
Runs given collection of jobs taking argument and producing result on this projection with given collection of arguments using given mapper to map jobs to nodes and then reduces job results to a single execution result using provided reducer. |
|
|
mapreduce(GridMapper<GridOutClosure<R1>,GridRichNode> mapper,
GridClosure<? super T,R1> job,
Collection<? extends T> args,
GridReducer<R1,R2> rdc,
GridPredicate<? super GridRichNode>... p)
Runs job taking argument and producing result on this projection with given collection of arguments using given mapper to map job executions to nodes. |
|
|
mapreduce(GridMapper<GridOutClosure<R1>,GridRichNode> mapper,
GridClosure<? super T,R1> job,
GridOutClosure<T> pdc,
int cnt,
GridReducer<R1,R2> rdc,
GridPredicate<? super GridRichNode>... p)
Runs job taking argument and producing result on this projection with given producer of arguments using given mapper to map job executions to nodes. |
|
|
mapreduce(GridMapper<T,GridRichNode> mapper,
Collection<T> jobs,
GridReducer<R1,R2> rdc,
GridPredicate<? super GridRichNode>... p)
Executes given jobs on this projection with custom mapping and reducing logic. |
|
|
mapreduceAsync(GridMapper<GridOutClosure<R1>,GridRichNode> mapper,
Collection<? extends GridClosure<? super T,R1>> jobs,
Collection<? extends T> args,
GridReducer<R1,R2> rdc,
GridPredicate<? super GridRichNode>... p)
Runs given collection of jobs taking argument and producing result on this projection with given collection of arguments using given mapper to map jobs to nodes and then reduces job results to a single execution result using provided reducer. |
|
|
mapreduceAsync(GridMapper<GridOutClosure<R1>,GridRichNode> mapper,
GridClosure<? super T,R1> job,
Collection<? extends T> args,
GridReducer<R1,R2> rdc,
GridPredicate<? super GridRichNode>... p)
Runs job taking argument and producing result on this projection with given collection of arguments using given mapper to map job executions to nodes. |
|
|
mapreduceAsync(GridMapper<GridOutClosure<R1>,GridRichNode> mapper,
GridClosure<? super T,R1> job,
GridOutClosure<T> pdc,
int cnt,
GridReducer<R1,R2> rdc,
GridPredicate<? super GridRichNode>... p)
Runs job taking argument and producing result on this projection with given producer of arguments using given mapper to map job executions to nodes. |
|
|
mapreduceAsync(GridMapper<T,GridRichNode> mapper,
Collection<T> jobs,
GridReducer<R1,R2> rdc,
GridPredicate<? super GridRichNode>... p)
Asynchronously executes given jobs on this projection with custom mapping and reducing logic. |
|
GridProjection |
merge(GridProjection... prjs)
Merges this projection with the optional set of passed in projections. |
|
String |
name()
Gets the name of the grid this grid instance (and correspondingly its local node) belongs to. |
|
Collection<GridProjection> |
neighborhood()
Gets collections of neighbors from this projection. |
|
GridRichNode |
node(UUID nodeId,
GridPredicate<? super GridRichNode>... p)
Gets a node for given ID from this optionally filtered projection. |
|
Collection<GridRichNode> |
nodeId8(String id8)
Gets collection of nodes for given node ID8. |
|
|
nodeLocal()
Gets node-local storage instance. |
|
Collection<GridRichNode> |
nodes(Collection<UUID> ids)
Gets collection of grid nodes for given node IDs out of this projection. |
|
Collection<GridRichNode> |
nodes(GridPredicate<? super GridRichNode>... p)
Gets read-only collections of nodes in this projection that evaluate to true for all
given predicates. |
|
GridRichNode |
oldest()
Gets the oldest node in this topology. |
|
GridRichNode |
oldestx()
Gets the oldest node in this topology. |
|
GridProjection |
parent()
Gets parent projection or null if this project is an instance of Grid interface, i.e. |
|
boolean |
pingNode(UUID nodeId)
Pings a remote node. |
|
GridPredicate<GridRichNode> |
predicate()
Gets predicate that defines a subset of nodes for this projection at the time of the call. |
|
GridProjection |
projectionForAttribute(String n,
String v)
Creates monadic projection with the nodes from this projection that have given node attribute with optional value. |
|
GridProjection |
projectionForCaches(String cacheName,
String... cacheNames)
Creates monadic projection with the nodes from this projection that have configured caches with given names. |
|
GridProjection |
projectionForNodeIds(Collection<UUID> nodeIds)
Creates monadic projection with a given set of node IDs out of this projection. |
|
GridProjection |
projectionForNodeIds(UUID... ids)
Creates monadic projection with a given set of node IDs ouf of this projection. |
|
GridProjection |
projectionForNodes(Collection<? extends GridNode> nodes)
Creates monadic projection with a given set of nodes out of this projection. |
|
GridProjection |
projectionForNodes(GridRichNode... nodes)
Creates monadic projection with a given set of nodes out of this projection. |
|
GridProjection |
projectionForPredicate(GridPredicate<? super GridRichNode>... p)
Creates monadic projection with the nodes from this projection that also satisfy given set of predicates. |
|
GridProjectionMetrics |
projectionMetrics()
Gets a metrics snapshot for this projection. |
|
GridRichNode |
random()
Gets the randomly selected node from this projection. |
|
GridRichNode |
randomx()
Gets the randomly selected node from this projection. |
|
void |
readExternal(ObjectInput in)
|
|
|
readFromSwap(String space,
Object key,
ClassLoader ldr)
Reads data stored by Grid.writeToSwap(String, Object, Object, ClassLoader) method. |
|
void |
recordLocalEvent(GridEvent evt)
Records locally generated event. |
|
|
reduce(GridClosureCallMode mode,
Collection<? extends Callable<R1>> jobs,
GridReducer<R1,R2> rdc,
GridPredicate<? super GridRichNode>... p)
Executes given jobs on this projection. |
|
|
reduce(GridClosureCallMode mode,
Collection<? extends GridClosure<? super T,R1>> jobs,
Collection<? extends T> args,
GridReducer<R1,R2> rdc,
GridPredicate<? super GridRichNode>... p)
Runs given collection of jobs taking argument and producing result on this projection with given collection of arguments using given distribution mode and then reduces job results to a single execution result using provided reducer. |
|
|
reduce(GridClosureCallMode mode,
GridClosure<? super T,R1> job,
Collection<? extends T> args,
GridReducer<R1,R2> rdc,
GridPredicate<? super GridRichNode>... p)
Runs job taking argument and producing result on this projection with given collection of arguments using given distribution mode. |
|
|
reduce(GridClosureCallMode mode,
GridClosure<? super T,R1> job,
GridOutClosure<T> pdc,
int cnt,
GridReducer<R1,R2> rdc,
GridPredicate<? super GridRichNode>... p)
Runs job taking argument and producing result on this projection with given producer of arguments using given distribution mode. |
|
|
reduceAsync(GridClosureCallMode mode,
Collection<? extends Callable<R1>> jobs,
GridReducer<R1,R2> rdc,
GridPredicate<? super GridRichNode>... p)
Asynchronously executes given jobs on this projection. |
|
|
reduceAsync(GridClosureCallMode mode,
Collection<? extends GridClosure<? super T,R1>> jobs,
Collection<? extends T> args,
GridReducer<R1,R2> rdc,
GridPredicate<? super GridRichNode>... p)
Runs given collection of jobs taking argument and producing result on this projection with given collection of arguments using given distribution mode and then reduces job results to a single execution result using provided reducer. |
|
|
reduceAsync(GridClosureCallMode mode,
GridClosure<? super T,R1> job,
Collection<? extends T> args,
GridReducer<R1,R2> rdc,
GridPredicate<? super GridRichNode>... p)
Runs job taking argument and producing result on this projection with given collection of arguments using given distribution mode. |
|
|
reduceAsync(GridClosureCallMode mode,
GridClosure<? super T,R1> job,
GridOutClosure<T> pdc,
int cnt,
GridReducer<R1,R2> rdc,
GridPredicate<? super GridRichNode>... p)
Runs job taking argument and producing result on this projection with given producer of arguments using given distribution mode. |
|
List<GridEvent> |
remoteEvents(GridPredicate<? super GridEvent> pe,
long timeout,
GridPredicate<? super GridRichNode>... pn)
Queries nodes in this projection for events using passed in predicate filter for event selection. |
|
GridFuture<List<GridEvent>> |
remoteEventsAsync(GridPredicate<? super GridEvent> pe,
long timeout,
GridPredicate<? super GridRichNode>... pn)
Asynchronously queries nodes in this projection for events using passed in predicate filter for event selection. |
|
|
remoteListenAsync(Collection<? extends GridNode> nodes,
GridPredicate2<UUID,? super T>... p)
Registers given message listeners on all nodes defined by this projection to listen for messages sent from the given nodes. |
|
|
remoteListenAsync(GridNode node,
GridPredicate2<UUID,? super T>... p)
Registers given message listeners on all nodes defined by this projection to listen for messages sent from the given node. |
|
|
remoteListenAsync(GridPredicate<? super GridRichNode> pn,
GridPredicate2<UUID,? super T>... p)
Registers given message listeners on all nodes defined by this projection to listen for messages sent from the nodes defined via predicate. |
|
Collection<GridRichNode> |
remoteNodes(GridPredicate<? super GridRichNode>... p)
Gets read-only collections of nodes from this projection excluding local node, if any. |
|
GridProjection |
remoteProjection(GridPredicate<? super GridRichNode>... p)
Gets monadic projection consisting from the nodes in this projection excluding the local node, if any. |
|
void |
removeFromSwap(String space,
Object key,
GridInClosure<Object> c,
ClassLoader ldr)
Removes data stored by Grid.writeToSwap(String, Object, Object, ClassLoader) method. |
|
boolean |
removeLocalEventListener(GridLocalEventListener lsnr,
int... types)
Removes local event listener. |
|
boolean |
removeMessageListener(GridMessageListener lsnr)
Removes a previously registered message listener. |
|
void |
restartNodes(Collection<UUID> ids)
Restarts nodes defined by provided IDs. |
|
void |
restartNodes(GridPredicate<? super GridRichNode>... p)
Restarts nodes satisfying optional set of predicates. |
|
void |
restartNodes(UUID id,
UUID... ids)
Restarts nodes defined by provided IDs. |
|
GridRichNode |
rich(GridNode node)
Creates grid rich node wrapped around given thin node. |
|
|
run(GridClosureCallMode mode,
Collection<? extends GridInClosure<? super T>> jobs,
Collection<? extends T> args,
GridPredicate<? super GridRichNode>... p)
Runs given collection of jobs taking argument on this projection with given collection of arguments using given distribution mode. |
|
void |
run(GridClosureCallMode mode,
Collection<? extends Runnable> jobs,
GridPredicate<? super GridRichNode>... p)
Executes given closures on this projection. |
|
|
run(GridClosureCallMode mode,
GridInClosure<? super T> job,
Collection<? extends T> args,
GridPredicate<? super GridRichNode>... p)
Runs job taking argument on this projection with given collection of arguments using given distribution mode. |
|
|
run(GridClosureCallMode mode,
GridInClosure<? super T> job,
GridOutClosure<T> pdc,
int cnt,
GridPredicate<? super GridRichNode>... p)
Runs job taking argument on this projection with given producer of arguments using given distribution mode. |
|
|
run(GridClosureCallMode mode,
GridInClosure<? super T> job,
T arg,
GridPredicate<? super GridRichNode>... p)
Runs job that doesn't produce any result with given argument on this projection using given distribution mode. |
|
void |
run(GridClosureCallMode mode,
Runnable job,
GridPredicate<? super GridRichNode>... p)
Executes given closure on this projection. |
|
void |
run(GridMapper<Runnable,GridRichNode> mapper,
Collection<? extends Runnable> jobs,
GridPredicate<? super GridRichNode>... p)
Executes collections of closures using given mapper on this projection. |
|
|
runAsync(GridClosureCallMode mode,
Collection<? extends GridInClosure<? super T>> jobs,
Collection<? extends T> args,
GridPredicate<? super GridRichNode>... p)
Runs given collection of jobs taking argument on this projection with given collection of arguments using given distribution mode. |
|
GridFuture<?> |
runAsync(GridClosureCallMode mode,
Collection<? extends Runnable> jobs,
GridPredicate<? super GridRichNode>... p)
Asynchronously executes given closures on this projection. |
|
|
runAsync(GridClosureCallMode mode,
GridInClosure<? super T> job,
Collection<? extends T> args,
GridPredicate<? super GridRichNode>... p)
Runs job taking argument on this projection with given collection of arguments using given distribution mode. |
|
|
runAsync(GridClosureCallMode mode,
GridInClosure<? super T> job,
GridOutClosure<T> pdc,
int cnt,
GridPredicate<? super GridRichNode>... p)
Runs job taking argument on this projection with given producer of arguments using given distribution mode. |
|
|
runAsync(GridClosureCallMode mode,
GridInClosure<? super T> job,
T arg,
GridPredicate<? super GridRichNode>... p)
Runs job that doesn't produce any result with given argument on this projection using given distribution mode. |
|
GridFuture<?> |
runAsync(GridClosureCallMode mode,
Runnable job,
GridPredicate<? super GridRichNode>... p)
Asynchronously executes given closure on this projection. |
|
GridFuture<?> |
runAsync(GridMapper<Runnable,GridRichNode> mapper,
Collection<? extends Runnable> jobs,
GridPredicate<? super GridRichNode>... p)
Asynchronously executes collections of closures using given mapper on this projection. |
|
GridFuture<?> |
runLocal(Runnable r)
Executes given closure on internal system thread pool asynchronously. |
|
boolean |
runOptimistic(GridAbsClosure c,
int attempts,
GridAbsClosure rollback,
GridPredicate<? super GridRichNode>... p)
Executes given closure locally in optimistic topology transaction, i.e. ensuring that projection topology doesn't change during the closure execution. |
|
GridFuture<Boolean> |
runOptimisticAsync(GridAbsClosure c,
int attempts,
GridAbsClosure rollback,
GridPredicate<? super GridRichNode>... p)
Executes given closure in optimistic topology transaction, i.e. ensuring that grid topology doesn't change during the closure execution. |
|
|
scheduleLocal(Callable<R> r,
String pattern)
Schedules closure for execution using local cron-based scheduling. |
|
GridScheduleFuture<?> |
scheduleLocal(Runnable r,
String pattern)
Schedules closure for execution using local cron-based scheduling. |
|
void |
send(Collection<?> msgs,
GridPredicate<? super GridRichNode>... p)
Sends given messages to the nodes in this projection. |
|
void |
send(Object msg,
GridPredicate<? super GridRichNode>... p)
Sends given message to the nodes in this projection. |
|
void |
sendAdminEmail(String subj,
String body,
boolean html)
Sends given email to all configured admin emails. |
|
GridFuture<Boolean> |
sendAdminEmailAsync(String subj,
String body,
boolean html)
Schedule sending of given email to all configured admin emails. |
|
void |
setApplicationContext(org.springframework.context.ApplicationContext ctx)
|
|
void |
setConfiguration(GridConfiguration cfg)
Sets grid configuration. |
|
int |
size(GridPredicate<? super GridRichNode>... p)
Gets number of nodes currently in this projection and satisfying optional set of predicates. |
|
GridPair<GridProjection> |
split(GridPredicate<? super GridRichNode>... p)
Splits this projection into two: first will have nodes that evaluate to true for all
given predicates, second will have the remaining nodes. |
|
Collection<GridTuple3<String,Boolean,String>> |
startNodes(Collection<String> hostSpecs,
String dfltUname,
String dfltPasswd,
File key,
int nodes,
String ggHome,
String cfg,
String script,
String log,
boolean restart)
Starts one or more nodes on remote host(s) defined by collection of host specifications. |
|
Collection<GridTuple3<String,Boolean,String>> |
startNodes(File file,
String dfltUname,
String dfltPasswd,
File key,
int nodes,
String ggHome,
String cfg,
String script,
String log,
boolean restart)
Starts one or more nodes on remote host(s) defined by file with host specifications (one specification per line). |
|
void |
stopNodes(Collection<UUID> ids)
Stops nodes defined by provided IDs. |
|
void |
stopNodes(GridPredicate<? super GridRichNode>... p)
Stops nodes satisfying optional set of predicates. |
|
void |
stopNodes(UUID id,
UUID... ids)
Stops nodes defined by provided IDs. |
|
long |
topologyHash(GridPredicate<? super GridRichNode>... p)
This method calculates hash value of the given set of nodes (a topology). |
|
long |
topologyHash(Iterable<? extends GridNode> nodes)
This method calculates hash value of the given set of nodes (a topology). |
|
String |
toString()
|
|
void |
undeployTask(String taskName)
Makes the best attempt to undeploy a task from the whole grid. |
|
String |
version()
Ges version string of the GridGain instance. |
|
GridEvent |
waitForEvent(long timeout,
Runnable c,
GridPredicate<? super GridEvent> p,
int... types)
Blocks and waits for the local event. |
|
GridFuture<GridEvent> |
waitForEventAsync(GridPredicate<? super GridEvent> p,
int... types)
Gets event future that allows for asynchronous waiting for the specified events. |
|
GridProjection |
withCheckpointSpi(String spiName)
Sets checkpoint SPI for the next executed task on this projection in the current thread. |
|
GridProjection |
withFailoverSpi(String spiName)
Sets failover SPI for the next executed task on this projection in the current thread. |
|
GridProjection |
withLoadBalancingSpi(String spiName)
Sets load balancing SPI for the next executed task on this projection in the current thread. |
|
GridProjection |
withName(String taskName)
Sets task name for the next executed task on this projection in the current thread. |
|
GridProjection |
withResultClosure(GridClosure2X<GridJobResult,List<GridJobResult>,GridJobResultPolicy> res)
Sets custom ad-hoc implementation for GridTask.result(GridJobResult, List) method for the
next executed closure on this projection in the current thread. |
|
GridProjection |
withTopologySpi(String spiName)
Sets topology SPI for the next executed task on this projection in the current thread. |
|
void |
writeExternal(ObjectOutput out)
|
|
void |
writeToSwap(String space,
Object key,
Object val,
ClassLoader ldr)
Writes given data to specified swap space. |
|
GridRichNode |
youngest()
Gets the youngest node in this topology. |
|
GridRichNode |
youngestx()
Gets the youngest node in this topology. |
|
| Methods inherited from class org.gridgain.grid.lang.GridMetadataAwareAdapter |
|---|
addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, clone, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, putMetaIfAbsent, readExternalMeta, removeMeta, removeMeta, replaceMeta, writeExternalMeta |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.gridgain.grid.GridMetadataAware |
|---|
addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, putMetaIfAbsent, removeMeta, removeMeta, replaceMeta |
| Constructor Detail |
|---|
public GridSpringBean()
| Method Detail |
|---|
public GridConfiguration configuration()
NOTE:
SPIs obtains through this method should never be used directly. SPIs provide
internal view on the subsystem and is used internally by GridGain kernal. In rare use cases when
access to a specific implementation of this SPI is required - an instance of this SPI can be obtained
via this method to check its configuration properties or call other non-SPI
methods.
configuration in interface Gridpublic void setConfiguration(GridConfiguration cfg)
cfg - Grid configuration.
public void setApplicationContext(org.springframework.context.ApplicationContext ctx)
throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwareorg.springframework.beans.BeansExceptionpublic Grid grid()
grid in interface GridProjection
public void destroy()
throws Exception
destroy in interface org.springframework.beans.factory.DisposableBeanException
public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanExceptionpublic GridLogger log()
log in interface Grid
public GridProjectionMetrics projectionMetrics()
throws GridException
projectionMetrics in interface GridProjectionGridException - If projection is empty.
GridNode.metrics()public Collection<GridRichNode> daemonNodes(@Nullable GridPredicate<? super GridRichNode>... p)
Daemon nodes are the usual grid nodes that participate in topology but not visible on the main APIs, i.e. they are not part of any projections. The only way to see daemon nodes is to use this method.
Daemon nodes are used primarily for management and monitoring functionality that is build on GridGain and needs to participate in the topology but also needs to be excluded from "normal" topology so that it won't participate in task execution or data grid storage.
daemonNodes in interface GridProjectionp - Optional set of predicates. If none provided - all daemon nodes will be returned.
null.public GridProjection parent()
null if this project is an instance of Grid interface, i.e.
root projection.
parent in interface GridProjectionnull.
public GridProjection projectionForAttribute(String n,
@Nullable
String v)
null than simple attribute presence
(with any value) will be used for inclusion of the node.
projectionForAttribute in interface GridProjectionn - Name of the attribute.v - Optional attribute value to match.
public GridProjection projectionForCaches(@Nullable
String cacheName,
@Nullable
String... cacheNames)
projectionForCaches in interface GridProjectioncacheName - Cache name.cacheNames - Cache names.
public int size(@Nullable
GridPredicate<? super GridRichNode>... p)
size in interface GridProjectionp - Optional set of predicates. If none provided - all nodes in the projection
will count.
public String version()
version in interface GridGrid.build()public String copyright()
copyright in interface Gridpublic String build()
build in interface GridGrid.version()public GridRichNode random()
random in interface GridProjectionnull if
projection is empty.GridProjection.randomx()
public boolean runOptimistic(GridAbsClosure c,
int attempts,
@Nullable
GridAbsClosure rollback,
@Nullable
GridPredicate<? super GridRichNode>... p)
Note that this method will block until closure execution is complete (successfully or not). Note also that transactional semantic of this method is optimistic. No locking of grid topology is performed but the topology version is checked before and after the closure execution and compared to be the same.
Note also that if given closure or rollback closure throw runtime exception it will be propagated to the caller without any special handling. Specifically, a rollback closure won't be called if the executing closure throws runtime exception.
runOptimistic in interface GridProjectionc - Closure to execute on unchanged topology.attempts - Number of re-execution attempts. Must be greater than zero.rollback - Optional rollback closure to execute in case when topology did indeed change during
closure execution. If not provided - the given closure will simply execute again.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
True if closure successfully executed on unchanged topology - false if number
of attempts is exceeded.GridProjection.runOptimisticAsync(GridAbsClosure, int, GridAbsClosure, GridPredicate[])public <R> R callOptimistic(GridOutClosure<R> c, int attempts, R dfltVal, @Nullable GridAbsClosure rollback, @Nullable GridPredicate<? super GridRichNode>... p)
Note that this method will block until closure execution is complete (successfully or not). Note also that transactional semantic of this method is optimistic. No locking of grid topology is performed but the topology version is checked before and after the closure execution and compared to be the same.
Note also that if given closure or rollback closure throw runtime exception it will be propagated to the caller without any special handling. Specifically, a rollback closure won't be called if the executing closure throws runtime exception.
callOptimistic in interface GridProjectionR - Type of the closure return value.c - Closure to execute on unchanged topology.attempts - Number of re-execution attempts. Must be greater than zero.dfltVal - Default to return when number of attempts is exceeded.rollback - Optional rollback closure to execute in case when topology did indeed change during
closure execution. If not provided - the given closure will simply execute again.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
GridProjection.callOptimisticAsync(GridOutClosure, int, Object, GridAbsClosure, GridPredicate[])public GridFuture<Boolean> runOptimisticAsync(GridAbsClosure c, int attempts, @Nullable GridAbsClosure rollback, @Nullable GridPredicate<? super GridRichNode>... p)
Note that this method will not block until closure execution is complete (successfully or not). Note also that transactional semantic of this method is optimistic. No locking of grid topology is performed but the topology version is checked before and after the closure execution and compared to be the same.
Note also that if given closure or rollback closure throw runtime exception it will be propagated to the caller without any special handling. Specifically, a rollback closure won't be called if the executing closure throws runtime exception.
runOptimisticAsync in interface GridProjectionc - Closure to execute on unchanged topology.attempts - Number of re-execution attempts. Must be greater than zero.rollback - Optional rollback closure to execute in case when topology did indeed change during
closure execution. If not provided - the given closure will simply execute again.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
true if closure successfully executed on unchanged
topology, or false if number of attempts is exceeded.GridProjection.runOptimistic(GridAbsClosure, int, GridAbsClosure, GridPredicate[])public <R> GridFuture<R> callOptimisticAsync(GridOutClosure<R> c, int attempts, R dfltVal, @Nullable GridAbsClosure rollback, @Nullable GridPredicate<? super GridRichNode>... p)
Note that this method will not block until closure execution is complete (successfully or not). Note also that transactional semantic of this method is optimistic. No locking of grid topology is performed but the topology version is checked before and after the closure execution and compared to be the same.
Note also that if given closure or rollback closure throw runtime exception it will be propagated to the caller without any special handling. Specifically, a rollback closure won't be called if the executing closure throws runtime exception.
callOptimisticAsync in interface GridProjectionR - Type of the closure return value.c - Closure to execute on unchanged topology.attempts - Number of re-execution attempts. Must be greater than zero.dfltVal - Default to return when number of attempts is exceeded.rollback - Optional rollback closure to execute in case when topology did indeed change during
closure execution. If not provided - the given closure will simply execute again.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
GridProjection.callOptimistic(GridOutClosure, int, Object, GridAbsClosure, GridPredicate[])
public void affinityRun(String cacheName,
@Nullable
Collection<?> affKeys,
@Nullable
Runnable job,
@Nullable
GridPredicate<? super GridRichNode>... p)
throws GridException
jobs that will be mapped to nodes
with provided affinity keys.
This method will block until its execution is complete or an exception is thrown.
All default SPI implementations configured for this grid instance will be
used (i.e. failover, load balancing, collision resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
affinityRun in interface GridProjectionGridException - Thrown in case of any error.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException thrown if computation was cancelled.cacheName - Name of the cache to use for affinity co-location.affKeys - Collection of affinity keys. All dups will be ignored. If null or empty
this method is no-op.job - Closure to affinity co-located on the node with given affinity key and execute.
If null - this method is no-op.p - Optional set of filtering predicates. All predicates must evaluate to true for a
node to be included. If none provided - all nodes in this projection will be used for topology.GridProjection.affinityRunAsync(String, Collection, Runnable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String),
GridJobContext.cacheName(),
GridJobContext.affinityKey()public GridFuture<?> affinityRunAsync(String cacheName, @Nullable Collection<?> affKeys, @Nullable Runnable job, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
jobs that will be mapped to nodes
with provided affinity keys.
Unlike its sibling method GridProjection.affinityRun(String, Collection, Runnable, GridPredicate[]) this method does
not block and returns immediately with future. All default SPI implementations
configured for this grid instance will be used (i.e. failover, load balancing, collision resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Note that class GridAbsClosure implements Runnable and class GridOutClosure
implements Callable interface. Note also that class GridFunc and typedefs provide rich
APIs and functionality for closures and predicates based processing in GridGain. While Java interfaces
Runnable and Callable allow for lowest common denominator for APIs - it is advisable
to use richer Functional Programming support provided by GridGain available in org.gridgain.grid.lang
package.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
affinityRunAsync in interface GridProjectionGridException - Thrown in case of any error.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException thrown if computation was cancelled.cacheName - Name of the cache to use for affinity co-location.affKeys - Collection of affinity keys. All dups will be ignored. If null or
empty - this method is no-op.job - Closure to affinity co-located on the node with given affinity key and execute.
If null - this method is no-op.p - Optional set of filtering predicates. All predicates must evaluate to true for a
node to be included. If none provided - all nodes in this projection will be used for topology.
GridProjection.affinityRun(String, Object, Runnable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String),
GridJobContext.cacheName(),
GridJobContext.affinityKey()public <R> R affinityCall(String cacheName, @Nullable Object affKey, @Nullable Callable<R> job, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
This method will block until its execution is complete or an exception is thrown.
All default SPI implementations configured for this grid instance will be
used (i.e. failover, load balancing, collision resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
affinityCall in interface GridProjectionGridException - Thrown in case of any error.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException thrown if computation was cancelled.cacheName - Name of the cache to use for affinity co-location.affKey - Affinity key. If null - this method is no-op.job - Closure to affinity co-located on the node with given affinity key and execute.
If null or empty - this method is no-op.p - Optional set of filtering predicates. All predicates must evaluate to true for a
node to be included. If none provided - all nodes in this projection will be used for topology.
GridProjection.affinityRunAsync(String, Object, Runnable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String),
GridJobContext.cacheName(),
GridJobContext.affinityKey()public <R> Collection<R> affinityCall(String cacheName, @Nullable Collection<?> affKeys, @Nullable Callable<R> job, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
jobs that will be mapped to nodes
with provided affinity keys.
This method will block until its execution is complete or an exception is thrown.
All default SPI implementations configured for this grid instance will be
used (i.e. failover, load balancing, collision resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
affinityCall in interface GridProjectionGridException - Thrown in case of any error.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException thrown if computation was cancelled.cacheName - Name of the cache to use for affinity co-location.affKeys - Collection of affinity keys. All dups will be ignored. If null
or empty - this method is no-op.job - Closure to affinity co-located on the node with given affinity key and execute.
If null - this method is no-op.p - Optional set of filtering predicates. All predicates must evaluate to true for a
node to be included. If none provided - all nodes in this projection will be used for topology.
GridProjection.affinityRunAsync(String, Object, Runnable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String),
GridJobContext.cacheName(),
GridJobContext.affinityKey()public <R> GridFuture<R> affinityCallAsync(String cacheName, @Nullable Object affKey, @Nullable Callable<R> job, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
Unlike its sibling method GridProjection.affinityCall(String, Object, Callable, GridPredicate[]) this method does
not block and returns immediately with future. All default SPI implementations
configured for this grid instance will be used (i.e. failover, load balancing, collision resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
affinityCallAsync in interface GridProjectionGridException - Thrown in case of any error.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException thrown if computation was cancelled.cacheName - Name of the cache to use for affinity co-location.affKey - Affinity key. If null - this method is no-op.job - Closure to affinity co-located on the node with given affinity key and execute.
If null - this method is no-op.p - Optional set of filtering predicates. All predicates must evaluate to true for a
node to be included. If none provided - all nodes in this projection will be used for topology.
GridProjection.affinityRunAsync(String, Object, Runnable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String),
GridJobContext.cacheName(),
GridJobContext.affinityKey()public <R> GridFuture<Collection<R>> affinityCallAsync(String cacheName, @Nullable Collection<?> affKeys, @Nullable Callable<R> job, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
jobs that will be mapped to nodes
with provided affinity keys.
Unlike its sibling method GridProjection.affinityCall(String, Object, Callable, GridPredicate[]) this method does
not block and returns immediately with future. All default SPI implementations
configured for this grid instance will be used (i.e. failover, load balancing, collision resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
affinityCallAsync in interface GridProjectionGridException - Thrown in case of any error.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException throws if computation was cancelled.cacheName - Name of the cache to use for affinity co-location.affKeys - Collection of affinity keys. All dups will be ignored.
If null or empty - this method is no-op.job - Closure to affinity co-located on the node with given affinity key and execute.
If null - this method is no-op.p - Optional set of filtering predicates. All predicates must evaluate to true for a
node to be included. If none provided - all nodes in this projection will be used for topology.
GridProjection.affinityRunAsync(String, Object, Runnable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String),
GridJobContext.cacheName(),
GridJobContext.affinityKey()
public void affinityRun(String cacheName,
Object affKey,
@Nullable
Runnable job,
@Nullable
GridPredicate<? super GridRichNode>... p)
throws GridException
This method will block until its execution is complete or an exception is thrown.
All default SPI implementations configured for this grid instance will be
used (i.e. failover, load balancing, collision resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
affinityRun in interface GridProjectionGridException - Thrown in case of any error.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException thrown if computation was cancelled.cacheName - Name of the cache to use for affinity co-location.affKey - Affinity key. If null - this method is no-op.job - Closure to affinity co-located on the node with given affinity key and execute.
If null - this method is no-op.p - Optional set of filtering predicates. All predicates must evaluate to true for a
node to be included. If none provided - all nodes in this projection will be used for topology.GridProjection.affinityRunAsync(String, Object, Runnable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String),
GridJobContext.cacheName(),
GridJobContext.affinityKey()public GridFuture<?> affinityRunAsync(String cacheName, Object affKey, @Nullable Runnable job, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
Unlike its sibling method GridProjection.affinityRun(String, Object, Runnable, GridPredicate[]) this method does
not block and returns immediately with future. All default SPI implementations
configured for this grid instance will be used (i.e. failover, load balancing, collision resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Note that class GridAbsClosure implements Runnable and class GridOutClosure
implements Callable interface. Note also that class GridFunc and typedefs provide rich
APIs and functionality for closures and predicates based processing in GridGain. While Java interfaces
Runnable and Callable allow for lowest common denominator for APIs - it is advisable
to use richer Functional Programming support provided by GridGain available in org.gridgain.grid.lang
package.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
affinityRunAsync in interface GridProjectionGridException - Thrown in case of any error.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException thrown if computation was cancelled.cacheName - Name of the cache to use for affinity co-location.affKey - Affinity key. If null - this method is no-op.job - Closure to affinity co-located on the node with given affinity key and execute.
If null - this method is no-op.p - Optional set of filtering predicates. All predicates must evaluate to true for a
node to be included. If none provided - all nodes in this projection will be used for topology.
GridProjection.affinityRun(String, Object, Runnable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String),
GridJobContext.cacheName(),
GridJobContext.affinityKey()
public GridRichNode youngestx()
throws GridEmptyProjectionException
youngestx in interface GridProjectionGridEmptyProjectionException - Thrown in case when projection is empty.
GridProjection.youngest()
public GridRichNode oldestx()
throws GridEmptyProjectionException
oldestx in interface GridProjectionGridEmptyProjectionException - Thrown in case when projection is empty.
GridProjection.oldest()
public GridRichNode randomx()
throws GridEmptyProjectionException
randomx in interface GridProjectionGridEmptyProjectionException - Thrown in case when projection is empty.
GridProjection.random()public Collection<GridProjection> neighborhood()
Detection of the same physical computer (host) is based on comparing set of network interface MACs. If two nodes have the same set of MACs, GridGain considers these nodes running on the same physical computer. Note that this same logic is used in license management.
Knowing your neighbors can be very important when performing a dynamic split since nodes on the same computer will often bypass network when communicating with each other leading to much better performance for certain use cases. Conversely, one would like to avoid loading the nodes from the same physical computer with tasks as these nodes share CPU and memory between them resulting in reduced performance comparing to a no-neighboring split.
neighborhood in interface GridProjectionGridRichNode.neighbors(),
GridRichNode.neighborsAndMe()public boolean hasRemoteNodes()
hasRemoteNodes in interface GridProjectionTrue if this projection does not have any remote nodes in it at the moment
of call, false otherwise.public Collection<GridRichNode> nodeId8(String id8)
nodeId8 in interface GridProjectionid8 - node ID8.
public boolean hasLocalNode()
hasLocalNode in interface GridProjectionTrue if this projection does not have local node in it at the moment
of call, false otherwise.public GridRichNode youngest()
youngest in interface GridProjectionnull if projection is
empty.GridProjection.youngestx()public GridRichNode oldest()
oldest in interface GridProjectionnull if
projection is empty.GridProjection.oldestx()public int hosts()
Detection of the same physical computer (host) is based on comparing set of network interface MACs. If two nodes have the same set of MACs, GridGain considers these nodes running on the same physical computer. Note that this same logic is used in license management.
hosts in interface GridProjectionpublic int cpus()
cpus in interface GridProjectionpublic boolean isRestartEnabled()
bin/ggstart.{sh|bat} script using -r argument. Node can be
programmatically restarted using GridFactory.restart(boolean, boolean)} method.
isRestartEnabled in interface GridTrue if restart mode is enabled, false otherwise.GridFactory.restart(boolean, boolean)public GridEnterpriseLicense license()
license in interface Gridnull when running on Community Edition.public boolean isJmxRemoteEnabled()
com.sun.management.jmxremote
isJmxRemoteEnabled in interface GridTrue if remote JMX management is enabled - false otherwise.public boolean isSmtpEnabled()
GridConfiguration.getSmtpHost().
If SMTP is not configured all emails notifications will be disabled.
isSmtpEnabled in interface GridTrue if SMTP is configured - false otherwise.GridConfiguration.getSmtpFromEmail(),
GridConfiguration.getSmtpHost(),
GridConfiguration.getSmtpPassword(),
GridConfiguration.getSmtpPort(),
GridConfiguration.getSmtpUsername(),
GridConfiguration.isSmtpSsl(),
GridConfiguration.isSmtpStartTls(),
Grid.sendAdminEmailAsync(String, String, boolean)public GridFuture<Boolean> sendAdminEmailAsync(String subj, String body, boolean html)
Note that this method returns immediately with the future and all emails will be sent asynchronously in a different thread. If email queue is full or sending has failed - the email will be lost. Email queue can fill up if rate of scheduling emails is greater than the rate of SMTP sending.
Implementation is not performing any throttling and it is responsibility of the caller to properly throttle the emails, if necessary.
Note that this feature only available in Enterprise Edition.
sendAdminEmailAsync in interface Gridsubj - Subject of the email.body - Body of the email.html - If true the email body will have MIME html subtype.
true email was successfully sent. In all
other cases - sending process has failed.Grid.isSmtpEnabled(),
Grid.sendAdminEmail(String, String, boolean),
GridConfiguration.getAdminEmails()
public void sendAdminEmail(String subj,
String body,
boolean html)
throws GridException
Note that this method will return only if email is successfully sent. In case of sending failure it will throw exception. This method will block until either email is successfully sent or exception is thrown due to failure.
Implementation is not performing any throttling and it is responsibility of the caller to properly throttle the emails, if necessary.
Note that this feature only available in Enterprise Edition.
sendAdminEmail in interface GridGridException - Thrown in case when sending has failed.subj - Subject of the email.body - Body of the email.html - If true the email body will have MIME html subtype.Grid.isSmtpEnabled(),
Grid.sendAdminEmailAsync(String, String, boolean),
GridConfiguration.getAdminEmails()public <T> GridOutClosure<GridFuture<T>> gridify(GridClosureCallMode mode, Callable<T> c, @Nullable GridPredicate<? super GridRichNode>... p)
This method effectively allows to convert "local" closure into a distributed one that will take the same parameters (if any), execute "somewhere" on this projection, and produce the same result but via future.
gridify in interface GridProjectionT - Type of the return value.mode - Closure call mode with to curry given closure.c - Closure to convert.p - Optional set of filtering predicates. If none provided - all nodes from this
projection will be candidates for load balancing.
public GridOutClosure<GridFuture<?>> gridify(GridClosureCallMode mode, Runnable r, @Nullable GridPredicate<? super GridRichNode>... p)
This method effectively allows to convert "local" closure into a distributed one that will take the same parameters (if any), execute "somewhere" on this projection, and produce the same result but via future.
gridify in interface GridProjectionmode - Closure call mode with to curry given closure.r - Closure to convert.p - Optional set of filtering predicates. If none provided - all nodes from this
projection will be candidates for load balancing.
public <E,T> GridClosure<E,GridFuture<T>> gridify(GridClosureCallMode mode, GridClosure<E,T> c, @Nullable GridPredicate<? super GridRichNode>... p)
This method effectively allows to convert "local" closure into a distributed one that will take the same parameters (if any), execute "somewhere" on this projection, and produce the same result but via future.
gridify in interface GridProjectionE - Type of the free variable.T - Type of the return value.mode - Closure call mode with to curry given closure.c - Closure to convert.p - Optional set of filtering predicates. If none provided - all nodes from this
projection will be candidates for load balancing.
public <E1,E2,T> GridClosure2<E1,E2,GridFuture<T>> gridify(GridClosureCallMode mode, GridClosure2<E1,E2,T> c, @Nullable GridPredicate<? super GridRichNode>... p)
This method effectively allows to convert "local" closure into a distributed one that will take the same parameters (if any), execute "somewhere" on this projection, and produce the same result but via future.
gridify in interface GridProjectionE1 - Type of the first free variable.E2 - Type of the second free variable.T - Type of the return value.mode - Closure call mode with to curry given closure.c - Closure to convert.p - Optional set of filtering predicates. If none provided - all nodes from this
projection will be candidates for load balancing.
public <E1,E2,E3,T> GridClosure3<E1,E2,E3,GridFuture<T>> gridify(GridClosureCallMode mode, GridClosure3<E1,E2,E3,T> c, @Nullable GridPredicate<? super GridRichNode>... p)
This method effectively allows to convert "local" closure into a distributed one that will take the same parameters (if any), execute "somewhere" on this projection, and produce the same result but via future.
gridify in interface GridProjectionE1 - Type of the first free variable.E2 - Type of the second free variable.E3 - Type of the third free variable.T - Type of the return value.mode - Closure call mode with to curry given closure.c - Closure to convert.p - Optional set of filtering predicates. If none provided - all nodes from this
projection will be candidates for load balancing.
public <E> GridClosure<E,GridFuture<?>> gridify(GridClosureCallMode mode, GridInClosure<E> c, @Nullable GridPredicate<? super GridRichNode>... p)
This method effectively allows to convert "local" closure into a distributed one that will take the same parameters (if any), execute "somewhere" on this projection, and produce the same result but via future.
gridify in interface GridProjectionE - Type of the free variable.mode - Closure call mode with to curry given closure.c - Closure to convert.p - Optional set of filtering predicates. If none provided - all nodes from this
projection will be candidates for load balancing.
public <E1,E2> GridClosure2<E1,E2,GridFuture<?>> gridify(GridClosureCallMode mode, GridInClosure2<E1,E2> c, @Nullable GridPredicate<? super GridRichNode>... p)
This method effectively allows to convert "local" closure into a distributed one that will take the same parameters (if any), execute "somewhere" on this projection, and produce the same result but via future.
gridify in interface GridProjectionE1 - Type of the first free variable.E2 - Type of the second free variable.mode - Closure call mode with to curry given closure.c - Closure to convert.p - Optional set of filtering predicates. If none provided - all nodes from this
projection will be candidates for load balancing.
public <E1,E2,E3> GridClosure3<E1,E2,E3,GridFuture<?>> gridify(GridClosureCallMode mode, GridInClosure3<E1,E2,E3> c, @Nullable GridPredicate<? super GridRichNode>... p)
This method effectively allows to convert "local" closure into a distributed one that will take the same parameters (if any), execute "somewhere" on this projection, and produce the same result but via future.
gridify in interface GridProjectionE1 - Type of the first free variable.E2 - Type of the second free variable.E3 - Type of the third free variable.mode - Closure call mode with to curry given closure.c - Closure to convert.p - Optional set of filtering predicates. If none provided - all nodes from this
projection will be candidates for load balancing.
public GridOutClosure<GridFuture<Boolean>> gridify(GridClosureCallMode mode, GridAbsPredicate c, @Nullable GridPredicate<? super GridRichNode>... p)
This method effectively allows to convert "local" predicate into a distributed one that will take the same parameters (if any), execute "somewhere" on this projection, and produce the same result but via future.
gridify in interface GridProjectionmode - Closure call mode with to curry given closure.c - Predicate to convert.p - Optional set of filtering predicates. If none provided - all nodes from this
projection will be candidates for load balancing.
public <E> GridClosure<E,GridFuture<Boolean>> gridify(GridClosureCallMode mode, GridPredicate<E> c, @Nullable GridPredicate<? super GridRichNode>... p)
This method effectively allows to convert "local" predicate into a distributed one that will take the same parameters (if any), execute "somewhere" on this projection, and produce the same result but via future.
gridify in interface GridProjectionE - Type of the free variable.mode - Closure call mode with to curry given closure.c - Predicate to convert.p - Optional set of filtering predicates. If none provided - all nodes from this
projection will be candidates for load balancing.
public <E1,E2> GridClosure2<E1,E2,GridFuture<Boolean>> gridify(GridClosureCallMode mode, GridPredicate2<E1,E2> c, @Nullable GridPredicate<? super GridRichNode>... p)
This method effectively allows to convert "local" predicate into a distributed one that will take the same parameters (if any), execute "somewhere" on this projection, and produce the same result but via future.
gridify in interface GridProjectionE1 - Type of the first free variable.E2 - Type of the second free variable.mode - Closure call mode with to curry given closure.c - Predicate to convert.p - Optional set of filtering predicates. If none provided - all nodes from this
projection will be candidates for load balancing.
public <E1,E2,E3> GridClosure3<E1,E2,E3,GridFuture<Boolean>> gridify(GridClosureCallMode mode, GridPredicate3<E1,E2,E3> c, @Nullable GridPredicate<? super GridRichNode>... p)
This method effectively allows to convert "local" predicate into a distributed one that will take the same parameters (if any), execute "somewhere" on this projection, and produce the same result but via future.
gridify in interface GridProjectionE1 - Type of the first free variable.E2 - Type of the second free variable.E3 - Type of the third free variable.mode - Closure call mode with to curry given closure.c - Predicate to convert.p - Optional set of filtering predicates. If none provided - all nodes from this
projection will be candidates for load balancing.
public boolean dynamic()
Dynamic projection is based on predicate and in any particular moment of time can consist of a different set of nodes. Static project does not change and always consist of the same set of nodes (excluding the node that have left the topology since the creation of the static projection).
dynamic in interface GridProjection
public GridProjection projectionForNodes(@Nullable
Collection<? extends GridNode> nodes)
projectionForNodes in interface GridProjectionnodes - Collection of nodes to create a projection from.
public GridProjection projectionForNodes(@Nullable
GridRichNode... nodes)
projectionForNodes in interface GridProjectionnodes - Collection of nodes to create a projection from.
public Collection<GridRichNode> nodes(@Nullable Collection<UUID> ids)
Nodes are returned in the same order as passed in IDs.
nodes in interface GridProjectionids - Collection of node IDs. If none provides - empty collection will be returned.
public GridProjection cross(@Nullable
GridProjection... prjs)
cross in interface GridProjectionprjs - Other projections. If none provided - this projection is returned.
public GridEvent waitForEvent(long timeout,
@Nullable
Runnable c,
@Nullable
GridPredicate<? super GridEvent> p,
@Nullable
int... types)
throws GridException
This is one of the two similar methods providing different semantic for waiting for events. One method (this one) uses passed in optional continuation so that caller can pass a logic that emits the event, and another method returns future allowing caller a more discrete control.
This method returns when either event of specified type has been generated and passed the optional predicate, if any, or the timeout has elapsed. Note that some local events are generated in response to the actions on remote nodes.
This method encapsulates an important paradigm as many operations in GridGain cause local events to be generated even for the operations that may happen on the remote nodes. This method provides convenient one-stop blocking and waiting functionality for such cases.
waitForEvent in interface GridGridException - Thrown only when continuation throws any exception.timeout - Timeout in milliseconds. If timeout value is less than or equal to zero, the
method will not wait at all and will return immediately.c - Optional continuation. If specified it will ba called right after the event listener
is registered but before the wait countdown started. This parameter is important when
you need to avoid a window between execution of an operation that can cause the event
and settings the event listener. Passing this operation as continuation into this method
allows to avoid this window.p - Optional filtering predicate. Only if predicates evaluates to true will the event
end the wait. Note that events of provided types only will be fed to the predicate.types - Types of the events to wait for.
null if the call got timed out.Grid.waitForEventAsync(GridPredicate, int...)public GridFuture<GridEvent> waitForEventAsync(@Nullable GridPredicate<? super GridEvent> p, @Nullable int... types)
This is one of the two similar methods providing different semantic for waiting for events. One method uses passed in optional continuation so that caller can pass a logic that emits the event, and another method (this one) returns future allowing caller a more discrete control.
This method returns a future which by calling one of its get methods will block
and wait for the specified event (either indefinitely or with provided timeout). Note that
you need to call this method to acquire the future before emitting the event itself. This
way you can avoid the window when event is emitted but no listener is set for it.
This method encapsulates an important paradigm as many operations in GridGain cause local events to be generated even for the operations that may happen on the remote nodes. This method provides convenient one-stop blocking and waiting functionality for such cases.
waitForEventAsync in interface Gridp - Optional filtering predicate. Only if predicates evaluates to true will the event
end the wait. Note that events of provided types only will be fed to the predicate.types - Types of the events to wait for.
Grid.waitForEvent(long, Runnable, GridPredicate, int...)public GridRichNode rich(GridNode node)
Note that in most cases end user should not have to use this method as most of the APIs returning rich nodes already. This functionality exists for easier migration from previous versions as well as for internal purposes.
Note also that GridGain caches rich instances internal and for same thin node it will always return the same rich node.
rich in interface Gridnode - Thin node to wrap.
public GridProjection merge(@Nullable
GridProjection... prjs)
merge in interface GridProjectionprjs - Optional set of projections to merge with. If non provided - this
projection is returned.
public long topologyHash(Iterable<? extends GridNode> nodes)
Note that since GridGain topology architecture is peer-to-peer (without centralized coordination) there is still a small window in which different nodes would have different version for the same topology. Therefore, this version cannot be used in strict ACID context. Values returned by this method are not guaranteed to be sequential. Standard implementation uses CRC32 hash method.
topologyHash in interface Gridnodes - Collection of grid nodes. Note that this can be either full topology or
any subset of it.
public void addLocalEventListener(GridLocalEventListener lsnr,
int[] types)
Note that by default all events in GridGain are enabled and therefore generated and stored by whatever event storage SPI is configured. GridGain can and often does generate thousands events per seconds under the load and therefore it creates a significant additional load on the system. If these events are not needed by the application this load is unnecessary and leads to significant performance degradation.
It is highly recommended to enable only those events that your application logic requires
by using either GridConfiguration.getExcludeEventTypes() or
GridConfiguration.getIncludeEventTypes() methods in GridGain configuration. Note that certain
events are required for GridGain's internal operations and such events will still be generated but not stored by
event storage SPI if they are disabled in GridGain configuration.
Note also that since event types are defined as integer the unknown (invalid) event types cannot be detected and therefore will be ignored (because there is no way to know which user-defined types are used).
addLocalEventListener in interface Gridlsnr - Event listener for local events to add.types - Event types for which this listener will be notified. If this array is empty an exception
will be thrown.
NOTE: subscribing to large set of events will impose significant performance penalty.
GridEvent,
GridEventType,
Grid.addLocalEventListener(GridLocalEventListener, int, int...)
public void addLocalEventListener(GridLocalEventListener lsnr,
int type,
@Nullable
int... types)
Note that by default all events in GridGain are enabled and therefore generated and stored by whatever event storage SPI is configured. GridGain can and often does generate thousands events per seconds under the load and therefore it creates a significant additional load on the system. If these events are not needed by the application this load is unnecessary and leads to significant performance degradation.
It is highly recommended to enable only those events that your application logic requires
by using either GridConfiguration.getExcludeEventTypes() or
GridConfiguration.getIncludeEventTypes() methods in GridGain configuration. Note that certain
events are required for GridGain's internal operations and such events will still be generated but not stored by
event storage SPI if they are disabled in GridGain configuration.
Note that unlike its sibling method this method never throws an exception because its signature guarantees that there is at least one event type to subscribe for.
Note also that since event types are defined as integer the unknown (invalid) event types cannot be detected and therefore will be ignored (because there is no way to know which user-defined types are used).
addLocalEventListener in interface Gridlsnr - Event listener for local events to add.type - Event type for which this listener will be notified.types - Optional event types for which this listener will be notified.GridEvent,
GridEventType,
Grid.addLocalEventListener(GridLocalEventListener, int[])public <T> GridFuture<?> remoteListenAsync(@Nullable GridNode node, @Nullable GridPredicate2<UUID,? super T>... p)
node. Messages can be sent using one of the following
methods:
Essentially, this method allows to "wire up" sender and receiver(s) of the messages in a
completely distributed manner. Note that this method will take a current snapshot of nodes in
this projection which is an important consideration for dynamic projection that can have a
constantly changing set of nodes.
remoteListenAsync in interface GridProjectionT - Type of the message.node - Node to listen for message from. If null this method is no-op.p - Collection of predicates that are called on each received message. If all predicates
return true - the implementation will continue listen for the new messages. If any
predicate returns false - the implementation will unregister the listener and stop
receiving messages.
If none provided - this method is no-op.
GridListenActor,
GridProjection.listen(GridPredicate2[]),
GridProjection.remoteListenAsync(GridPredicate, GridPredicate2[]),
GridProjection.send(Object, GridPredicate[]),
GridProjection.send(Collection, GridPredicate[])public <T> GridFuture<?> remoteListenAsync(@Nullable Collection<? extends GridNode> nodes, @Nullable GridPredicate2<UUID,? super T>... p)
nodes. Messages can be sent using one of the following
methods:
Essentially, this method allows to "wire up" senders and receiver(s) of the messages in a
completely distributed manner. Note that this method will take a current snapshot of nodes in
this projection which is an important consideration for dynamic projection that can have a
constantly changing set of nodes.
remoteListenAsync in interface GridProjectionT - Type of the message.nodes - Nodes to listen for message from. If null or empty
this method is no-op.p - Collection of predicates that is called on each received message. If all predicates
return true - the implementation will continue listen for the new messages. If any
predicate returns false - the implementation will unregister the listener and stop
receiving messages.
If none provided - this method is no-op.
GridListenActor,
GridProjection.listen(GridPredicate2[]),
GridProjection.remoteListenAsync(GridPredicate, GridPredicate2[])public <T> GridFuture<?> remoteListenAsync(@Nullable GridPredicate<? super GridRichNode> pn, @Nullable GridPredicate2<UUID,? super T>... p)
remoteListenAsync in interface GridProjectionT - Type of the message.pn - Predicate to define nodes on each node from this projection to listen for messages
from. If not provided - this method is no-op.p - Collection of predicates that is called on each received message. If all predicates
return true - the implementation will continue listen for the new messages. If any
predicate returns false - the implementation will unregister the listener and stop
receiving messages.
If none provided - this method is no-op.
GridListenActor,
GridProjection.listen(GridPredicate2[]),
GridProjection.remoteListenAsync(Collection, GridPredicate2[])
public boolean removeLocalEventListener(GridLocalEventListener lsnr,
@Nullable
int... types)
removeLocalEventListener in interface Gridlsnr - Local event listener to remove.types - Types of events for which to remove listener. If not specified,
then listener will be removed for all types it was registered for.
true if listener was removed, false otherwise.GridEventType,
GridEvent
public void addMessageListener(GridMessageListener lsnr,
@Nullable
GridPredicate<Object>... p)
GridProjection.listen(GridPredicate2[]) method for more convenient
message listening API.
addMessageListener in interface Gridlsnr - Message listener to register.p - Message filter predicates. If none is provided - every message received will be
delivered to registered listener.GridProjection.listen(GridPredicate2[]),
GridProjection.send(Collection, GridPredicate[]),
GridProjection.send(Object, GridPredicate[]),
Grid.removeMessageListener(GridMessageListener)public boolean removeMessageListener(GridMessageListener lsnr)
GridProjection.listen(GridPredicate2[]) method
for more convenient message listening API.
removeMessageListener in interface Gridlsnr - Message listener to remove.
true of message listener was removed, false if it was not
previously registered.GridProjection.listen(GridPredicate2[]),
Grid.addMessageListener(GridMessageListener, GridPredicate[]),
GridProjection.send(Collection, GridPredicate[]),
GridProjection.send(Object, GridPredicate[])public GridRichNode localNode()
localNode in interface Gridpublic GridFuture<?> runLocal(@Nullable Runnable r) throws GridException
Note that class GridAbsClosure implements Runnable and class GridOutClosure
implements Callable interface. Note also that class GridFunc and typedefs provide rich
APIs and functionality for closures and predicates based processing in GridGain. While Java interfaces
Runnable and Callable allow for lowest common denominator for APIs - it is advisable
to use richer Functional Programming support provided by GridGain available in org.gridgain.grid.lang
package.
runLocal in interface GridGridException - Thrown in case of rejected execution by internal system thread pool.r - Runnable to execute. If null - this method is no-op.
Grid.callLocal(Callable),
GridAbsClosurepublic <R> GridFuture<R> callLocal(@Nullable Callable<R> c) throws GridException
Note that class GridAbsClosure implements Runnable and class GridOutClosure
implements Callable interface. Note also that class GridFunc and typedefs provide rich
APIs and functionality for closures and predicates based processing in GridGain. While Java interfaces
Runnable and Callable allow for lowest common denominator for APIs - it is advisable
to use richer Functional Programming support provided by GridGain available in org.gridgain.grid.lang
package.
callLocal in interface GridGridException - Thrown in case of rejected execution by internal system thread pool.R - Type of the return value for the closure.c - Callable to execute. If null - this method is no-op.
Grid.runLocal(Runnable),
GridOutClosurepublic <R> GridScheduleFuture<R> scheduleLocal(@Nullable Callable<R> r, String pattern) throws GridException
Here's an example of scheduling a closure that broadcasts a message to all nodes five times, once every minute, with initial delay in two seconds:
G.grid().scheduleLocal(
new CO() { // CO is a type alias for GridOutClosure.
@Override public String apply() {
try {
g.run(BROADCAST, F.println("Hello Node! :)");
return "OK";
}
catch (GridException e) {
throw new GridClosureException(e);
}
}
}, "{2, 5} * * * * *" // 2 seconds delay with 5 executions only.
);
Note that class GridAbsClosure implements Runnable and class GridOutClosure
implements Callable interface. Note also that class GridFunc and typedefs provide rich
APIs and functionality for closures and predicates based processing in GridGain. While Java interfaces
Runnable and Callable allow for lowest common denominator for APIs - it is advisable
to use richer Functional Programming support provided by GridGain available in org.gridgain.grid.lang
package.
scheduleLocal in interface GridGridException - Thrown in case of any errors.r - Closure to schedule to run as a background cron-based job.
If null - this method is no-op.pattern - Scheduling pattern in UNIX cron format with optional prefix {n1, n2}
where n1 is delay of scheduling in seconds and n2 is the number of execution. Both
parameters are optional.
public GridScheduleFuture<?> scheduleLocal(@Nullable Runnable r, String pattern) throws GridException
Here's an example of scheduling a closure that broadcasts a message to all nodes five times, once every minute, with initial delay in two seconds:
G.grid().scheduleLocal(
new CA() { // CA is a type alias for GridAbsClosure.
@Override public void apply() {
try {
g.run(BROADCAST, F.println("Hello Node! :)");
}
catch (GridException e) {
throw new GridClosureException(e);
}
}
}, "{2, 5} * * * * *" // 2 seconds delay with 5 executions only.
);
Note that class GridAbsClosure implements Runnable and class GridOutClosure
implements Callable interface. Note also that class GridFunc and typedefs provide rich
APIs and functionality for closures and predicates based processing in GridGain. While Java interfaces
Runnable and Callable allow for lowest common denominator for APIs - it is advisable
to use richer Functional Programming support provided by GridGain available in org.gridgain.grid.lang
package.
scheduleLocal in interface GridGridException - Thrown in case of any errors.r - Closure to schedule to run as a background cron-based job.
If null - this method is no-op.pattern - Scheduling pattern in UNIX cron format with optional prefix {n1, n2}
where n1 is delay of scheduling in seconds and n2 is the number of execution. Both
parameters are optional.
public <K,V> GridNodeLocal<K,V> nodeLocal()
Node-local values are similar to thread locals in a way that these values are not distributed and kept only on local node (similar like thread local values are attached to the current thread only). Node-local values are used primarily by closures executed from the remote nodes to keep intermediate state on the local node between executions.
There's only one instance of node local storage per local node. Node local storage is
based on ConcurrentMap and is safe for multi-threaded access.
nodeLocal in interface Gridpublic boolean pingNode(UUID nodeId)
Discovery SPIs usually have some latency in discovering failed nodes. Hence, communication to remote nodes may fail at times if an attempt was made to establish communication with a failed node. This method can be used to check if communication has failed due to node failure or due to some other reason.
pingNode in interface GridnodeId - ID of a node to ping.
true if node for a given ID is alive, false otherwise.GridDiscoverySpipublic void deployTask(Class<? extends GridTask> taskCls) throws GridException
GridConfiguration.isPeerClassLoadingEnabled()), then other nodes
will automatically deploy task upon execution request from the originating node without
having to manually deploy it.
Another way of class deployment which is supported is deployment from local class path. Class from local class path has a priority over P2P deployed. Following describes task class deployment:
GridConfiguration.isPeerClassLoadingEnabled())
GridConfiguration.getPeerClassLoadingClassPathExclude()).GridConfiguration.isPeerClassLoadingEnabled())
Note that this is an alternative deployment method additionally to deployment SPI that
provides more formal method of deploying a task, e.g. deployment of GAR files and/or URI-based
deployment. See GridDeploymentSpi for detailed information about grid task deployment.
Note that class can be deployed multiple times on remote nodes, i.e. re-deployed. GridGain 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 (latest that is on the node where execution request is originated). This allows a very convenient development model when a developer can execute a task on the grid from IDE, then realize that he made a mistake, stop his node in IDE, fix mistake and re-execute the task. Grid will automatically detect that task got renewed and redeploy it on all remote nodes upon execution.
This method has no effect if the class passed in was already deployed. Implementation checks for this condition and returns immediately.
deployTask in interface GridGridException - If task is invalid and cannot be deployed.taskCls - Task class to deploy. If task class has GridTaskName annotation,
then task will be deployed under a name specified within annotation. Otherwise, full
class name will be used as task's name.GridDeploymentSpipublic void deployTask(Class<? extends GridTask> taskCls, ClassLoader clsLdr) throws GridException
GridConfiguration.isPeerClassLoadingEnabled()), then other nodes
will automatically deploy task upon execution request from the originating node without
having to manually deploy it.
Another way of class deployment which is supported is deployment from local class path. Class from local class path has a priority over P2P deployed. Following describes task class deployment:
GridConfiguration.isPeerClassLoadingEnabled())
GridConfiguration.getPeerClassLoadingClassPathExclude()).GridConfiguration.isPeerClassLoadingEnabled())
Note that this is an alternative deployment method additionally to deployment SPI that
provides more formal method of deploying a task, e.g. deployment of GAR files and/or URI-based
deployment. See GridDeploymentSpi for detailed information about grid task deployment.
Note that class can be deployed multiple times on remote nodes, i.e. re-deployed. GridGain 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 (latest that is on the node where execution request is originated). This allows a very convenient development model when a developer can execute a task on the grid from IDE, then realize that he made a mistake, stop his node in IDE, fix mistake and re-execute the task. Grid will automatically detect that task got renewed and redeploy it on all remote nodes upon execution.
This method has no effect if the class passed in was already deployed. Implementation checks for this condition and returns immediately.
deployTask in interface GridGridException - If task is invalid and cannot be deployed.taskCls - Task class to deploy. If task class has GridTaskName annotation,
then task will be deployed under a name specified within annotation. Otherwise, full
class name will be used as task's name.clsLdr - Task resources/classes class loader. This class loader is in charge
of loading all necessary resources.GridDeploymentSpipublic Map<String,Class<? extends GridTask<?,?>>> localTasks(@Nullable GridPredicate<? super Class<? extends GridTask<?,?>>>... p)
localTasks in interface Gridp - Set of filtering predicates. If no predicates provided - all
locally deployed tasks, if any, will be returned.
public void undeployTask(String taskName)
throws GridException
Note that GridGain maintains internal versions for grid tasks in case of redeployment. This method will attempt to undeploy all versions on the grid task with given name.
undeployTask in interface GridGridException - Thrown if undeploy failed.taskName - Name of the task to undeploy. If task class has GridTaskName annotation,
then task was deployed under a name specified within annotation. Otherwise, full
class name should be used as task's name.public Collection<GridEvent> localEvents(@Nullable GridPredicate<? super GridEvent>... p)
localEvents in interface Gridp - Mandatory predicates to filter events. All predicates must be satisfied for the
event to be returned.
Note: unlike other methods in GridGain APIs if no predicates is provided this method will return no results. This exception is made to avoid situation when all local events are erroneously returned. Returning all local events may result in creating collection with tens of thousands elements seriously compromising the system's performance.
PEpublic void recordLocalEvent(GridEvent evt)
GridProjection.remoteEvents(GridPredicate, long, GridPredicate[]) method.
recordLocalEvent in interface Gridevt - Locally generated event.public String name()
If default grid instance is used, then
null is returned. Refer to GridFactory documentation
for information on how to start named grids.
name in interface Gridnull for default grid.public <K,V> GridCache<K,V> cache(String name)
cache in interface GridK - Key type.V - Value type.name - Cache name.
public <K,V> GridCache<K,V> cache()
GridCacheProjection.name() method on default instance returns null.
cache in interface GridK - Key type.V - Value type.
public Collection<GridCache<?,?>> caches(@Nullable GridPredicate<? super GridCache<?,?>>... p)
caches in interface Gridp - Predicates. If none provided - all configured caches will be returned.
public void writeToSwap(@Nullable
String space,
Object key,
@Nullable
Object val,
@Nullable
ClassLoader ldr)
throws GridException
writeToSwap in interface GridGridException - Thrown in case of any errors.space - Optional swap space name. If null is passed - global swap space will be used.key - Data key.val - Data value.ldr - Class loader (optional).public <T> T readFromSwap(@Nullable String space, Object key, @Nullable ClassLoader ldr) throws GridException
Grid.writeToSwap(String, Object, Object, ClassLoader) method.
readFromSwap in interface GridGridException - Thrown in case of any errors.space - Optional swap space name. If null is passed - global swap space will be used.key - Data key.ldr - Class loader (optional).
null if no data was stored.
public void removeFromSwap(@Nullable
String space,
Object key,
@Nullable
GridInClosure<Object> c,
@Nullable
ClassLoader ldr)
throws GridException
Grid.writeToSwap(String, Object, Object, ClassLoader) method.
removeFromSwap in interface GridGridException - Thrown in case of any errors.space - Optional swap space name. If null is passed - global
swap space will be used.key - Data key.c - Optional closure that takes removed value and executes after actual
removing. If there was no value in storage the closure is not executed.ldr - Class loader (optional).
public void clearSwapSpace(@Nullable
String space)
throws GridException
clearSwapSpace in interface GridGridException - Thrown in case of any errors.space - Optional swap space name. If null is passed - global swap space will be used.public <T,R> R executeSync(GridTask<T,R> task, @Nullable T arg, long timeout, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
GridProjection.execute(Class, Object, GridPredicate[]) this method
executes given task synchronously. This method will block until execution
is complete, timeout expires or exception is thrown.
Note: this method will limit set of nodes to only those that are in this projection at the time of the call. If this projection is changing its node set dynamically, the set of nodes available for the task execution will also change dynamically from call to call.
When using this method task will be deployed automatically, so no explicit deployment step is required.
executeSync in interface GridProjectionGridTaskTimeoutException - If task execution has timed out. Note that
physically task may still be executing, as there is no practical way to stop
it (however, every job within task will receive interrupt apply).
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridException - If task execution resulted in exception.T - Type of the task's argument.R - Type of the task result returning from GridTask.reduce(List)
method.task - Instance of task to execute. If task class has GridTaskName
annotation, then task is deployed under a name specified within annotation.
Otherwise, full class name is used as task's name.arg - Optional argument of task execution, can be null.timeout - Optional timeout for this task execution in milliseconds.
If 0 the system will wait indefinitely for execution completion.p - Optional set of filtering predicates. If none provided - all nodes in
this projection will be used for task topology.
GridProjection.execute(Class, Object, GridPredicate[]),
GridProjection.execute(Class, Object, long, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withTopologySpi(String)public <T,R> R executeSync(Class<? extends GridTask<T,R>> taskCls, @Nullable T arg, long timeout, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
GridProjection.execute(Class, Object, GridPredicate[]) this method executes given
task synchronously. This method will block until execution is complete, timeout expires or
exception is thrown.
Note: this method will limit set of nodes to only those that are in this projection at the time of the call. If this projection is changing its node set dynamically, the set of nodes available for the task execution will also change dynamically from call to call.
When using this method task will be deployed automatically, so no explicit deployment step is required.
executeSync in interface GridProjectionGridTaskTimeoutException - If task execution has timed out. Note that physically
task may still be executing, as there is no practical way to stop it (however,
every job within task will receive interrupt apply).
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridException - If task execution resulted in exception.T - Type of the task's argument.R - Type of the task result returning from GridTask.reduce(List) method.taskCls - Class of the task to execute. If class has GridTaskName annotation,
then task is deployed under a name specified within annotation. Otherwise, full
class name is used as task's name.arg - Optional argument of task execution, can be null.timeout - Optional timeout for this task execution in milliseconds.
If 0 the system will wait indefinitely for execution completion.p - Optional set of filtering predicates. If none provided - all nodes in this projection
will be used for task topology.
GridProjection.execute(Class, Object, GridPredicate[]),
GridProjection.execute(Class, Object, long, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withTopologySpi(String)public <T,R> R executeSync(String taskName, @Nullable T arg, long timeout, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
GridProjection.execute(String, Object, GridPredicate[]) this method executes given task synchronously.
This method will block until execution is complete, timeout expires or exception is thrown.
Note: this method will limit set of nodes to only those that are in this projection at the time of the call. If this projection is changing its node set dynamically, the set of nodes available for the task execution will also change dynamically from call to call.
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 Grid#deployTask() method
for deployment algorithm).
executeSync in interface GridProjectionGridTaskTimeoutException - If task execution has timed out. Note that physically
task may still be executing, as there is no practical way to stop it (however,
every job within task will receive interrupt apply).
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridException - If task execution resulted in exception.T - Type of the task's argument.R - Type of the task result returning from GridTask.reduce(List) method.taskName - Name of the task to execute. If task class has GridTaskName annotation,
then task is deployed under a name specified within annotation. Otherwise, full
class name is used as task's name.arg - Optional argument of task execution, can be null.timeout - Optional timeout for this task execution in milliseconds.
If 0 the system will wait indefinitely for execution completion.p - Optional set of filtering predicates. If none provided - all nodes in this projection
will be used for task topology.
GridProjection.execute(String, Object, GridPredicate[]),
GridProjection.execute(String, Object, long, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withTopologySpi(String)public <T,R> GridTaskFuture<R> execute(String taskName, @Nullable T arg, @Nullable GridPredicate<? super GridRichNode>... p)
GridTask documentation.
This method assumes indefinite wait for task completion. To provide a timeout, use
GridProjection.execute(String, Object, long, GridPredicate[]) method. It is always recommended
to specify explicit task timeout.
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 Grid#deployTask() method
for deployment algorithm).
Note that if projection is empty after applying filtering predicates, the result future will finish with exception. In case of dynamic projection this method will take a snapshot of all nodes in the projection, apply all filtering predicates, if any, and if the resulting set of nodes is empty the returned future will finish with exception.
execute in interface GridProjectionT - Type of the task's argument.R - Type of the task result returning from GridTask.reduce(List) method.taskName - Name of the task to execute. If task class has GridTaskName annotation,
then task is deployed under a name specified within annotation. Otherwise, full
class name is used as task's name.arg - Optional argument of task execution, can be null.p - Optional set of filtering predicates. If none provided - all nodes in this projection
will be used for task topology.
for information about task execution.,
GridProjection.executeSync(String, Object, long, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withTopologySpi(String)public <T,R> GridTaskFuture<R> execute(String taskName, @Nullable T arg, long timeout, @Nullable GridPredicate<? super GridRichNode>... p)
GridTask 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 Grid#deployTask() method
for deployment algorithm).
Note that if projection is empty after applying filtering predicates, the result future will finish with exception. In case of dynamic projection this method will take a snapshot of all nodes in the projection, apply all filtering predicates, if any, and if the resulting set of nodes is empty the returned future will finish with exception.
execute in interface GridProjectionT - Type of the task's argument.R - Type of the task result returning from GridTask.reduce(List) method.taskName - Name of the task to execute. If task class has GridTaskName annotation,
then task is deployed under a name specified within annotation. Otherwise, full
class name is used as task's name.arg - Optional argument of task execution, can be null.timeout - Optional timeout for this task execution in milliseconds.
If 0 the system will wait indefinitely for execution completion.p - Optional set of filtering predicates. If none provided - all nodes in this projection
will be used for task topology.
for information about task execution.,
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withTopologySpi(String)public <T,R> GridTaskFuture<R> execute(String taskName, @Nullable T arg, GridTaskListener lsnr, @Nullable GridPredicate<? super GridRichNode>... p)
GridTask
documentation. Once task execution is complete, GridTaskListener.onFinished(GridTaskFuture)
gets called. In that case GridFuture.isDone() will always return true.
This method assumes indefinite wait for task completion. To provide a timeout, use
GridProjection.execute(String, Object, long, GridTaskListener, GridPredicate[]) method. It is always
recommended to specify explicit task timeout.
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 Grid#deployTask() method
for deployment algorithm).
Note that if projection is empty after applying filtering predicates, the result future will finish with exception. In case of dynamic projection this method will take a snapshot of all nodes in the projection, apply all filtering predicates, if any, and if the resulting set of nodes is empty the returned future will finish with exception.
execute in interface GridProjectionT - Type of the task's argument.R - Type of the task result returning from GridTask.reduce(List) method.taskName - Name of the task to execute. If task class has GridTaskName annotation,
then task is deployed under a name specified within annotation. Otherwise, full
class name is used as task's name.arg - Optional argument of task execution, can be null.lsnr - Optional grid task result listener that will be called once the execution is completed
(successfully or not).p - Optional set of filtering predicates. If none provided - all nodes in this projection
will be used for task topology.
for information about task execution.,
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withTopologySpi(String)public <T,R> GridTaskFuture<R> execute(String taskName, @Nullable T arg, long timeout, GridTaskListener lsnr, @Nullable GridPredicate<? super GridRichNode>... p)
GridTask
documentation. Once task execution is complete, GridTaskListener.onFinished(GridTaskFuture)
gets called. In that case GridFuture.isDone() will always return true.
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 Grid#deployTask() method
for deployment algorithm).
Note that if projection is empty after applying filtering predicates, the result future will finish with exception. In case of dynamic projection this method will take a snapshot of all nodes in the projection, apply all filtering predicates, if any, and if the resulting set of nodes is empty the returned future will finish with exception.
execute in interface GridProjectionT - Type of the task's argument.R - Type of the task result returning from GridTask.reduce(List) method.taskName - Name of the task to execute. If task class has GridTaskName annotation,
then task is deployed under a name specified within annotation. Otherwise, full
class name is used as task's name.arg - Optional argument of task execution, can be null.timeout - Optional timeout for this task execution in milliseconds.
If 0, then the system will wait indefinitely for execution completion.lsnr - Optional grid task result listener that will be called once the execution is completed
(successfully or not).p - Optional set of filtering predicates. If none provided - all nodes in this projection
will be used for task topology.
for information about task execution.,
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withTopologySpi(String)public <T,R> GridTaskFuture<R> execute(Class<? extends GridTask<T,R>> taskCls, @Nullable T arg, @Nullable GridPredicate<? super GridRichNode>... p)
GridTask documentation.
This method assumes indefinite wait for task completion. To provide a timeout, use
GridProjection.execute(String, Object, long, GridPredicate[]) method. It is always recommended
to specify explicit task timeout.
This method is extremely useful when task class is already loaded, for example, in J2EE application server environment. Since application servers already support deployment and hot-redeployment, it is convenient to deploy all task related classes via standard J2EE deployment and then use task classes directly.
When using this method task will be deployed automatically, so no explicit deployment step is required.
Note that if projection is empty after applying filtering predicates, the result future will finish with exception. In case of dynamic projection this method will take a snapshot of all nodes in the projection, apply all filtering predicates, if any, and if the resulting set of nodes is empty the returned future will finish with exception.
execute in interface GridProjectionT - Type of the task's argument.R - Type of the task result returning from GridTask.reduce(List) method.taskCls - Class of the task to execute. If class has GridTaskName annotation,
then task is deployed under a name specified within annotation. Otherwise, full
class name is used as task's name.arg - Optional argument of task execution, can be null.p - Optional set of filtering predicates. If none provided - all nodes in this projection
will be used for task topology.
for information about task execution.,
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withTopologySpi(String)public <T,R> GridTaskFuture<R> execute(Class<? extends GridTask<T,R>> taskCls, @Nullable T arg, long timeout, @Nullable GridPredicate<? super GridRichNode>... p)
GridTask documentation.
This method is extremely useful when task class is already loaded, for example, in J2EE application server environment. Since application servers already support deployment and hot-redeployment, it is convenient to deploy all task related classes via standard J2EE deployment and then use task classes directly.
When using this method task will be deployed automatically, so no explicit deployment step is required.
Note that if projection is empty after applying filtering predicates, the result future will finish with exception. In case of dynamic projection this method will take a snapshot of all nodes in the projection, apply all filtering predicates, if any, and if the resulting set of nodes is empty the returned future will finish with exception.
execute in interface GridProjectionT - Type of the task's argument.R - Type of the task result returning from GridTask.reduce(List) method.taskCls - Class of the task to execute. If class has GridTaskName annotation,
then task is deployed under a name specified within annotation. Otherwise, full
class name is used as task's name.arg - Optional argument of task execution, can be null.timeout - Optional timeout for this task execution in milliseconds.
If 0 the system will wait indefinitely for execution completion.p - Optional set of filtering predicates. If none provided - all nodes in this projection
will be used for task topology.
for information about task execution.,
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withTopologySpi(String)public <T,R> GridTaskFuture<R> execute(Class<? extends GridTask<T,R>> taskCls, @Nullable T arg, GridTaskListener lsnr, @Nullable GridPredicate<? super GridRichNode>... p)
GridTask
documentation. Once task execution is complete, GridTaskListener.onFinished(GridTaskFuture)
gets called. In that case GridFuture.isDone() will always return true.
This method assumes indefinite wait for task completion. To provide a timeout, use
GridProjection.execute(String, Object, long, GridTaskListener, GridPredicate[]) method. It is always
recommended to specify explicit task timeout.
This method is extremely useful when task class is already loaded, for example, in J2EE application server environment. Since application servers already support deployment and hot-redeployment, it is convenient to deploy all task related classes via standard J2EE deployment and then use task classes directly.
When using this method task will be deployed automatically, so no explicit deployment step is required.
Note that if projection is empty after applying filtering predicates, the result future will finish with exception. In case of dynamic projection this method will take a snapshot of all nodes in the projection, apply all filtering predicates, if any, and if the resulting set of nodes is empty the returned future will finish with exception.
execute in interface GridProjectionT - Type of the task argument.R - Type of the task result returning from GridTask.reduce(List) method.taskCls - Class of the task to execute. If class has GridTaskName annotation,
then task is deployed under a name specified within annotation. Otherwise, full
class name is used as task's name.arg - Optional argument of task execution, can be null.lsnr - Optional grid task result listener that will be called once the execution is completed
(successfully or not).p - Optional set of filtering predicates. If none provided - all nodes in this projection
will be used for task topology.
for information about task execution.public <T,R> GridTaskFuture<R> execute(Class<? extends GridTask<T,R>> taskCls, @Nullable T arg, long timeout, GridTaskListener lsnr, @Nullable GridPredicate<? super GridRichNode>... p)
GridTask
documentation. Once task execution is complete, GridTaskListener.onFinished(GridTaskFuture)
gets called. In that case GridFuture.isDone() will always return true.
This method is extremely useful when task class is already loaded, for example, in J2EE application server environment. Since application servers already support deployment and hot-redeployment, it is convenient to deploy all task related classes via standard J2EE deployment and then use task classes directly.
When using this method task will be deployed automatically, so no explicit deployment step is required.
Note that if projection is empty after applying filtering predicates, the result future will finish with exception. In case of dynamic projection this method will take a snapshot of all nodes in the projection, apply all filtering predicates, if any, and if the resulting set of nodes is empty the returned future will finish with exception.
execute in interface GridProjectionT - Type of the task's argument.R - Type of the task result returning from GridTask.reduce(List) method.taskCls - Class of the task to execute. If class has GridTaskName annotation,
then task is deployed under a name specified within annotation. Otherwise, full
class name is used as task's name.arg - Optional argument of task execution, can be null.timeout - Optional timeout for this task execution in milliseconds.
If 0, then the system will wait indefinitely for execution completion.lsnr - Optional grid task result listener that will be called once the execution is completed
(successfully or not).p - Optional set of filtering predicates. If none provided - all nodes in this projection
will be used for task topology.
for information about task execution.public GridPredicate<GridRichNode> predicate()
predicate in interface GridProjectionpublic <T,R> GridTaskFuture<R> execute(GridTask<T,R> task, @Nullable T arg, @Nullable GridPredicate<? super GridRichNode>... p)
GridTask documentation.
This method assumes indefinite wait for task completion. To provide a timeout, use
GridProjection.execute(String, Object, long, GridPredicate[]) method. It is always recommended to specify
explicit task timeout.
This method is extremely useful when task class is already loaded, for example, in J2EE application server environment. Since application servers already support deployment and hot-redeployment, it is convenient to deploy all task related classes via standard J2EE deployment and then use task classes directly.
When using this method task will be deployed automatically, so no explicit deployment step is required.
Note that if projection is empty after applying filtering predicates, the result future will finish with exception. In case of dynamic projection this method will take a snapshot of all nodes in the projection, apply all filtering predicates, if any, and if the resulting set of nodes is empty the returned future will finish with exception.
execute in interface GridProjectionT - Type of the task's argument.R - Type of the task result returning from GridTask.reduce(List) method.task - Instance of task to execute. If task class has GridTaskName annotation,
then task is deployed under a name specified within annotation. Otherwise, full
class name is used as task's name.arg - Optional argument of task execution, can be null.p - Optional set of filtering predicates. If none provided - all nodes in this projection
will be used for task topology.
for information about task execution.,
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withTopologySpi(String)public <T,R> GridTaskFuture<R> execute(GridTask<T,R> task, @Nullable T arg, long timeout, @Nullable GridPredicate<? super GridRichNode>... p)
GridTask documentation.
This method is extremely useful when task class is already loaded, for example, in J2EE application server environment. Since application servers already support deployment and hot-redeployment, it is convenient to deploy all task related classes via standard J2EE deployment and then use task classes directly.
When using this method task will be deployed automatically, so no explicit deployment step is required.
Note that if projection is empty after applying filtering predicates, the result future will finish with exception. In case of dynamic projection this method will take a snapshot of all nodes in the projection, apply all filtering predicates, if any, and if the resulting set of nodes is empty the returned future will finish with exception.
execute in interface GridProjectionT - Type of the task's argument.R - Type of the task result returning from GridTask.reduce(List) method.task - Instance of task to execute. If task class has GridTaskName annotation,
then task is deployed under a name specified within annotation. Otherwise, full
class name is used as task's name.arg - Optional argument of task execution, can be null.timeout - Optional timeout for this task execution in milliseconds.
If 0 the system will wait indefinitely for execution completion.p - Optional set of filtering predicates. If none provided - all nodes in this projection
will be used for task topology.
for information about task execution.,
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withTopologySpi(String)public <T,R> GridTaskFuture<R> execute(GridTask<T,R> task, @Nullable T arg, GridTaskListener lsnr, @Nullable GridPredicate<? super GridRichNode>... p)
GridTask
documentation. Once task execution is complete, GridTaskListener.onFinished(GridTaskFuture)
gets called. In that case GridFuture.isDone() will always return true.
This method assumes indefinite wait for task completion. To provide a timeout, use
GridProjection.execute(String, Object, long, GridTaskListener, GridPredicate[]) method. It is always
recommended to specify explicit task timeout.
This method is extremely useful when task class is already loaded, for example, in J2EE application server environment. Since application servers already support deployment and hot-redeployment, it is convenient to deploy all task related classes via standard J2EE deployment and then use task classes directly.
When using this method task will be deployed automatically, so no explicit deployment step is required.
Note that if projection is empty after applying filtering predicates, the result future will finish with exception. In case of dynamic projection this method will take a snapshot of all nodes in the projection, apply all filtering predicates, if any, and if the resulting set of nodes is empty the returned future will finish with exception.
execute in interface GridProjectionT - Type of the task's argument.R - Type of the task result returning from GridTask.reduce(List) method.task - Instance of task to execute. If task class has GridTaskName annotation,
then task is deployed under a name specified within annotation. Otherwise, full
class name is used as task's name.arg - Optional argument of task execution, can be null.lsnr - Optional grid task result listener that will be called once the execution is completed
(successfully or not).p - Optional set of filtering predicates. If none provided - all nodes in this projection
will be used for task topology.
for information about task execution.public <T,R> GridTaskFuture<R> execute(GridTask<T,R> task, @Nullable T arg, long timeout, GridTaskListener lsnr, @Nullable GridPredicate<? super GridRichNode>... p)
GridTask
documentation. Once task execution is complete, GridTaskListener.onFinished(GridTaskFuture)
gets called. In that case GridFuture.isDone() will always return true.
This method is extremely useful when task class is already loaded, for example, in J2EE application server environment. Since application servers already support deployment and hot-redeployment, it is convenient to deploy all task related classes via standard J2EE deployment and then use task classes directly.
When using this method task will be deployed automatically, so no explicit deployment step is required.
Note that if projection is empty after applying filtering predicates, the result future will finish with exception. In case of dynamic projection this method will take a snapshot of all nodes in the projection, apply all filtering predicates, if any, and if the resulting set of nodes is empty the returned future will finish with exception.
execute in interface GridProjectionT - Type of the task's argument.R - Type of the task result returning from GridTask.reduce(List) method.task - Instance of task to execute. If task class has GridTaskName annotation,
then task is deployed under a name specified within annotation. Otherwise, full
class name is used as task's name.arg - Optional argument of task execution, can be null.timeout - Optional timeout for this task execution in milliseconds.
If 0, then the system will wait indefinitely for execution completion.lsnr - Optional grid task result listener that will be called once the execution is completed
(successfully or not).p - Optional set of filtering predicates. If none provided - all nodes in this projection
will be used for task topology.
for information about task execution.public <R1,R2,T extends Callable<R1>> R2 mapreduce(@Nullable GridMapper<T,GridRichNode> mapper, @Nullable Collection<T> jobs, @Nullable GridReducer<R1,R2> rdc, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
This method will block until its execution is complete or an exception is thrown.
All default SPI implementations configured for this grid instance will be
used (i.e. failover, load balancing, collision resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Here's a general example of the Java method that takes a text message and calculates its length by splitting it by spaces, calculating the length of each word on individual (remote) grid node and then summing (reducing) results from all nodes to produce the final length of the input string using function APIs, typedefs, and execution closures on the grid:
public static int length(final String msg) throws GridException {
return G.grid().call(SPREAD, F.yield(msg.split(" "), F.cInvoke("length")), F.sumIntReducer());
}
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
mapreduce in interface GridProjectionGridException - Thrown in case of any error.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException throws if computation was cancelled.R1 - Return type of the closures.R2 - Return type of the final reduced value.mapper - Mapping closure that maps given jobs to the grid nodes. Note that each job will be
mapped only once. If null - this method is no-op.jobs - Closures to map to grid nodes and execute on them. If null or empty -
this method is no-op.rdc - Reducing closure that reduces results from multiple closure into one final value.
If null - this method is no-op.p - Optional set of filtering predicates. If none provided - all nodes in this projection
will be used for topology.
null is returned.GridProjection.withResultClosure(GridClosure2X)public <R1,R2,T extends Callable<R1>> GridFuture<R2> mapreduceAsync(@Nullable GridMapper<T,GridRichNode> mapper, @Nullable Collection<T> jobs, @Nullable GridReducer<R1,R2> rdc, @Nullable GridPredicate<? super GridRichNode>... p)
Note that unlike its sibling method GridProjection.mapreduce(GridMapper, Collection, GridReducer, GridPredicate[])
this method does not block and returns immediately with the future. All default SPI implementations
configured for this grid instance will be used (i.e. failover, load balancing, collision resolution, etc.).
If you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
mapreduceAsync in interface GridProjectionR1 - Return type of the closures.R2 - Return type of the final reduced value.mapper - Mapping closure that maps given jobs to the grid nodes. Note that each job will be
mapped only once. If null - this method is no-op.jobs - Closures to map to grid nodes and execute on them.
If null or empty - this method is no-op.rdc - Reducing closure that reduces results from multiple closure into one final value.
If null - this method is no-op.p - Optional set of filtering predicates. If none provided - all nodes in this projection
will be used for topology.
null value is returned.GridProjection.withResultClosure(GridClosure2X)public boolean isEnterprise()
isEnterprise in interface GridTrue for enterprise edition, false - for community edition.GridEnterpriseFeatureException,
GridEnterpriseOnly
public GridProjection projectionForNodeIds(@Nullable
UUID... ids)
Note that name with prefix 0 selected to avoid Java naming conflict.
projectionForNodeIds in interface GridProjectionids - Collection of node IDs defining collection of nodes to create projection with.
public GridProjection projectionForPredicate(@Nullable
GridPredicate<? super GridRichNode>... p)
Note that name with prefix 1 selected to avoid Java naming conflict.
projectionForPredicate in interface GridProjectionp - Collection of predicates that all should evaluate to true for a node
to be included in the final projection.
PN
public long topologyHash(@Nullable
GridPredicate<? super GridRichNode>... p)
Note that since GridGain topology architecture is peer-to-peer (without centralized coordination) there is still a small window in which different nodes would have different version for the same topology. Therefore, this version cannot be used in strict ACID context. Values returned by this method are not guaranteed to be sequential. Standard implementation uses CRC32 hash method.
topologyHash in interface GridProjectionp - Collection of predicates that all should evaluate to true for node
to be included in the final calculation.
public Collection<GridRichNode> remoteNodes(@Nullable GridPredicate<? super GridRichNode>... p)
remoteNodes in interface GridProjectionp - Predicates to filter remote nodes. If none provided - all remote nodes
will be returned.
public GridProjection remoteProjection(@Nullable
GridPredicate<? super GridRichNode>... p)
remoteProjection in interface GridProjectionp - Predicates to filter remote nodes. If none provided - all remote nodes
will be used.
public Collection<GridRichNode> nodes(@Nullable GridPredicate<? super GridRichNode>... p)
true for all
given predicates.
nodes in interface GridProjectionp - Optional set of predicates. If none provided - all nodes will be returned.
true for provided predicates.
Node that this collection can be empty when either given predicates filter out all
nodes or method is called on daemon node and it is the only node in the topology.
Remember: this method doesn't return daemon nodes.GridProjection.daemonNodes(GridPredicate[])
public void run(@Nullable
GridMapper<Runnable,GridRichNode> mapper,
@Nullable
Collection<? extends Runnable> jobs,
@Nullable
GridPredicate<? super GridRichNode>... p)
throws GridException
This method will block until its execution is complete or an exception is thrown.
All default SPI implementations configured for this grid instance will be
used (i.e. failover, load balancing, collision resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Here's a general example of the Java method that takes a text message and calculates its length by splitting it by spaces, calculating the length of each word on individual (remote) grid node and then summing (reducing) results from all nodes to produce the final length of the input string using function APIs, typedefs, and execution closures on the grid:
public static int length(final String msg) throws GridException {
return G.grid().call(SPREAD, F.yield(msg.split(" "), F.cInvoke("length")), F.sumIntReducer());
}
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
run in interface GridProjectionGridException - Thrown in case of any error.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException throws if computation was cancelled.mapper - Mapping closure that maps given jobs to the grid nodes. Note that each job will be
mapped only once. If null - this method is no-op.jobs - Closures to map to grid nodes and execute on them.
If null or empty - this method is no-op.p - Optional set of filtering predicates. All predicates must evaluate to true for a
node to be included. If none provided - all nodes in this projection will be used for topology.GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)
public void run(GridClosureCallMode mode,
@Nullable
Runnable job,
@Nullable
GridPredicate<? super GridRichNode>... p)
throws GridException
This method will block until the execution is complete. All default SPI implementations
configured for this grid instance will be used (i.e. failover, load balancing, collision resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Here's a general example of the Java method that takes a text message, splits it into individual words and prints each word on an individual grid node using typedefs, functional APIs and closure execution on the grid:
public static void sayIt(String phrase) throws GridException {
G.grid().call(SPREAD, F.yield(phrase.split(" "), F.<String>printf("%s")));
}
Note that class GridAbsClosure implements Runnable and class GridOutClosure
implements Callable interface. Note also that class GridFunc and typedefs provide rich
APIs and functionality for closures and predicates based processing in GridGain. While Java interfaces
Runnable and Callable allow for lowest common denominator for APIs - it is advisable
to use richer Functional Programming support provided by GridGain available in org.gridgain.grid.lang
package.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
run in interface GridProjectionGridException - Thrown in case of any error.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException throws if computation was cancelled.mode - Mode of the distribution for the closure.job - Job closure to execute. If null - this method is no-op.p - Optional set of predicates. All predicates must evaluate to true for a node to be
included. If none provided - all nodes in this projection will be used in topology.PN,
GridProjection.runAsync(GridClosureCallMode, Runnable, GridPredicate[]),
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public GridFuture<?> runAsync(GridClosureCallMode mode, @Nullable Runnable job, @Nullable GridPredicate<? super GridRichNode>... p)
Unlike its sibling method GridProjection.run(GridClosureCallMode, Runnable, GridPredicate[]) this method does
not block and returns immediately with future. All default SPI implementations
configured for this grid instance will be used (i.e. failover, load balancing, collision resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Note that class GridAbsClosure implements Runnable and class GridOutClosure
implements Callable interface. Note also that class GridFunc and typedefs provide rich
APIs and functionality for closures and predicates based processing in GridGain. While Java interfaces
Runnable and Callable allow for lowest common denominator for APIs - it is advisable
to use richer Functional Programming support provided by GridGain available in org.gridgain.grid.lang
package.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
runAsync in interface GridProjectionmode - Mode of the distribution for the closure.job - Job closure to execute. If null - this method is no-op.p - Optional set of predicates. All predicates must evaluate to true for a node to be
included. If none provided - all nodes in this projection will be used in topology.
PN,
GridProjection.run(GridClosureCallMode, Runnable, GridPredicate[]),
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)
public void run(GridClosureCallMode mode,
@Nullable
Collection<? extends Runnable> jobs,
@Nullable
GridPredicate<? super GridRichNode>... p)
throws GridException
This method will block until the execution is complete. All default SPI implementations
configured for this grid instance will be used (i.e. failover, load balancing, collision resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Here's a general example of the Java method that takes a text message, splits it into individual words and prints each word on an individual grid node using typedefs, functional APIs and closure execution on the grid:
public static void sayIt(String phrase) throws GridException {
G.grid().call(SPREAD, F.yield(phrase.split(" "), F.<String>printf("%s")));
}
Note that class GridAbsClosure implements Runnable and class GridOutClosure
implements Callable interface. Note also that class GridFunc and typedefs provide rich
APIs and functionality for closures and predicates based processing in GridGain. While Java interfaces
Runnable and Callable allow for lowest common denominator for APIs - it is advisable
to use richer Functional Programming support provided by GridGain available in org.gridgain.grid.lang
package.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
run in interface GridProjectionGridException - Thrown in case of any error.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException throws if computation was cancelled.mode - Mode of the distribution for the closure.jobs - Job closures to execute. If null or empty - this method is no-op.p - Optional set of predicates. All predicates must evaluate to true for a node to be
included. If none provided - all nodes in this projection will be used in topology.PN,
GridProjection.runAsync(GridClosureCallMode, Collection, GridPredicate[]),
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public GridFuture<?> runAsync(GridClosureCallMode mode, @Nullable Collection<? extends Runnable> jobs, @Nullable GridPredicate<? super GridRichNode>... p)
Unlike its sibling method GridProjection.run(GridClosureCallMode, Collection, GridPredicate[]) this method does
not block and returns immediately with future. All default SPI implementations
configured for this grid instance will be used (i.e. failover, load balancing, collision resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Note that class GridAbsClosure implements Runnable and class GridOutClosure
implements Callable interface. Note also that class GridFunc and typedefs provide rich
APIs and functionality for closures and predicates based processing in GridGain. While Java interfaces
Runnable and Callable allow for lowest common denominator for APIs - it is advisable
to use richer Functional Programming support provided by GridGain available in org.gridgain.grid.lang
package.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
runAsync in interface GridProjectionmode - Mode of the distribution for the closure.jobs - Job closures to execute. If null or empty - this method is no-op.p - Optional set of predicates. All predicates must evaluate to true for a node to be
included. If none provided - all nodes in this projection will be used in topology.
PN,
GridProjection.run(GridClosureCallMode, Collection, GridPredicate[])
public GridProjection withName(@Nullable
String taskName)
You may use this method to set task name when you cannot use
GridTaskName annotation.
Here is an example.
G.grid().withName("MyTask").call(
BROADCAST,
new CAX() {
@Override public void applyx() throws GridException {
System.out.println("Hello!");
}
}
);
withName in interface GridProjectiontaskName - Task name.
this).
public GridProjection withResultClosure(@Nullable
GridClosure2X<GridJobResult,List<GridJobResult>,GridJobResultPolicy> res)
GridTask.result(GridJobResult, List) method for the
next executed closure on this projection in the current thread.
When closure starts execution the ad-hoc implementation set here is reset - so it is valid only
for one execution from the current thread.
Note that this method makes sense only for closure executions, i.e. the case where GridGain automatically converts closure to a grid task. If a user provided task is executed this ad-hoc closure is ignored.
This particular useful when you need to disable, for example, failover on specific closure
execution like in the following example (note that X.NO_FAILOVER provides
built-in closure that effectively disables failover logic):
G.grid().withResultClosure(X.NO_FAILOVER).call(
BROADCAST,
new CAX() {
@Override public void applyx() throws GridException {
System.out.println("Hello!");
}
}
);
withResultClosure in interface GridProjectionres - Ad-hoc implementation for GridTask.result(GridJobResult, List) method.
this).X.NO_FAILOVER
public GridProjection withFailoverSpi(@Nullable
String spiName)
You may use this method to set specific failover SPI when you cannot use
GridTaskSpis annotation.
Here is an example.
G.grid().withFailoverSpi("MyFailoverSpi").call(
BROADCAST,
new CAX() {
@Override public void applyx() throws GridException {
System.out.println("Hello!");
}
}
);
withFailoverSpi in interface GridProjectionspiName - Failover SPI name to use.
this).GridTaskSpis
public GridProjection withCheckpointSpi(@Nullable
String spiName)
You may use this method to set specific checkpoint SPI when you cannot use
GridTaskSpis annotation.
Here is an example.
G.grid().withCheckpointSpi("MyCheckpointSpi").call(
BROADCAST,
new CAX() {
@Override public void applyx() throws GridException {
System.out.println("Hello!");
}
}
);
withCheckpointSpi in interface GridProjectionspiName - Checkpoint SPI name to use.
this).GridTaskSpis
public GridProjection withLoadBalancingSpi(@Nullable
String spiName)
You may use this method to set specific load balancing SPI when you cannot use
GridTaskSpis annotation.
Here is an example.
G.grid().withLoadBalancingSpi("MyLoadBalancingSpi").call(
BROADCAST,
new CAX() {
@Override public void applyx() throws GridException {
System.out.println("Hello!");
}
}
);
withLoadBalancingSpi in interface GridProjectionspiName - Load balancing SPI name to use.
this).GridTaskSpis
public GridProjection withTopologySpi(@Nullable
String spiName)
You may use this method to set specific topology SPI when you cannot use
GridTaskSpis annotation.
Here is an example.
G.grid().withTopologySpi("MyTopologySpi").call(
BROADCAST,
new CAX() {
@Override public void applyx() throws GridException {
System.out.println("Hello!");
}
}
);
withTopologySpi in interface GridProjectionspiName - Checkpoint SPI name to use.
this).GridTaskSpispublic <R> R call(GridClosureCallMode mode, @Nullable Callable<R> job, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
This method will block until the execution is complete. All default SPI implementations
configured for this grid instance will be used (i.e. failover, load balancing, collision
resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Here's a general example of the Java method that takes a text message, splits it into individual words and prints each word on an individual grid node using typedefs, functional APIs and closure execution on the grid:
public static void sayIt(String phrase) throws GridException {
G.grid().call(SPREAD, F.yield(phrase.split(" "), F.<String>printf("%s")));
}
Note that class GridAbsClosure implements Runnable and class GridOutClosure
implements Callable interface. Note also that class GridFunc and typedefs provide rich
APIs and functionality for closures and predicates based processing in GridGain. While Java interfaces
Runnable and Callable allow for lowest common denominator for APIs - it is advisable
to use richer Functional Programming support provided by GridGain available in org.gridgain.grid.lang
package.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
call in interface GridProjectionGridException - Thrown in case of any error.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException throws if computation was cancelled.R - Type of the closure return value.mode - Mode of the distribution for the closures.job - Closure to invoke. If null - this method is no-op.p - Optional set of predicates. All predicates must evaluate to true for a node to be
included. If none provided - all nodes in this projection will be used.
GridClosureCallMode.UNICAST) - all results will be received but only first one
will be returned (and all other will be discarded). Such non-unicast executions make sense
primarily for side-effects only closures (i.e. closures that have no return value).PN,
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R> GridFuture<R> callAsync(GridClosureCallMode mode, @Nullable Callable<R> job, @Nullable GridPredicate<? super GridRichNode>... p)
Unlike its sibling method GridProjection.call(GridClosureCallMode, Callable, GridPredicate[]) this method does
not block and returns immediately with future. All default SPI implementations
configured for this grid instance will be used (i.e. failover, load balancing, collision resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Note that class GridAbsClosure implements Runnable and class GridOutClosure
implements Callable interface. Note also that class GridFunc and typedefs provide rich
APIs and functionality for closures and predicates based processing in GridGain. While Java interfaces
Runnable and Callable allow for lowest common denominator for APIs - it is advisable
to use richer Functional Programming support provided by GridGain available in org.gridgain.grid.lang
package.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
callAsync in interface GridProjectionR - Type of the closure return value.mode - Mode of the distribution for the closures.job - Closure to invoke. If null - this method is no-op.p - Optional set of predicates. All predicates must evaluate to true for a node to be
included. If none provided - all nodes in this projection will be used.
GridClosureCallMode.UNICAST) - all results will be received but
only first one will be returned (and all other will be discarded). Such non-unicast executions
make sense primarily for side-effects only closures (i.e. closures that have no return value).PN,
GridProjection.call(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R> Collection<R> call(GridClosureCallMode mode, @Nullable Collection<? extends Callable<R>> jobs, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
This method will block until the execution is complete. All default SPI implementations
configured for this grid instance will be used (i.e. failover, load balancing, collision
resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Here's a general example of the Java method that takes a text message, splits it into individual words and prints each word on an individual grid node using typedefs, functional APIs and closure execution on the grid:
public static void sayIt(String phrase) throws GridException {
G.grid().call(SPREAD, F.yield(phrase.split(" "), F.<String>printf("%s")));
}
Note that class GridAbsClosure implements Runnable and class GridOutClosure
implements Callable interface. Note also that class GridFunc and typedefs provide rich
APIs and functionality for closures and predicates based processing in GridGain. While Java interfaces
Runnable and Callable allow for lowest common denominator for APIs - it is advisable
to use richer Functional Programming support provided by GridGain available in org.gridgain.grid.lang
package.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
call in interface GridProjectionGridException - Thrown in case of any error.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException throws if computation was cancelled.mode - Mode of the distribution for the closures.jobs - Closures to invoke. If null or empty - this method is no-op.p - Optional set of predicates. All predicates must evaluate to true for a node to be
included. If none provided - all nodes in this projection will be used.
PN,
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R> GridFuture<Collection<R>> callAsync(GridClosureCallMode mode, @Nullable Collection<? extends Callable<R>> jobs, @Nullable GridPredicate<? super GridRichNode>... p)
Unlike its sibling method GridProjection.call(GridClosureCallMode, Collection, GridPredicate[]) this method does
not block and returns immediately with future. All default SPI implementations
configured for this grid instance will be used (i.e. failover, load balancing, collision resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Note that class GridAbsClosure implements Runnable and class GridOutClosure
implements Callable interface. Note also that class GridFunc and typedefs provide rich
APIs and functionality for closures and predicates based processing in GridGain. While Java interfaces
Runnable and Callable allow for lowest common denominator for APIs - it is advisable
to use richer Functional Programming support provided by GridGain available in org.gridgain.grid.lang
package.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
callAsync in interface GridProjectionR - Type of the closure return value.mode - Mode of the distribution for the closures.jobs - Closures to invoke. If null or empty - this method is no-op.p - Optional set of predicates. All predicates must evaluate to true for a node to be
included. If none provided - all nodes in this projection will be used.
PN,
GridProjection.call(GridClosureCallMode, Collection, GridPredicate[]),
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R1,R2> R2 reduce(GridClosureCallMode mode, @Nullable Collection<? extends Callable<R1>> jobs, @Nullable GridReducer<R1,R2> rdc, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
This method will block until the execution is complete. All default SPI implementations
configured for this grid instance will be used (i.e. failover, load balancing, collision
resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Here's a general example of the Java method that takes a text message and calculates its length by splitting it by spaces, calculating the length of each word on individual (remote) grid node and then summing (reducing) results from all nodes to produce the final length of the input string using function APIs, typedefs, and execution closures on the grid:
public static int length(final String msg) throws GridException {
return G.grid().call(SPREAD, F.yield(msg.split(" "), F.cInvoke("length")), F.sumIntReducer());
}
Note that class GridAbsClosure implements Runnable and class GridOutClosure
implements Callable interface. Note also that class GridFunc and typedefs provide rich
APIs and functionality for closures and predicates based processing in GridGain. While Java interfaces
Runnable and Callable allow for lowest common denominator for APIs - it is advisable
to use richer Functional Programming support provided by GridGain available in org.gridgain.grid.lang
package.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
reduce in interface GridProjectionGridException - Thrown in case of any error.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException throws if computation was cancelled.R1 - Closure result type.R2 - Type of the reduced value.mode - Mode of the distribution for the closure.jobs - Closures to executes. If null or empty - this method is no-op.rdc - Result reducing closure. If null - this method is no-op.p - Optional set of predicates. All predicates must evaluate to true for a node to be
included. If none provided - all nodes in this projection will be used.
null is returned.PN,
GridProjection.reduceAsync(GridClosureCallMode, Collection, GridReducer, GridPredicate[]),
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R1,R2> GridFuture<R2> reduceAsync(GridClosureCallMode mode, Collection<? extends Callable<R1>> jobs, GridReducer<R1,R2> rdc, @Nullable GridPredicate<? super GridRichNode>... p)
Unlike its sibling method GridProjection.reduce(GridClosureCallMode, Collection, GridReducer, GridPredicate[])
this method does not block and returns immediately with future. All default SPI implementations
configured for this grid instance will be used (i.e. failover, load balancing, collision resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Note that class GridAbsClosure implements Runnable and class GridOutClosure
implements Callable interface. Note also that class GridFunc and typedefs provide rich
APIs and functionality for closures and predicates based processing in GridGain. While Java interfaces
Runnable and Callable allow for lowest common denominator for APIs - it is advisable
to use richer Functional Programming support provided by GridGain available in org.gridgain.grid.lang
package.
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
reduceAsync in interface GridProjectionR1 - Closure result type.R2 - Type of the reduced value.mode - Mode of the distribution for the closure.jobs - Closures to executes. If null or empty - this method is no-op.rdc - Result reducing closure. If null - this method is no-op.p - Optional set of predicates. All predicates must evaluate to true for a node to be
included. If none provided - all nodes in this projection will be used.
null
value is returned.PN,
GridProjection.reduce(GridClosureCallMode, Collection, GridReducer, GridPredicate[]),
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)
public void send(@Nullable
Object msg,
@Nullable
GridPredicate<? super GridRichNode>... p)
throws GridException
send in interface GridProjectionGridException - If failed to send a message to any of the nodes.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.msg - Message to send. If null - this method is no-op.p - Optional set of filtering predicates. All predicates must evaluate to true for a
node to be included. If none provided - all nodes in this projection will be used.
public void send(@Nullable
Collection<?> msgs,
@Nullable
GridPredicate<? super GridRichNode>... p)
throws GridException
send in interface GridProjectionGridException - If failed to send a message to any of the nodes.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.msgs - Messages to send. Order of the sending is undefined. If the method produces
the exception none or some messages could have been sent already.
If null or empty - this method is no-op.p - Optional set of filtering predicates. All predicates must evaluate to true for a
node to be included. If none provided - all nodes in this projection will be used.
public GridRichNode node(UUID nodeId,
@Nullable
GridPredicate<? super GridRichNode>... p)
node in interface GridProjectionnodeId - Node ID.p - Optional set of filtering predicates. If non provided - all nodes in this
projection will be included.
null if such node does not exist in this
projection.
public boolean isEmptyFor(@Nullable
GridPredicate<? super GridRichNode>... p)
isEmptyFor in interface GridProjectionp - Optional set of filtering predicates. If non provided - all nodes in this
projection will be included.
true if at the time of calling this projection has at least
one node - false otherwise.public boolean isEmpty()
isEmpty in interface GridProjectiontrue if at the time of calling this projection has at least
one node - false otherwise.
public boolean contains(GridNode node,
@Nullable
GridPredicate<? super GridRichNode>... p)
contains in interface GridProjectionnode - Node to check.p - Optional set of filtering predicates. If non provided - all nodes in this
projection will be included.
true if this node is in this projection, false otherwise.
public boolean contains(UUID nodeId,
@Nullable
GridPredicate<? super GridRichNode>... p)
contains in interface GridProjectionnodeId - Node ID to check.p - Optional set of filtering predicates. If non provided - all nodes in this
projection will be included.
true if the node with given node ID is in this projection, false otherwise.public List<GridEvent> remoteEvents(GridPredicate<? super GridEvent> pe, long timeout, @Nullable GridPredicate<? super GridRichNode>... pn) throws GridException
remoteEvents in interface GridProjectionGridException - If query failed to execute.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException throws if computation was cancelled.pe - Predicate filter used to query events on remote nodes.timeout - Maximum time to wait for result, 0 to wait forever.pn - Optional set of predicates. All predicates must evaluate to true for a node to be
included. If none provided - all nodes in this projection will be used.
GridProjection.remoteEventsAsync(GridPredicate, long, GridPredicate[]),
PE,
PNpublic <T> void listen(@Nullable GridPredicate2<UUID,? super T>... p)
When this method is called it will register message listener for the messages only from nodes
in this projection and return immediately without blocking. On the background, for each received
messages from these nodes it will call passed in predicates. If all predicates return true -
it will continue listen for the new messages. If at least one predicate returns false -
it will unregister the listener and stop receiving messages. Note that checking predicates will
be short-circuit if a predicate evaluates to false.
Note that all predicates will be called in synchronized context so that only one thread can access given predicate at a time.
listen in interface GridProjectionT - Type of the message.p - Collection of predicates that is called on each received message. If all predicates
return true - the implementation will continue listen for the new messages. If any
predicate returns false - the implementation will unregister the listener and stop
receiving messages.
If none provided - this method is no-op.
GridListenActor,
GridProjection.remoteListenAsync(Collection, GridPredicate2[]),
GridProjection.remoteListenAsync(GridPredicate, GridPredicate2[])
public ExecutorService executor(@Nullable
GridPredicate<? super GridRichNode>... p)
ExecutorService which will execute all submitted
Callable and Runnable tasks on this projection. This essentially
creates a Distributed Thread Pool that can be used as a drop-in
replacement for local thread pools to gain easy distributed processing
capabilities.
User may run Callable and Runnable tasks
just like normally with java.util.ExecutorService.
The typical Java example could be:
... ExecutorService exec = grid.executor(); Future<String> fut = exec.submit(new MyCallable()); ... String res = fut.get(); ...
executor in interface GridProjectionp - Optional set of predicates. All predicates must evaluate to true for a node to be
included. If none provided or null - all nodes in this projection will be used.
ExecutorService which delegates all calls to grid.public Iterator<GridRichNode> iterator()
iterator in interface Iterable<GridRichNode>public GridFuture<List<GridEvent>> remoteEventsAsync(GridPredicate<? super GridEvent> pe, long timeout, @Nullable GridPredicate<? super GridRichNode>... pn)
remoteEventsAsync in interface GridProjectionpe - Predicate filter used to query events on remote nodes.timeout - Maximum time to wait for result, 0 to wait forever.pn - Optional set of predicates. All predicates must evaluate to true for a node to be
included. If none provided - all nodes in this projection will be used.
GridProjection.remoteEvents(GridPredicate, long, GridPredicate[]),
PE,
PN
public GridProjection projectionForNodeIds(@Nullable
Collection<UUID> nodeIds)
Note that name with prefix 0 selected to avoid Java naming conflict.
projectionForNodeIds in interface GridProjectionnodeIds - Collection of node IDs defining collection of nodes to create projection with.
public GridPair<GridProjection> split(@Nullable GridPredicate<? super GridRichNode>... p)
true for all
given predicates, second will have the remaining nodes. Note that if no predicates provided the first
projection in returned pair will be this projection and the second object in the pair will be null.
split in interface GridProjectionp - Optional set of splitting predicates.
public GridProjection cross(@Nullable
Collection<? extends GridNode> nodes)
cross in interface GridProjectionnodes - Set of nodes to cross by. If none provided - this projection is returned.
public GridProjection cross0(@Nullable
GridRichNode... nodes)
Note that name with prefix 1 selected to avoid Java naming conflict.
cross0 in interface GridProjectionnodes - Set of nodes to cross by. If none provided - this projection is returned.
public <R> Collection<R> call(@Nullable GridMapper<Callable<R>,GridRichNode> mapper, @Nullable Collection<? extends Callable<R>> jobs, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
GridMapper
for mapper details.
Note that unlike its sibling GridProjection.callAsync(GridMapper, Collection, GridPredicate[])
this method will block until execution is complete, timeout expires, execution
is cancelled or exception is thrown.
call in interface GridProjectionGridException - Thrown in case of any failure.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException
thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException
thrown if computation was cancelled.R - Type of job result.mapper - Mapper used to map jobs to nodes. If null - this method is no-op.jobs - Jobs to run. If null or empty - this method is no-op.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R> GridFuture<Collection<R>> callAsync(@Nullable GridMapper<Callable<R>,GridRichNode> mapper, @Nullable Collection<? extends Callable<R>> jobs, @Nullable GridPredicate<? super GridRichNode>... p)
GridMapper
for mapper details.
Note that unlike its sibling GridProjection.call(GridMapper, Collection, GridPredicate[])
this method doesn't block and immediately returns with future of execution.
callAsync in interface GridProjectionR - Type of job result.mapper - Mapper used to map jobs to nodes. If null - this method is no-op.jobs - Jobs to run. If null or empty - this method is no-op.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <T,R> Collection<R> call(GridClosureCallMode mode, @Nullable Collection<? extends GridClosure<? super T,R>> jobs, @Nullable Collection<? extends T> args, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
Note that unlike its sibling
GridProjection.callAsync(GridClosureCallMode, Collection, Collection, GridPredicate[])
this method will block until execution is complete, timeout expires, execution
is cancelled or exception is thrown.
call in interface GridProjectionGridException - Thrown in case of any failure.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException
thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException
thrown if computation was cancelled.T - Type of job argument.R - Type of job result.mode - Distribution mode.jobs - Jobs to run. If null or empty - this method is no-op.args - Jobs' arguments (closure free variables).p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <T,R> GridFuture<Collection<R>> callAsync(GridClosureCallMode mode, @Nullable Collection<? extends GridClosure<? super T,R>> jobs, @Nullable Collection<? extends T> args, @Nullable GridPredicate<? super GridRichNode>... p)
Note that unlike its sibling
GridProjection.call(GridClosureCallMode, Collection, Collection, GridPredicate[])
this method doesn't block and immediately returns with future of execution.
callAsync in interface GridProjectionT - Type of job argument.R - Type of job result.mode - Distribution mode.jobs - Jobs to run. If null or empty - this method is no-op.args - Jobs' arguments (closure free variables).p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <T,R> Collection<R> call(GridClosureCallMode mode, @Nullable GridClosure<? super T,R> job, @Nullable Collection<? extends T> args, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
GridClosureCallMode.BROADCAST
will be equal to size of collection of arguments.
Note that unlike its sibling
GridProjection.callAsync(GridClosureCallMode, GridClosure, Collection, GridPredicate[])
this method will block until execution is complete, timeout expires, execution
is cancelled or exception is thrown.
call in interface GridProjectionGridException - Thrown in case of any failure.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException
thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException
thrown if computation was cancelled.T - Type of job argument.R - Type of job result.mode - Distribution mode.job - Job to run. If null - this method is no-op.args - Job arguments (closure free variables).p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <T,R> GridFuture<Collection<R>> callAsync(GridClosureCallMode mode, @Nullable GridClosure<? super T,R> job, @Nullable Collection<? extends T> args, @Nullable GridPredicate<? super GridRichNode>... p)
GridClosureCallMode.BROADCAST
will be equal to size of collection of arguments.
Note that unlike its sibling
GridProjection.call(GridClosureCallMode, GridClosure, Collection, GridPredicate[])
this method doesn't block and immediately returns with future of execution.
callAsync in interface GridProjectionT - Type of job argument.R - Type of job result.mode - Distribution mode.job - Job to run. If null - this method is no-op.args - Job arguments (closure free variables).p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <T,R> Collection<R> call(GridClosureCallMode mode, @Nullable GridClosure<? super T,R> job, @Nullable GridOutClosure<T> pdc, int cnt, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
GridClosureCallMode.BROADCAST
will be equal to number of produced arguments specified by cnt.
Note that unlike its sibling
GridProjection.callAsync(GridClosureCallMode, GridClosure, GridOutClosure, int, GridPredicate[])
this method will block until execution is complete, timeout expires, execution
is cancelled or exception is thrown.
call in interface GridProjectionGridException - Thrown in case of any failure.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException
thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException
thrown if computation was cancelled.T - Type of job argument.R - Type of job result.mode - Distribution mode.job - Job to run. If null - this method is no-op.pdc - Producer of job arguments.cnt - Number of arguments to produce.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <T,R> GridFuture<Collection<R>> callAsync(GridClosureCallMode mode, @Nullable GridClosure<? super T,R> job, @Nullable GridOutClosure<T> pdc, int cnt, @Nullable GridPredicate<? super GridRichNode>... p)
GridClosureCallMode.BROADCAST
will be equal to number of produced arguments specified by cnt.
Note that unlike its sibling
GridProjection.call(GridClosureCallMode, GridClosure, GridOutClosure, int, GridPredicate[])
this method doesn't block and immediately returns with future of execution.
callAsync in interface GridProjectionT - Type of job argument.R - Type of job result.mode - Distribution mode.job - Job to run. If null - this method is no-op.pdc - Producer of job arguments. If null - this method is no-op.cnt - Number of arguments to produce.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <T> void run(GridClosureCallMode mode, @Nullable Collection<? extends GridInClosure<? super T>> jobs, @Nullable Collection<? extends T> args, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
Note that unlike its sibling
GridProjection.runAsync(GridClosureCallMode, Collection, Collection, GridPredicate[])
this method will block until execution is complete, timeout expires, execution
is cancelled or exception is thrown.
run in interface GridProjectionGridException - Thrown in case of any failure.
GridInterruptedException - Subclass of GridException
thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException
thrown if computation was cancelled.T - Type of job argument.mode - Distribution mode.jobs - Jobs to run. If null or empty - this method is no-op.args - Job arguments.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <T> GridFuture<?> runAsync(GridClosureCallMode mode, @Nullable Collection<? extends GridInClosure<? super T>> jobs, @Nullable Collection<? extends T> args, @Nullable GridPredicate<? super GridRichNode>... p)
Note that unlike its sibling
GridProjection.run(GridClosureCallMode, Collection, Collection, GridPredicate[])
this method doesn't block and immediately returns with future of execution.
runAsync in interface GridProjectionT - Type of job argument.mode - Distribution mode.jobs - Jobs to run. If null or empty - this method is no-op.args - Job arguments.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <T> void run(GridClosureCallMode mode, @Nullable GridInClosure<? super T> job, Collection<? extends T> args, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
GridClosureCallMode.BROADCAST will be equal to
size of collection of arguments.
Note that unlike its sibling
GridProjection.runAsync(GridClosureCallMode, GridInClosure, Collection, GridPredicate[])
this method will block until execution is complete, timeout expires, execution
is cancelled or exception is thrown.
run in interface GridProjectionGridException - Thrown in case of any failure.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException
thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException
thrown if computation was cancelled.T - Type of job argument.mode - Distribution mode.job - Job to run. If null - this method is no-op.args - Job arguments.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <T> GridFuture<?> runAsync(GridClosureCallMode mode, @Nullable GridInClosure<? super T> job, @Nullable Collection<? extends T> args, @Nullable GridPredicate<? super GridRichNode>... p)
GridClosureCallMode.BROADCAST will be equal to
size of collection of arguments.
Note that unlike its sibling
GridProjection.run(GridClosureCallMode, GridInClosure, Collection, GridPredicate[])
this method doesn't block and immediately returns with future of execution.
runAsync in interface GridProjectionT - Type of job argument.mode - Distribution mode.job - Job to run. If null - this method is no-op.args - Job arguments.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <T> void run(GridClosureCallMode mode, @Nullable GridInClosure<? super T> job, @Nullable GridOutClosure<T> pdc, int cnt, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
GridClosureCallMode.BROADCAST will be equal to
number of produced arguments specified by cnt.
Note that unlike its sibling
GridProjection.runAsync(GridClosureCallMode, GridInClosure, GridOutClosure, int, GridPredicate[])
this method will block until execution is complete, timeout expires, execution
is cancelled or exception is thrown.
run in interface GridProjectionGridException - Thrown in case of any failure.
GridInterruptedException - Subclass of GridException
thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException
thrown if computation was cancelled.T - Type of job argument.mode - Distribution mode.job - Job to run. If null - this method is no-op.pdc - Producer of job arguments. If null - this method is no-op.cnt - Number of arguments to produce.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <T> GridFuture<?> runAsync(GridClosureCallMode mode, @Nullable GridInClosure<? super T> job, @Nullable GridOutClosure<T> pdc, int cnt, @Nullable GridPredicate<? super GridRichNode>... p)
GridClosureCallMode.BROADCAST will be equal to
number of produced arguments specified by cnt.
Note that unlike its sibling
GridProjection.run(GridClosureCallMode, GridInClosure, GridOutClosure, int, GridPredicate[])
this method doesn't block and immediately returns with future of execution.
runAsync in interface GridProjectionT - Type of job argument.mode - Distribution mode.job - Job to run. If null - this method is no-op.pdc - Producer of job arguments. If null - this method is no-op.cnt - Number of arguments to produce.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R1,R2,T> R2 reduce(GridClosureCallMode mode, @Nullable Collection<? extends GridClosure<? super T,R1>> jobs, @Nullable Collection<? extends T> args, @Nullable GridReducer<R1,R2> rdc, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
GridReducer for reducer details.
Note that unlike its sibling
GridProjection.reduceAsync(GridClosureCallMode, Collection, Collection, GridReducer, GridPredicate[])
this method will block until execution is complete, timeout expires, execution
is cancelled or exception is thrown.
reduce in interface GridProjectionGridException - Thrown in case of any failure.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException
thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException
thrown if computation was cancelled.R1 - Type of job result.R2 - Type of reduced result.T - Type of job argument.mode - Distribution mode.jobs - Jobs to run. If null or empty - this method is no-op.args - Job arguments.rdc - Job result reducer. If null - this method is no-op.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
null is returned.GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R1,R2,T> GridFuture<R2> reduceAsync(GridClosureCallMode mode, @Nullable Collection<? extends GridClosure<? super T,R1>> jobs, @Nullable Collection<? extends T> args, @Nullable GridReducer<R1,R2> rdc, @Nullable GridPredicate<? super GridRichNode>... p)
GridReducer for reducer details.
Note that unlike its sibling
GridProjection.reduce(GridClosureCallMode, Collection, Collection, GridReducer, GridPredicate[])
this method doesn't block and immediately returns with future of execution.
reduceAsync in interface GridProjectionR1 - Type of job result.R2 - Type of reduced result.T - Type of job argument.mode - Distribution mode.jobs - Jobs to run. If null or empty - this method is no-op.args - Job arguments.rdc - Job result reducer. If null - this method is no-op.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
null value is returned.GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R1,R2,T> R2 reduce(GridClosureCallMode mode, @Nullable GridClosure<? super T,R1> job, @Nullable Collection<? extends T> args, @Nullable GridReducer<R1,R2> rdc, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
GridClosureCallMode.BROADCAST
will be equal to size of collection of arguments. Then method reduces these job
results to a single execution result using provided reducer. See GridReducer
for reducer details.
Note that unlike its sibling
GridProjection.reduceAsync(GridClosureCallMode, GridClosure, Collection, GridReducer, GridPredicate[])
this method will block until execution is complete, timeout expires, execution
is cancelled or exception is thrown.
reduce in interface GridProjectionGridException - Thrown in case of any failure.
GridInterruptedException - Subclass of GridException
thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException
thrown if computation was cancelled.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.R1 - Type of job result.R2 - Type of reduced result.T - Type of job argument.mode - Distribution mode.job - Job to run. If null - this method is no-op.args - Job arguments.rdc - Job result reducer. If null - this method is no-op.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
null is returned.GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R1,R2,T> GridFuture<R2> reduceAsync(GridClosureCallMode mode, @Nullable GridClosure<? super T,R1> job, @Nullable Collection<? extends T> args, @Nullable GridReducer<R1,R2> rdc, @Nullable GridPredicate<? super GridRichNode>... p)
GridClosureCallMode.BROADCAST
will be equal to size of collection of arguments. Then method reduces these job
results to a single execution result using provided reducer. See GridReducer
for reducer details.
Note that unlike its sibling
GridProjection.reduce(GridClosureCallMode, GridClosure, Collection, GridReducer, GridPredicate[])
this method doesn't block and immediately returns with future of execution.
reduceAsync in interface GridProjectionR1 - Type of job result.R2 - Type of reduced result.T - Type of job argument.mode - Distribution mode.job - Job to run. If null - this method is no-op.args - Job arguments.rdc - Job result reducer. If null - this method is no-op.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
null value is returned.GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R1,R2,T> R2 reduce(GridClosureCallMode mode, @Nullable GridClosure<? super T,R1> job, @Nullable GridOutClosure<T> pdc, int cnt, @Nullable GridReducer<R1,R2> rdc, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
GridClosureCallMode.BROADCAST
will be equal to number of produced arguments specified by cnt. Then method
reduces these job results to a single execution result using provided reducer. See
GridReducer for reducer details.
Note that unlike its sibling
GridProjection.reduceAsync(GridClosureCallMode, GridClosure, GridOutClosure, int, GridReducer, GridPredicate[])
this method will block until execution is complete, timeout expires, execution
is cancelled or exception is thrown.
reduce in interface GridProjectionGridException - Thrown in case of any failure.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException
thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException
thrown if computation was cancelled.R1 - Type of job result.R2 - Type of reduced result.T - Type of job argument.mode - Distribution mode.job - Job to run. If null - this method is no-op.pdc - Producer of job arguments. If null - this method is no-op.cnt - Number of arguments to produce.rdc - Job result reducer. If null - this method is no-op.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
null is returned.GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R1,R2,T> GridFuture<R2> reduceAsync(GridClosureCallMode mode, @Nullable GridClosure<? super T,R1> job, @Nullable GridOutClosure<T> pdc, int cnt, @Nullable GridReducer<R1,R2> rdc, @Nullable GridPredicate<? super GridRichNode>... p)
GridClosureCallMode.BROADCAST
will be equal to number of produced arguments specified by cnt. Then method
reduces these job results to a single execution result using provided reducer. See
GridReducer for reducer details.
Note that unlike its sibling
GridProjection.reduce(GridClosureCallMode, GridClosure, GridOutClosure, int, GridReducer, GridPredicate[])
this method doesn't block and immediately returns with future of execution.
reduceAsync in interface GridProjectionR1 - Type of job result.R2 - Type of reduced result.T - Type of job argument.mode - Distribution mode.job - Job to run. If null - this method is no-op.pdc - Producer of job arguments. If null - this method is no-op.cnt - Number of arguments to produce.rdc - Job result reducer. If null - this method is no-op.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
null value is returned.GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R1,R2,T> R2 mapreduce(@Nullable GridMapper<GridOutClosure<R1>,GridRichNode> mapper, @Nullable Collection<? extends GridClosure<? super T,R1>> jobs, @Nullable Collection<? extends T> args, @Nullable GridReducer<R1,R2> rdc, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
GridMapper for mapper details and GridReducer
for reducer details.
Note that unlike its sibling
GridProjection.mapreduceAsync(GridMapper, Collection, Collection, GridReducer, GridPredicate[])
this method will block until execution is complete, timeout expires, execution
is cancelled or exception is thrown.
mapreduce in interface GridProjectionGridException - Thrown in case of any failure.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException
thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException
thrown if computation was cancelled.R1 - Type of job result.R2 - Type of reduced result.T - Type of job argument.mapper - Mapper used to map jobs to nodes.jobs - Jobs to run. If null or empty - this method is no-op.args - Job arguments.rdc - Job result reducer. If null - this method is no-op.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
null is returned.GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R1,R2,T> GridFuture<R2> mapreduceAsync(@Nullable GridMapper<GridOutClosure<R1>,GridRichNode> mapper, @Nullable Collection<? extends GridClosure<? super T,R1>> jobs, @Nullable Collection<? extends T> args, @Nullable GridReducer<R1,R2> rdc, @Nullable GridPredicate<? super GridRichNode>... p)
GridMapper for mapper details and GridReducer
for reducer details.
Note that unlike its sibling
GridProjection.mapreduce(GridMapper, Collection, Collection, GridReducer, GridPredicate[])
this method doesn't block and immediately returns with future of execution.
mapreduceAsync in interface GridProjectionR1 - Type of job result.R2 - Type of reduced result.T - Type of job argument.mapper - Mapper used to map jobs to nodes.jobs - Jobs to run. If null or empty - this method is no-op.args - Job arguments.rdc - Job result reducer. If null - this method is no-op.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
null value
is returned.GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R1,R2,T> R2 mapreduce(@Nullable GridMapper<GridOutClosure<R1>,GridRichNode> mapper, @Nullable GridClosure<? super T,R1> job, @Nullable Collection<? extends T> args, @Nullable GridReducer<R1,R2> rdc, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
GridClosureCallMode.BROADCAST will be equal to size of collection of
arguments. Then method reduces these job results to a single execution result
using provided reducer. See GridMapper for mapper details and
GridReducer for reducer details.
Note that unlike its sibling
GridProjection.mapreduceAsync(GridMapper, GridClosure, Collection, GridReducer, GridPredicate[])
this method will block until execution is complete, timeout expires, execution
is cancelled or exception is thrown.
mapreduce in interface GridProjectionGridException - Thrown in case of any failure.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException
thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException
thrown if computation was cancelled.R1 - Type of job result.R2 - Type of reduced result.T - Type of job argument.mapper - Mapper used to map jobs to nodes.job - Job to run. If null - this method is no-op.args - Job arguments.rdc - Job result reducer. If null - this method is no-op.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
null is returned.GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R1,R2,T> GridFuture<R2> mapreduceAsync(@Nullable GridMapper<GridOutClosure<R1>,GridRichNode> mapper, @Nullable GridClosure<? super T,R1> job, @Nullable Collection<? extends T> args, @Nullable GridReducer<R1,R2> rdc, @Nullable GridPredicate<? super GridRichNode>... p)
GridClosureCallMode.BROADCAST will be equal to size of collection of
arguments. Then method reduces these job results to a single execution result
using provided reducer. See GridMapper for mapper details and
GridReducer for reducer details.
Note that unlike its sibling
GridProjection.mapreduce(GridMapper, GridClosure, Collection, GridReducer, GridPredicate[])
this method doesn't block and immediately returns with future of execution.
mapreduceAsync in interface GridProjectionR1 - Type of job result.R2 - Type of reduced result.T - Type of job argument.mapper - Mapper used to map jobs to nodes.job - If null - this method is no-op.args - Job arguments.rdc - Job result reducer. If null - this method is no-op.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
null value is returned.GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R1,R2,T> R2 mapreduce(@Nullable GridMapper<GridOutClosure<R1>,GridRichNode> mapper, @Nullable GridClosure<? super T,R1> job, @Nullable GridOutClosure<T> pdc, int cnt, @Nullable GridReducer<R1,R2> rdc, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
GridClosureCallMode.BROADCAST will be equal to number of produced arguments
specified by cnt. Then method reduces these job results to a single execution
result using provided reducer. See GridMapper for mapper details and
GridReducer for reducer details.
Note that unlike its sibling
GridProjection.mapreduceAsync(GridMapper, GridClosure, GridOutClosure, int, GridReducer, GridPredicate[])
this method will block until execution is complete, timeout expires, execution
is cancelled or exception is thrown.
mapreduce in interface GridProjectionGridException - Thrown in case of any failure.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.
GridInterruptedException - Subclass of GridException
thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException
thrown if computation was cancelled.R1 - Type of job result.R2 - Type of reduced result.T - Type of job argument.mapper - Mapper used to map jobs to nodes.job - Job to run. If null - this method is no-op.pdc - Producer of job arguments. If null - this method is no-op.cnt - Number of arguments to produce.rdc - Job result reducer. If null - this method is no-op.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
null is returned.GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R1,R2,T> GridFuture<R2> mapreduceAsync(@Nullable GridMapper<GridOutClosure<R1>,GridRichNode> mapper, @Nullable GridClosure<? super T,R1> job, @Nullable GridOutClosure<T> pdc, int cnt, @Nullable GridReducer<R1,R2> rdc, @Nullable GridPredicate<? super GridRichNode>... p)
GridClosureCallMode.BROADCAST will be equal to number of produced arguments
specified by cnt. Then method reduces these job results to a single execution
result using provided reducer. See GridMapper for mapper details and
GridReducer for reducer details.
Note that unlike its sibling
GridProjection.mapreduce(GridMapper, GridClosure, GridOutClosure, int, GridReducer, GridPredicate[])
this method doesn't block and immediately returns with future of execution.
mapreduceAsync in interface GridProjectionR1 - Type of job result.R2 - Type of reduced result.T - Type of job argument.mapper - Mapper used to map jobs to nodes.job - Job to run. If null - this method is no-op.pdc - Producer of job arguments. If null - this method is no-op.cnt - Number of arguments to produce.rdc - Job result reducer. If null - this method is no-op.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
null value is returned.GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <T> void run(GridClosureCallMode mode, @Nullable GridInClosure<? super T> job, @Nullable T arg, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
GridProjection.callAsync(GridClosureCallMode, GridClosure, Object, GridPredicate[])
this method will block until execution is complete, timeout expires, execution
is cancelled or exception is thrown.
run in interface GridProjectionGridException - Thrown in case of any failure.
GridInterruptedException - Subclass of GridException
thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException
thrown if computation was cancelled.T - Type of job argument.mode - Distribution mode.job - Job to run. If null - this method is no-op.arg - Job argument.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <T> GridFuture<?> runAsync(GridClosureCallMode mode, @Nullable GridInClosure<? super T> job, @Nullable T arg, @Nullable GridPredicate<? super GridRichNode>... p)
GridProjection.run(GridClosureCallMode, GridInClosure, Object, GridPredicate[])
this method doesn't block and immediately returns with future of execution.
runAsync in interface GridProjectionT - Type of job argument.mode - Distribution mode.job - Job to run. If null - this method is no-op.arg - Job argument.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R,T> R call(GridClosureCallMode mode, @Nullable GridClosure<? super T,R> job, @Nullable T arg, @Nullable GridPredicate<? super GridRichNode>... p) throws GridException
GridProjection.callAsync(GridClosureCallMode, GridClosure, Object, GridPredicate[])
this method will block until execution is complete, timeout expires, execution
is cancelled or exception is thrown.
call in interface GridProjectionGridException - Thrown in case of any failure.
GridInterruptedException - Subclass of GridException
thrown if the wait was interrupted.
GridFutureCancelledException - Subclass of GridException
thrown if computation was cancelled.
GridEmptyProjectionException - Thrown in case when this projection is empty.
Note that in case of dynamic projection this method will take a snapshot of all the
nodes at the time of this call, apply all filtering predicates, if any, and if the
resulting collection of nodes is empty - the exception will be thrown.R - Type of job result.T - Type of job argument.mode - Distribution mode.job - Job to run. If null - this method is no-op.arg - Job argument.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
GridClosureCallMode.UNICAST) - all results will be received but only first one
will be returned (and all other will be discarded). Such non-unicast executions make sense
primarily for side-effects only closures (i.e. closures that have no return value).GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <R,T> GridFuture<R> callAsync(GridClosureCallMode mode, @Nullable GridClosure<? super T,R> job, @Nullable T arg, @Nullable GridPredicate<? super GridRichNode>... p)
GridProjection.call(GridClosureCallMode, GridClosure, Object, GridPredicate[])
this method doesn't block and immediately returns with future of execution.
callAsync in interface GridProjectionR - Type of job result.T - Type of job argument.mode - Distribution mode.job - Job to run. If null - this method is no-op.arg - Job argument.p - Optional set of predicates filtering execution topology. If not
provided - all nodes in this projection will be included.
GridClosureCallMode.UNICAST) - all results will be received but
only first one will be returned (and all other will be discarded). Such non-unicast executions
make sense primarily for side-effects only closures (i.e. closures that have no return value).GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public GridFuture<?> runAsync(@Nullable GridMapper<Runnable,GridRichNode> mapper, @Nullable Collection<? extends Runnable> jobs, @Nullable GridPredicate<? super GridRichNode>... p)
Unlike its sibling method GridProjection.run(GridClosureCallMode, Runnable, GridPredicate[]) this method does
not block and returns immediately with future. All default SPI implementations configured for this grid
instance will be used (i.e. failover, load balancing, collision resolution, etc.).
Note that if you need greater control on any aspects of Java code execution on the grid
you should implement GridTask which will provide you with full control over the execution.
Here's a general example of the Java method that takes a text message and calculates its length by splitting it by spaces, calculating the length of each word on individual (remote) grid node and then summing (reducing) results from all nodes to produce the final length of the input string using function APIs, typedefs, and execution closures on the grid:
public static int length(final String msg) throws GridException {
return G.grid().call(SPREAD, F.yield(msg.split(" "), F.cInvoke("length")), F.sumIntReducer());
}
Notice that Runnable and Callable implementations must support serialization as required
by the configured marshaller. For example, JDK marshaller will require that implementations would
be serializable. Other marshallers, e.g. JBoss marshaller, may not have this limitation. Please consult
with specific marshaller implementation for the details. Note that all closures and predicates in
org.gridgain.grid.lang package are serializable and can be freely used in the distributed
context with all marshallers currently shipped with GridGain.
runAsync in interface GridProjectionmapper - Mapping closure that maps given jobs to the grid nodes. Note that each job will be
mapped only once. If null - this method is no-op.jobs - Closures to map to grid nodes and execute on them.
If null or empty - this method is no-op.p - Optional set of filtering predicates. All predicates must evaluate to true for a
node to be included. If none provided - all nodes in this projection will be used for topology.
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]),
GridProjection.withCheckpointSpi(String),
GridProjection.withFailoverSpi(String),
GridProjection.withName(String),
GridProjection.withResultClosure(GridClosure2X),
GridProjection.withTopologySpi(String)public <K> Map<GridRichNode,Collection<K>> mapKeysToNodes(String cacheName, @Nullable Collection<? extends K> keys) throws GridException
This method works as following:
GridCacheAffinity is
used to determine which keys are mapped to which groups of nodes.
mapKeysToNodes in interface GridProjectionGridException - If failed to map cache keys.cacheName - Cache name, if null, then default cache instance is used.keys - Cache keys to map to nodes.
public <K> Map<GridRichNode,Collection<K>> mapKeysToNodes(@Nullable Collection<? extends K> keys) throws GridException
This method works as following:
GridCacheAffinity is
used to determine which keys are mapped to which nodes.
mapKeysToNodes in interface GridProjectionGridException - If failed to map cache keys.keys - Cache keys to map to nodes.
public <K> GridRichNode mapKeyToNode(K key) throws GridException
This method works as following:
GridCacheAffinity
is returned.
mapKeyToNode in interface GridProjectionGridException - If failed to map key.key - Cache key to map to a node.
null if cache with default name
is not present in the grid.public <K> GridRichNode mapKeyToNode(String cacheName, K key) throws GridException
This method works as following:
GridCacheAffinity
is returned.
mapKeyToNode in interface GridProjectionGridException - If failed to map key.cacheName - Cache name, if null, then default cache instance is used.key - Cache key to map to a node.
null if cache with given name
is not present in the grid.public Collection<GridTuple3<String,Boolean,String>> startNodes(File file, @Nullable String dfltUname, @Nullable String dfltPasswd, @Nullable File key, int nodes, @Nullable String ggHome, @Nullable String cfg, @Nullable String script, @Nullable String log, boolean restart) throws GridException
Parameters for each host are defined in specification which has the following format: <username>:<password>@<hostname>:<port>#<nodes> (only hostname is required).
If username or password are not provided in specification, default values from
dfltUname and dfltPasswd parameters are used.
Default port is 22.
<nodes> defines number of nodes that should run on the host. E.g., if
5 nodes are expected and 3 are already running, only 2 new
nodes will be started.
One specification can define several hosts if their IPs are sequential.
E.g., 10.0.0.1~5 defines range of five IP addresses. Other parameters
(username, password, etc.) are applied to all hosts equally.
Returned result contains tuples. Each corresponds to one node start attempt and contains hostname, success flag and error message if attempt was not successful. Note that successful attempt doesn't mean that node was actually started and joined topology. For large topologies (> 100s nodes) it can take over 10 minutes for all nodes to start. See individual node logs for details.
Note that SSH remote execution requires that all environment properties be set globally
on the remote node. Standard GridGain ggstart.{sh|bat} script needs both GRIDGAIN_HOME
(cam also be passed in ggHome parameter) and JAVA_HOME environment variables
set globally for SSH-based execution to work.
On Linux - you can use '/etc/environment' file to set global environment variables at the login time. Mac OSX currently doesn't support automatic setting of global variable and you need to provide custom start script in this case. On Windows use standard way to set environment properties.
startNodes in interface GridProjectionGridException - In case of error.file - File with host specifications.dfltUname - Default username (used if specification doesn't contain username).dfltPasswd - Default password (used if specification doesn't contain password).key - Private key file. Define it if server requires key authentication.nodes - Expected number of nodes on the host. If some nodes are started
already, then only remaining nodes will be started. If current count of
nodes is equal to this number, and restart flag is false,
then nothing will happen.ggHome - Path to GridGain installation folder. If null, global
GRIDGAIN_HOME environment variable must be set on remote hosts.cfg - Path to configuration file (optional).script - Path to start script (optional).log - Path to log file (optional).restart - Whether to stop existing nodes. If true, all existing
nodes on the host will be stopped before starting new ones. If false,
nodes will be started only if there are less nodes on the host than expected.
public Collection<GridTuple3<String,Boolean,String>> startNodes(Collection<String> hostSpecs, @Nullable String dfltUname, @Nullable String dfltPasswd, @Nullable File key, int nodes, @Nullable String ggHome, @Nullable String cfg, @Nullable String script, @Nullable String log, boolean restart) throws GridException
Parameters for each host are defined in specification which has the following format: <username>:<password>@<hostname>:<port>#<nodes> (only hostname is required).
If username or password are not provided in specification, default values from
dfltUname and dfltPasswd parameters are used.
Default port is 22.
<nodes> defines number of nodes that should run on the host. E.g., if
5 nodes are expected and 3 are already running, only 2 new
nodes will be started.
One specification can define several hosts if their IPs are sequential.
E.g., 10.0.0.1~5 defines range of five IP addresses. Other parameters
(username, password, etc.) are applied to all hosts equally.
Returned result contains tuples. Each corresponds to one node start attempt and contains hostname, success flag and error message if attempt was not successful. Note that successful attempt doesn't mean that node was actually started and joined topology. For large topologies (> 100s nodes) it can take over 10 minutes for all nodes to start. See individual node logs for details.
Note that SSH remote execution requires that all environment properties be set globally
on the remote node. Standard GridGain ggstart.{sh|bat} script needs both GRIDGAIN_HOME
(cam also be passed in ggHome parameter) and JAVA_HOME environment variables
set globally for SSH-based execution to work.
On Linux - you can use '/etc/environment' file to set global environment variables at the login time. Mac OSX currently doesn't support automatic setting of global variable and you need to provide custom start script in this case. On Windows use standard way to set environment properties.
startNodes in interface GridProjectionGridException - In case of error.hostSpecs - Collection of host specifications.dfltUname - Default username (used if specification doesn't contain username).dfltPasswd - Default password (used if specification doesn't contain password).key - Private key file. Define it if server requires key authentication.nodes - Expected number of nodes on the host. If some nodes are started
already, then only remaining nodes will be started. If current count of
nodes is equal to this number, and restart flag is false,
then nothing will happen.ggHome - Path to GridGain installation folder. If null, global
GRIDGAIN_HOME environment variable must be set on remote hosts.cfg - Path to configuration file (optional).script - Path to start script (optional).log - Path to log file (optional).restart - Whether to stop existing nodes. If true, all existing
nodes on the host will be stopped before starting new ones. If false,
nodes will be started only if there are less nodes on the host than expected.
public void stopNodes(@Nullable
GridPredicate<? super GridRichNode>... p)
throws GridException
stopNodes in interface GridProjectionGridException - In case of error.p - Optional set of filtering predicates. If none provided - all nodes in this projection
will be stopped.
public void stopNodes(UUID id,
@Nullable
UUID... ids)
throws GridException
stopNodes in interface GridProjectionGridException - In case of error.id - ID defining node to stop.ids - IDs defining nodes to stop.public void stopNodes(Collection<UUID> ids) throws GridException
stopNodes in interface GridProjectionGridException - In case of error.ids - IDs defining nodes to stop.
public void restartNodes(@Nullable
GridPredicate<? super GridRichNode>... p)
throws GridException
restartNodes in interface GridProjectionGridException - In case of error.p - Optional set of filtering predicates. If none provided - all nodes in this projection
will be restarted.
public void restartNodes(UUID id,
@Nullable
UUID... ids)
throws GridException
restartNodes in interface GridProjectionGridException - In case of error.id - ID defining node to restart.ids - IDs defining nodes to restart.public void restartNodes(Collection<UUID> ids) throws GridException
restartNodes in interface GridProjectionGridException - In case of error.ids - IDs defining nodes to restart.public String toString()
toString in class Object
public void writeExternal(ObjectOutput out)
throws IOException
writeExternal in interface ExternalizableIOException
public void readExternal(ObjectInput in)
throws IOException,
ClassNotFoundException
readExternal in interface ExternalizableIOException
ClassNotFoundException
|
GridGain 3.6.0e
Enterprise Edition |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
|
GridGain - Real Time Big Data
|
|
|