GridGain™ 3.6.0e
Enterprise Edition

org.gridgain.grid
Class GridSpringBean

java.lang.Object
  extended by org.gridgain.grid.lang.GridMetadataAwareAdapter
      extended by org.gridgain.grid.GridSpringBean
All Implemented Interfaces:
Externalizable, Serializable, Cloneable, Iterable<GridRichNode>, Grid, GridMetadataAware, GridProjection, org.springframework.beans.factory.Aware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware

public class GridSpringBean
extends GridMetadataAwareAdapter
implements Grid, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, Externalizable

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.

Spring Configuration Example

Here is a typical example of describing it in Spring file:
 <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"/>
 

Java Example

Here is how you may access this bean from code:
 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:


Wiki
Forum

See Also:
Serialized Form
 

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.
<R> Collection<R>
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.
<R> R
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.
<R> GridFuture<Collection<R>>
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.
<R> GridFuture<R>
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.
<K,V> GridCache<K,V>
cache()
          Gets default cache instance if one is configured or null otherwise.
<K,V> GridCache<K,V>
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.
<R> R
call(GridClosureCallMode mode, Callable<R> job, GridPredicate<? super GridRichNode>... p)
          Executes given closure on this projection.
<R> Collection<R>
call(GridClosureCallMode mode, Collection<? extends Callable<R>> jobs, GridPredicate<? super GridRichNode>... p)
          Executes given closures on this projection.
<T,R> Collection<R>
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.
<T,R> Collection<R>
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.
<T,R> Collection<R>
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.
<R,T> R
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.
<R> Collection<R>
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.
<R> GridFuture<R>
callAsync(GridClosureCallMode mode, Callable<R> job, GridPredicate<? super GridRichNode>... p)
          Asynchronously executes given closure on this projection.
<R> GridFuture<Collection<R>>
callAsync(GridClosureCallMode mode, Collection<? extends Callable<R>> jobs, GridPredicate<? super GridRichNode>... p)
          Asynchronously executes given closures on this projection.
<T,R> GridFuture<Collection<R>>
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.
<T,R> GridFuture<Collection<R>>
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.
<T,R> GridFuture<Collection<R>>
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.
<R,T> GridFuture<R>
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.
<R> GridFuture<Collection<R>>
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.
<R> GridFuture<R>
callLocal(Callable<R> c)
          Executes given callable on internal system thread pool asynchronously.
<R> R
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.
<R> GridFuture<R>
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.
<T,R> GridTaskFuture<R>
execute(Class<? extends GridTask<T,R>> taskCls, T arg, GridPredicate<? super GridRichNode>... p)
          Executes a task on the grid.
<T,R> GridTaskFuture<R>
execute(Class<? extends GridTask<T,R>> taskCls, T arg, GridTaskListener lsnr, GridPredicate<? super GridRichNode>... p)
          Asynchronously executes a task on the grid.
<T,R> GridTaskFuture<R>
execute(Class<? extends GridTask<T,R>> taskCls, T arg, long timeout, GridPredicate<? super GridRichNode>... p)
          Executes a task on the grid.
<T,R> GridTaskFuture<R>
execute(Class<? extends GridTask<T,R>> taskCls, T arg, long timeout, GridTaskListener lsnr, GridPredicate<? super GridRichNode>... p)
          Asynchronously executes a task on the grid.
<T,R> GridTaskFuture<R>
execute(GridTask<T,R> task, T arg, GridPredicate<? super GridRichNode>... p)
          Executes a task on the grid.
<T,R> GridTaskFuture<R>
execute(GridTask<T,R> task, T arg, GridTaskListener lsnr, GridPredicate<? super GridRichNode>... p)
          Asynchronously executes a task on the grid.
<T,R> GridTaskFuture<R>
execute(GridTask<T,R> task, T arg, long timeout, GridPredicate<? super GridRichNode>... p)
          Executes a task on the grid.
<T,R> GridTaskFuture<R>
execute(GridTask<T,R> task, T arg, long timeout, GridTaskListener lsnr, GridPredicate<? super GridRichNode>... p)
          Asynchronously executes a task on the grid.
<T,R> GridTaskFuture<R>
execute(String taskName, T arg, GridPredicate<? super GridRichNode>... p)
          Executes a task on the grid.
<T,R> GridTaskFuture<R>
execute(String taskName, T arg, GridTaskListener lsnr, GridPredicate<? super GridRichNode>... p)
          Asynchronously executes a task on the grid.
<T,R> GridTaskFuture<R>
execute(String taskName, T arg, long timeout, GridPredicate<? super GridRichNode>... p)
          Executes a task on the grid.
<T,R> GridTaskFuture<R>
execute(String taskName, T arg, long timeout, GridTaskListener lsnr, GridPredicate<? super GridRichNode>... p)
          Asynchronously executes a task on the grid.
<T,R> R
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.
<T,R> R
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.
<T,R> R
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.
<T> GridOutClosure<GridFuture<T>>
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.
<E,T> GridClosure<E,GridFuture<T>>
gridify(GridClosureCallMode mode, GridClosure<E,T> c, GridPredicate<? super GridRichNode>... p)
          Curries given closure into distribution version of it.
<E1,E2,T> GridClosure2<E1,E2,GridFuture<T>>
gridify(GridClosureCallMode mode, GridClosure2<E1,E2,T> c, GridPredicate<? super GridRichNode>... p)
          Curries given closure into distribution version of it.
<E1,E2,E3,T>
GridClosure3<E1,E2,E3,GridFuture<T>>
gridify(GridClosureCallMode mode, GridClosure3<E1,E2,E3,T> c, GridPredicate<? super GridRichNode>... p)
          Curries given closure into distribution version of it.
<E> GridClosure<E,GridFuture<?>>
gridify(GridClosureCallMode mode, GridInClosure<E> c, GridPredicate<? super GridRichNode>... p)
          Curries given closure into distribution version of it.
<E1,E2> GridClosure2<E1,E2,GridFuture<?>>
gridify(GridClosureCallMode mode, GridInClosure2<E1,E2> c, GridPredicate<? super GridRichNode>... p)
          Curries given closure into distribution version of it.
<E1,E2,E3> GridClosure3<E1,E2,E3,GridFuture<?>>
gridify(GridClosureCallMode mode, GridInClosure3<E1,E2,E3> c, GridPredicate<? super GridRichNode>... p)
          Curries given closure into distribution version of it.
<E> GridClosure<E,GridFuture<Boolean>>
gridify(GridClosureCallMode mode, GridPredicate<E> c, GridPredicate<? super GridRichNode>... p)
          Curries given predicate into distribution version of it.
<E1,E2> GridClosure2<E1,E2,GridFuture<Boolean>>
gridify(GridClosureCallMode mode, GridPredicate2<E1,E2> c, GridPredicate<? super GridRichNode>... p)
          Curries given predicate into distribution version of it.
<E1,E2,E3> GridClosure3<E1,E2,E3,GridFuture<Boolean>>
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.
<T> void
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.
<K> Map<GridRichNode,Collection<K>>
mapKeysToNodes(Collection<? extends K> keys)
          This method provides ability to detect which cache keys are mapped to which nodes on default unnamed cache instance.
<K> Map<GridRichNode,Collection<K>>
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.
<K> GridRichNode
mapKeyToNode(K key)
          This method provides ability to detect which keys are mapped to which nodes on default unnamed cache instance.
<K> GridRichNode
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.
<R1,R2,T> R2
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.
<R1,R2,T> R2
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.
<R1,R2,T> R2
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.
<R1,R2,T extends Callable<R1>>
R2
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.
<R1,R2,T> GridFuture<R2>
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.
<R1,R2,T> GridFuture<R2>
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.
<R1,R2,T> GridFuture<R2>
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.
<R1,R2,T extends Callable<R1>>
GridFuture<R2>
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.
<K,V> GridNodeLocal<K,V>
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)
          
<T> T
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.
<R1,R2> R2
reduce(GridClosureCallMode mode, Collection<? extends Callable<R1>> jobs, GridReducer<R1,R2> rdc, GridPredicate<? super GridRichNode>... p)
          Executes given jobs on this projection.
<R1,R2,T> R2
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.
<R1,R2,T> R2
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.
<R1,R2,T> R2
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.
<R1,R2> GridFuture<R2>
reduceAsync(GridClosureCallMode mode, Collection<? extends Callable<R1>> jobs, GridReducer<R1,R2> rdc, GridPredicate<? super GridRichNode>... p)
          Asynchronously executes given jobs on this projection.
<R1,R2,T> GridFuture<R2>
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.
<R1,R2,T> GridFuture<R2>
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.
<R1,R2,T> GridFuture<R2>
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.
<T> GridFuture<?>
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.
<T> GridFuture<?>
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.
<T> GridFuture<?>
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.
<T> void
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.
<T> void
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.
<T> void
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.
<T> void
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.
<T> GridFuture<?>
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.
<T> GridFuture<?>
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.
<T> GridFuture<?>
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.
<T> GridFuture<?>
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.
<R> GridScheduleFuture<R>
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

GridSpringBean

public GridSpringBean()
Method Detail

configuration

public GridConfiguration configuration()
Gets the configuration of this grid instance.

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.

Specified by:
configuration in interface Grid
Returns:
Grid configuration instance.

setConfiguration

public void setConfiguration(GridConfiguration cfg)
Sets grid configuration.

Parameters:
cfg - Grid configuration.

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext ctx)
                           throws org.springframework.beans.BeansException

Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Throws:
org.springframework.beans.BeansException

grid

public Grid grid()
Gets grid instance associated with this projection. Grid instance contains additional methods for working with grid as well as acts as a global projection (i.e. projection that is defined on all grid nodes in the topology).

Specified by:
grid in interface GridProjection
Returns:
Grid instance associated with this projection.

destroy

public void destroy()
             throws Exception

Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
Exception

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
Exception

log

public GridLogger log()
Gets grid's logger.

Specified by:
log in interface Grid
Returns:
Grid's logger.

projectionMetrics

public GridProjectionMetrics projectionMetrics()
                                        throws GridException
Gets a metrics snapshot for this projection.

Specified by:
projectionMetrics in interface GridProjection
Throws:
GridException - If projection is empty.
Returns:
Grid project metrics snapshot.
See Also:
GridNode.metrics()

daemonNodes

public Collection<GridRichNode> daemonNodes(@Nullable
                                            GridPredicate<? super GridRichNode>... p)
Gets collection of daemon nodes in this projection.

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.

Specified by:
daemonNodes in interface GridProjection
Parameters:
p - Optional set of predicates. If none provided - all daemon nodes will be returned.
Returns:
Collection of daemon nodes, possible empty, but never null.

parent

public GridProjection parent()
Gets parent projection or null if this project is an instance of Grid interface, i.e. root projection.

Specified by:
parent in interface GridProjection
Returns:
Parent projection of null.

projectionForAttribute

public GridProjection projectionForAttribute(String n,
                                             @Nullable
                                             String v)
Creates monadic projection with the nodes from this projection that have given node attribute with optional value. If value is null than simple attribute presence (with any value) will be used for inclusion of the node.

Specified by:
projectionForAttribute in interface GridProjection
Parameters:
n - Name of the attribute.
v - Optional attribute value to match.
Returns:
Monadic projection.

projectionForCaches

public GridProjection projectionForCaches(@Nullable
                                          String cacheName,
                                          @Nullable
                                          String... cacheNames)
Creates monadic projection with the nodes from this projection that have configured caches with given names.

Specified by:
projectionForCaches in interface GridProjection
Parameters:
cacheName - Cache name.
cacheNames - Cache names.
Returns:
Monadic projection.

size

public int size(@Nullable
                GridPredicate<? super GridRichNode>... p)
Gets number of nodes currently in this projection and satisfying optional set of predicates. Note that if projection is dynamic the size can vary from call to call.

Specified by:
size in interface GridProjection
Parameters:
p - Optional set of predicates. If none provided - all nodes in the projection will count.
Returns:
Number of nodes currently in this projection.

version

public String version()
Ges version string of the GridGain instance. This method is for information purpose only.

Specified by:
version in interface Grid
Returns:
GridGain version string (excluding the build number).
See Also:
Grid.build()

copyright

public String copyright()
Copyright statement for GridGain code.

Specified by:
copyright in interface Grid
Returns:
Legal copyright statement for GridGain code.

build

public String build()
Gets build number of this GridGain instance. This method is for information purpose only.

Specified by:
build in interface Grid
Returns:
GridGain instance build number.
See Also:
Grid.version()

random

public GridRichNode random()
Gets the randomly selected node from this projection.

Specified by:
random in interface GridProjection
Returns:
Randomly selected node in this topology. This method returns null if projection is empty.
See Also:
GridProjection.randomx()

runOptimistic

public boolean runOptimistic(GridAbsClosure c,
                             int attempts,
                             @Nullable
                             GridAbsClosure rollback,
                             @Nullable
                             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. If projection topology did change - optional rollback closure will be executed and given closure will be re-executed again up to specified number of attempts.

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.

Specified by:
runOptimistic in interface GridProjection
Parameters:
c - 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.
Returns:
True if closure successfully executed on unchanged topology - false if number of attempts is exceeded.
See Also:
GridProjection.runOptimisticAsync(GridAbsClosure, int, GridAbsClosure, GridPredicate[])

callOptimistic

public <R> R callOptimistic(GridOutClosure<R> c,
                            int attempts,
                            R dfltVal,
                            @Nullable
                            GridAbsClosure rollback,
                            @Nullable
                            GridPredicate<? super GridRichNode>... p)
Executes given closure in optimistic topology transaction, i.e. ensuring that grid topology doesn't change during the closure execution. If it did - optional rollback closure will be executed and given closure will be re-executed again up to specified number of attempts.

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.

Specified by:
callOptimistic in interface GridProjection
Type Parameters:
R - Type of the closure return value.
Parameters:
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.
Returns:
Closure return value.
See Also:
GridProjection.callOptimisticAsync(GridOutClosure, int, Object, GridAbsClosure, GridPredicate[])

runOptimisticAsync

public GridFuture<Boolean> runOptimisticAsync(GridAbsClosure c,
                                              int attempts,
                                              @Nullable
                                              GridAbsClosure rollback,
                                              @Nullable
                                              GridPredicate<? super GridRichNode>... p)
Executes given closure in optimistic topology transaction, i.e. ensuring that grid topology doesn't change during the closure execution. If it did - optional rollback closure will be executed and given closure will be re-executed again up to specified number of attempts.

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.

Specified by:
runOptimisticAsync in interface GridProjection
Parameters:
c - 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.
Returns:
Future with either true if closure successfully executed on unchanged topology, or false if number of attempts is exceeded.
See Also:
GridProjection.runOptimistic(GridAbsClosure, int, GridAbsClosure, GridPredicate[])

callOptimisticAsync

public <R> GridFuture<R> callOptimisticAsync(GridOutClosure<R> c,
                                             int attempts,
                                             R dfltVal,
                                             @Nullable
                                             GridAbsClosure rollback,
                                             @Nullable
                                             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. If it did - optional rollback closure will be executed and given closure will be re-executed again up to specified number of attempts.

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.

Specified by:
callOptimisticAsync in interface GridProjection
Type Parameters:
R - Type of the closure return value.
Parameters:
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.
Returns:
Future with return value.
See Also:
GridProjection.callOptimistic(GridOutClosure, int, Object, GridAbsClosure, GridPredicate[])

affinityRun

public void affinityRun(String cacheName,
                        @Nullable
                        Collection<?> affKeys,
                        @Nullable
                        Runnable job,
                        @Nullable
                        GridPredicate<? super GridRichNode>... p)
                 throws GridException
Executes given closure on the nodes where data for provided affinity keys are located. This is known as affinity co-location between compute grid (a closure) and in-memory data grid (value with affinity key). Note that implementation of multiple executions of the same closure will be wrapped as a single task that splits into multiple 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.

Specified by:
affinityRun in interface GridProjection
Throws:
GridException - 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.
Parameters:
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.
See Also:
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()

affinityRunAsync

public GridFuture<?> affinityRunAsync(String cacheName,
                                      @Nullable
                                      Collection<?> affKeys,
                                      @Nullable
                                      Runnable job,
                                      @Nullable
                                      GridPredicate<? super GridRichNode>... p)
                               throws GridException
Executes given closure on the nodes where data for provided affinity keys are located. This is known as affinity co-location between compute grid (a closure) and in-memory data grid (value with affinity key). Note that implementation of multiple executions of the same closure will be wrapped as a single task that splits into multiple 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.

Specified by:
affinityRunAsync in interface GridProjection
Throws:
GridException - 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.
Parameters:
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.
Returns:
Non-cancellable future of this execution.
See Also:
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()

affinityCall

public <R> R affinityCall(String cacheName,
                          @Nullable
                          Object affKey,
                          @Nullable
                          Callable<R> job,
                          @Nullable
                          GridPredicate<? super GridRichNode>... p)
               throws GridException
Executes given closure on the node where data for provided affinity key is located. This is known as affinity co-location between compute grid (a closure) and in-memory data grid (value with affinity key).

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.

Specified by:
affinityCall in interface GridProjection
Throws:
GridException - 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.
Parameters:
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.
Returns:
Closure execution result.
See Also:
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()

affinityCall

public <R> Collection<R> affinityCall(String cacheName,
                                      @Nullable
                                      Collection<?> affKeys,
                                      @Nullable
                                      Callable<R> job,
                                      @Nullable
                                      GridPredicate<? super GridRichNode>... p)
                           throws GridException
Executes given closure on the nodes where data for provided affinity keys are located. This is known as affinity co-location between compute grid (a closure) and in-memory data grid (value with affinity key). Note that implementation of multiple executions of the same closure will be wrapped as a single task that splits into multiple 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.

Specified by:
affinityCall in interface GridProjection
Throws:
GridException - 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.
Parameters:
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.
Returns:
Collection of closure execution results.
See Also:
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()

affinityCallAsync

public <R> GridFuture<R> affinityCallAsync(String cacheName,
                                           @Nullable
                                           Object affKey,
                                           @Nullable
                                           Callable<R> job,
                                           @Nullable
                                           GridPredicate<? super GridRichNode>... p)
                                throws GridException
Executes given closure on the node where data for provided affinity key is located. This is known as affinity co-location between compute grid (a closure) and in-memory data grid (value with affinity key).

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.

Specified by:
affinityCallAsync in interface GridProjection
Throws:
GridException - 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.
Parameters:
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.
Returns:
Non-cancellable closure result future.
See Also:
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()

affinityCallAsync

public <R> GridFuture<Collection<R>> affinityCallAsync(String cacheName,
                                                       @Nullable
                                                       Collection<?> affKeys,
                                                       @Nullable
                                                       Callable<R> job,
                                                       @Nullable
                                                       GridPredicate<? super GridRichNode>... p)
                                            throws GridException
Executes given closure on the nodes where data for provided affinity keys are located. This is known as affinity co-location between compute grid (a closure) and in-memory data grid (value with affinity key). Note that implementation of multiple executions of the same closure will be wrapped as a single task that splits into multiple 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.

Specified by:
affinityCallAsync in interface GridProjection
Throws:
GridException - 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.
Parameters:
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.
Returns:
Non-cancellable future of closure results. Upon successful execution number of results will be equal to number of affinity keys provided.
See Also:
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()

affinityRun

public void affinityRun(String cacheName,
                        Object affKey,
                        @Nullable
                        Runnable job,
                        @Nullable
                        GridPredicate<? super GridRichNode>... p)
                 throws GridException
Executes given closure on the node where data for provided affinity key is located. This is known as affinity co-location between compute grid (a closure) and in-memory data grid (value with affinity key).

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.

Specified by:
affinityRun in interface GridProjection
Throws:
GridException - 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.
Parameters:
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.
See Also:
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()

affinityRunAsync

public GridFuture<?> affinityRunAsync(String cacheName,
                                      Object affKey,
                                      @Nullable
                                      Runnable job,
                                      @Nullable
                                      GridPredicate<? super GridRichNode>... p)
                               throws GridException
Executes given closure on the node where data for provided affinity key is located. This is known as affinity co-location between compute grid (a closure) and in-memory data grid (value with affinity key).

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.

Specified by:
affinityRunAsync in interface GridProjection
Throws:
GridException - 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.
Parameters:
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.
Returns:
Non-cancellable future of this execution.
See Also:
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()

youngestx

public GridRichNode youngestx()
                       throws GridEmptyProjectionException
Gets the youngest node in this topology. The youngest node is a node from this topology that joined last.

Specified by:
youngestx in interface GridProjection
Throws:
GridEmptyProjectionException - Thrown in case when projection is empty.
Returns:
Youngest node in this topology.
See Also:
GridProjection.youngest()

oldestx

public GridRichNode oldestx()
                     throws GridEmptyProjectionException
Gets the oldest node in this topology. The oldest node is a node from this projection that joined topology first.

Specified by:
oldestx in interface GridProjection
Throws:
GridEmptyProjectionException - Thrown in case when projection is empty.
Returns:
Oldest node in this topology.
See Also:
GridProjection.oldest()

randomx

public GridRichNode randomx()
                     throws GridEmptyProjectionException
Gets the randomly selected node from this projection.

Specified by:
randomx in interface GridProjection
Throws:
GridEmptyProjectionException - Thrown in case when projection is empty.
Returns:
Randomly selected node in this topology.
See Also:
GridProjection.random()

neighborhood

public Collection<GridProjection> neighborhood()
Gets collections of neighbors from this projection. Neighbors are the groups of nodes from the same physical computer (host).

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.

Specified by:
neighborhood in interface GridProjection
Returns:
Collection of projections where each projection represents all nodes (in this projection) from a single physical computer. Result collection can be empty if this projection is empty.
See Also:
GridRichNode.neighbors(), GridRichNode.neighborsAndMe()

hasRemoteNodes

public boolean hasRemoteNodes()
Tests whether or not this projection has any remote nodes. Note that if this projection is dynamic the result of this method can vary from call to call.

Specified by:
hasRemoteNodes in interface GridProjection
Returns:
True if this projection does not have any remote nodes in it at the moment of call, false otherwise.

nodeId8

public Collection<GridRichNode> nodeId8(String id8)
Gets collection of nodes for given node ID8. ID8 is not strictly unique node ID since it returns first 8 characters of full node ID (which is UUID). ID8 is used for GUI purposes and monitoring. Note that since ID8 is not strictly unique, this method may return collection with more than one node matching given ID8.

Specified by:
nodeId8 in interface GridProjection
Parameters:
id8 - node ID8.
Returns:
Collection of nodes matching this ID8. Empty collection is returned when no nodes match given ID8.

hasLocalNode

public boolean hasLocalNode()
Tests whether or not this projection has local node in it. Note that if this projection is dynamic the result of this method can vary from call to call.

Specified by:
hasLocalNode in interface GridProjection
Returns:
True if this projection does not have local node in it at the moment of call, false otherwise.

youngest

public GridRichNode youngest()
Gets the youngest node in this topology. The youngest node is a node from this topology that joined last.

Specified by:
youngest in interface GridProjection
Returns:
Youngest node in this topology. This method returns null if projection is empty.
See Also:
GridProjection.youngestx()

oldest

public GridRichNode oldest()
Gets the oldest node in this topology. The oldest node is a node from this projection that joined topology first.

Specified by:
oldest in interface GridProjection
Returns:
Oldest node in this topology. This method returns null if projection is empty.
See Also:
GridProjection.oldestx()

hosts

public int hosts()
Gets number of unique hosts for nodes in this projection.

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.

Specified by:
hosts in interface GridProjection
Returns:
Number of unique hosts (always >= 1).

cpus

public int cpus()
Gets total number of CPUs for the nodes in this projection. Note that if two or more nodes started on the same physical host - they will all share the CPUs on that host (and this method will correctly account for that).

Specified by:
cpus in interface GridProjection
Returns:
Total number of CPUs (always >= 1).

isRestartEnabled

public boolean isRestartEnabled()
Whether or not node restart is enabled. Node restart us supported when this node was started with bin/ggstart.{sh|bat} script using -r argument. Node can be programmatically restarted using GridFactory.restart(boolean, boolean)} method.

Specified by:
isRestartEnabled in interface Grid
Returns:
True if restart mode is enabled, false otherwise.
See Also:
GridFactory.restart(boolean, boolean)

license

public GridEnterpriseLicense license()
Gets enterprise license descriptor.

Specified by:
license in interface Grid
Returns:
Enterprise license descriptor or null when running on Community Edition.

isJmxRemoteEnabled

public boolean isJmxRemoteEnabled()
Whether or not remote JMX management is enabled for this node. Remote JMX management is enabled when the following system property is set:

Specified by:
isJmxRemoteEnabled in interface Grid
Returns:
True if remote JMX management is enabled - false otherwise.

isSmtpEnabled

public boolean isSmtpEnabled()
Whether or not SMTP is configured. Note that SMTP is considered configured if SMTP host is provided in configuration (see GridConfiguration.getSmtpHost().

If SMTP is not configured all emails notifications will be disabled.

Specified by:
isSmtpEnabled in interface Grid
Returns:
True if SMTP is configured - false otherwise.
See Also:
GridConfiguration.getSmtpFromEmail(), GridConfiguration.getSmtpHost(), GridConfiguration.getSmtpPassword(), GridConfiguration.getSmtpPort(), GridConfiguration.getSmtpUsername(), GridConfiguration.isSmtpSsl(), GridConfiguration.isSmtpStartTls(), Grid.sendAdminEmailAsync(String, String, boolean)

sendAdminEmailAsync

public GridFuture<Boolean> sendAdminEmailAsync(String subj,
                                               String body,
                                               boolean html)
Schedule sending of given email to all configured admin emails. If no admin emails are configured this method is no-op. If SMTP is not configured this method is no-op.

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.

Specified by:
sendAdminEmailAsync in interface Grid
Parameters:
subj - Subject of the email.
body - Body of the email.
html - If true the email body will have MIME html subtype.
Returns:
Email's future. You can use this future to check on the status of the email. If future completes ok and its result value is true email was successfully sent. In all other cases - sending process has failed.
See Also:
Grid.isSmtpEnabled(), Grid.sendAdminEmail(String, String, boolean), GridConfiguration.getAdminEmails()

sendAdminEmail

public void sendAdminEmail(String subj,
                           String body,
                           boolean html)
                    throws GridException
Sends given email to all configured admin emails. If no admin emails are configured this method is no-op. If SMTP is not configured this method is no-op.

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.

Specified by:
sendAdminEmail in interface Grid
Throws:
GridException - Thrown in case when sending has failed.
Parameters:
subj - Subject of the email.
body - Body of the email.
html - If true the email body will have MIME html subtype.
See Also:
Grid.isSmtpEnabled(), Grid.sendAdminEmailAsync(String, String, boolean), GridConfiguration.getAdminEmails()

gridify

public <T> GridOutClosure<GridFuture<T>> gridify(GridClosureCallMode mode,
                                                 Callable<T> c,
                                                 @Nullable
                                                 GridPredicate<? super GridRichNode>... p)
Curries given closure into distribution version of it. When resulting closure is called it will return future without blocking and execute given closure asynchronously on this projection using closure call mode.

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.

Specified by:
gridify in interface GridProjection
Type Parameters:
T - Type of the return value.
Parameters:
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.
Returns:
Distributed version of the given closure.

gridify

public GridOutClosure<GridFuture<?>> gridify(GridClosureCallMode mode,
                                             Runnable r,
                                             @Nullable
                                             GridPredicate<? super GridRichNode>... p)
Curries given closure into distribution version of it. When resulting closure is called it will return future without blocking and execute given closure asynchronously on this projection using closure call mode.

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.

Specified by:
gridify in interface GridProjection
Parameters:
mode - 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.
Returns:
Distributed version of the given closure.

gridify

public <E,T> GridClosure<E,GridFuture<T>> gridify(GridClosureCallMode mode,
                                                  GridClosure<E,T> c,
                                                  @Nullable
                                                  GridPredicate<? super GridRichNode>... p)
Curries given closure into distribution version of it. When resulting closure is called it will return future without blocking and execute given closure asynchronously on this projection using closure call mode.

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.

Specified by:
gridify in interface GridProjection
Type Parameters:
E - Type of the free variable.
T - Type of the return value.
Parameters:
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.
Returns:
Distributed version of the given closure.

gridify

public <E1,E2,T> GridClosure2<E1,E2,GridFuture<T>> gridify(GridClosureCallMode mode,
                                                           GridClosure2<E1,E2,T> c,
                                                           @Nullable
                                                           GridPredicate<? super GridRichNode>... p)
Curries given closure into distribution version of it. When resulting closure is called it will return future without blocking and execute given closure asynchronously on this projection using closure call mode.

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.

Specified by:
gridify in interface GridProjection
Type Parameters:
E1 - Type of the first free variable.
E2 - Type of the second free variable.
T - Type of the return value.
Parameters:
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.
Returns:
Distributed version of the given closure.

gridify

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)
Curries given closure into distribution version of it. When resulting closure is called it will return future without blocking and execute given closure asynchronously on this projection using closure call mode.

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.

Specified by:
gridify in interface GridProjection
Type Parameters:
E1 - 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.
Parameters:
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.
Returns:
Distributed version of the given closure.

gridify

public <E> GridClosure<E,GridFuture<?>> gridify(GridClosureCallMode mode,
                                                GridInClosure<E> c,
                                                @Nullable
                                                GridPredicate<? super GridRichNode>... p)
Curries given closure into distribution version of it. When resulting closure is called it will return future without blocking and execute given closure asynchronously on this projection using closure call mode.

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.

Specified by:
gridify in interface GridProjection
Type Parameters:
E - Type of the free variable.
Parameters:
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.
Returns:
Distributed version of the given closure.

gridify

public <E1,E2> GridClosure2<E1,E2,GridFuture<?>> gridify(GridClosureCallMode mode,
                                                         GridInClosure2<E1,E2> c,
                                                         @Nullable
                                                         GridPredicate<? super GridRichNode>... p)
Curries given closure into distribution version of it. When resulting closure is called it will return future without blocking and execute given closure asynchronously on this projection using closure call mode.

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.

Specified by:
gridify in interface GridProjection
Type Parameters:
E1 - Type of the first free variable.
E2 - Type of the second free variable.
Parameters:
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.
Returns:
Distributed version of the given closure.

gridify

public <E1,E2,E3> GridClosure3<E1,E2,E3,GridFuture<?>> gridify(GridClosureCallMode mode,
                                                               GridInClosure3<E1,E2,E3> c,
                                                               @Nullable
                                                               GridPredicate<? super GridRichNode>... p)
Curries given closure into distribution version of it. When resulting closure is called it will return future without blocking and execute given closure asynchronously on this projection using closure call mode.

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.

Specified by:
gridify in interface GridProjection
Type Parameters:
E1 - Type of the first free variable.
E2 - Type of the second free variable.
E3 - Type of the third free variable.
Parameters:
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.
Returns:
Distributed version of the given closure.

gridify

public GridOutClosure<GridFuture<Boolean>> gridify(GridClosureCallMode mode,
                                                   GridAbsPredicate c,
                                                   @Nullable
                                                   GridPredicate<? super GridRichNode>... p)
Curries given predicate into distribution version of it. When resulting closure is called it will return future without blocking and execute given predicate asynchronously on this projection using closure call mode.

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.

Specified by:
gridify in interface GridProjection
Parameters:
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.
Returns:
Distributed version of the given predicate.

gridify

public <E> GridClosure<E,GridFuture<Boolean>> gridify(GridClosureCallMode mode,
                                                      GridPredicate<E> c,
                                                      @Nullable
                                                      GridPredicate<? super GridRichNode>... p)
Curries given predicate into distribution version of it. When resulting closure is called it will return future without blocking and execute given predicate asynchronously on this projection using closure call mode set.

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.

Specified by:
gridify in interface GridProjection
Type Parameters:
E - Type of the free variable.
Parameters:
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.
Returns:
Distributed version of the given predicate.

gridify

public <E1,E2> GridClosure2<E1,E2,GridFuture<Boolean>> gridify(GridClosureCallMode mode,
                                                               GridPredicate2<E1,E2> c,
                                                               @Nullable
                                                               GridPredicate<? super GridRichNode>... p)
Curries given predicate into distribution version of it. When resulting closure is called it will return future without blocking and execute given predicate asynchronously on this projection using closure call mode.

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.

Specified by:
gridify in interface GridProjection
Type Parameters:
E1 - Type of the first free variable.
E2 - Type of the second free variable.
Parameters:
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.
Returns:
Distributed version of the given predicate.

gridify

public <E1,E2,E3> GridClosure3<E1,E2,E3,GridFuture<Boolean>> gridify(GridClosureCallMode mode,
                                                                     GridPredicate3<E1,E2,E3> c,
                                                                     @Nullable
                                                                     GridPredicate<? super GridRichNode>... p)
Curries given predicate into distribution version of it. When resulting closure is called it will return future without blocking and execute given predicate asynchronously on this projection using closure call mode.

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.

Specified by:
gridify in interface GridProjection
Type Parameters:
E1 - Type of the first free variable.
E2 - Type of the second free variable.
E3 - Type of the third free variable.
Parameters:
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.
Returns:
Distributed version of the given predicate.

dynamic

public boolean dynamic()
Tells whether or not this projection is 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).

Specified by:
dynamic in interface GridProjection
Returns:
Whether or not projection is dynamic.

projectionForNodes

public GridProjection projectionForNodes(@Nullable
                                         Collection<? extends GridNode> nodes)
Creates monadic projection with a given set of nodes out of this projection. Note that nodes not in this projection at the moment of call will be excluded.

Specified by:
projectionForNodes in interface GridProjection
Parameters:
nodes - Collection of nodes to create a projection from.
Returns:
Monadic projection with given nodes.

projectionForNodes

public GridProjection projectionForNodes(@Nullable
                                         GridRichNode... nodes)
Creates monadic projection with a given set of nodes out of this projection. Note that nodes not in this projection at the moment of call will excluded.

Specified by:
projectionForNodes in interface GridProjection
Parameters:
nodes - Collection of nodes to create a projection from.
Returns:
Monadic projection with given nodes.

nodes

public Collection<GridRichNode> nodes(@Nullable
                                      Collection<UUID> ids)
Gets collection of grid nodes for given node IDs out of this projection. Note that nodes that not in this projection at the moment of call will be excluded.

Nodes are returned in the same order as passed in IDs.

Specified by:
nodes in interface GridProjection
Parameters:
ids - Collection of node IDs. If none provides - empty collection will be returned.
Returns:
Collection of grid nodes for given node IDs. Result collection can be smaller than the collection of IDs or even be empty depending on whether or not a node with given ID is still in the topology.

cross

public GridProjection cross(@Nullable
                            GridProjection... prjs)
Creates cross product of this projection and given projections. Resulting projection will only have nodes from this projection that also present in all given projections.

Specified by:
cross in interface GridProjection
Parameters:
prjs - Other projections. If none provided - this projection is returned.
Returns:
Cross product projection.

waitForEvent

public GridEvent waitForEvent(long timeout,
                              @Nullable
                              Runnable c,
                              @Nullable
                              GridPredicate<? super GridEvent> p,
                              @Nullable
                              int... types)
                       throws GridException
Blocks and waits for the local event.

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.

Specified by:
waitForEvent in interface Grid
Throws:
GridException - Thrown only when continuation throws any exception.
Parameters:
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.
Returns:
Grid event if one occurred or null if the call got timed out.
See Also:
Grid.waitForEventAsync(GridPredicate, int...)

waitForEventAsync

public GridFuture<GridEvent> waitForEventAsync(@Nullable
                                               GridPredicate<? super GridEvent> p,
                                               @Nullable
                                               int... types)
Gets event future that allows for asynchronous waiting for the specified events.

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.

Specified by:
waitForEventAsync in interface Grid
Parameters:
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.
Returns:
Grid event future.
See Also:
Grid.waitForEvent(long, Runnable, GridPredicate, int...)

rich

public GridRichNode rich(GridNode node)
Creates grid rich node wrapped around given thin 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.

Specified by:
rich in interface Grid
Parameters:
node - Thin node to wrap.
Returns:
Rich node.

merge

public GridProjection merge(@Nullable
                            GridProjection... prjs)
Merges this projection with the optional set of passed in projections.

Specified by:
merge in interface GridProjection
Parameters:
prjs - Optional set of projections to merge with. If non provided - this projection is returned.
Returns:
New merged projection or this project if non merging projections were passed in.

topologyHash

public long topologyHash(Iterable<? extends GridNode> nodes)
This method calculates hash value of the given set of nodes (a topology). Topology hash can be used in applications with optimistic locking scenario that relying on unchanged topology during a long operation.

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.

Specified by:
topologyHash in interface Grid
Parameters:
nodes - Collection of grid nodes. Note that this can be either full topology or any subset of it.
Returns:
8-byte topology hash value.

addLocalEventListener

public void addLocalEventListener(GridLocalEventListener lsnr,
                                  int[] types)
Adds an event listener for local events.

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

Specified by:
addLocalEventListener in interface Grid
Parameters:
lsnr - 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.

See Also:
GridEvent, GridEventType, Grid.addLocalEventListener(GridLocalEventListener, int, int...)

addLocalEventListener

public void addLocalEventListener(GridLocalEventListener lsnr,
                                  int type,
                                  @Nullable
                                  int... types)
Adds an event listener for local events.

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

Specified by:
addLocalEventListener in interface Grid
Parameters:
lsnr - 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.
See Also:
GridEvent, GridEventType, Grid.addLocalEventListener(GridLocalEventListener, int[])

remoteListenAsync

public <T> GridFuture<?> remoteListenAsync(@Nullable
                                           GridNode node,
                                           @Nullable
                                           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. 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.

Specified by:
remoteListenAsync in interface GridProjection
Type Parameters:
T - Type of the message.
Parameters:
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.

Returns:
Future for this distributed operation.
See Also:
GridListenActor, GridProjection.listen(GridPredicate2[]), GridProjection.remoteListenAsync(GridPredicate, GridPredicate2[]), GridProjection.send(Object, GridPredicate[]), GridProjection.send(Collection, GridPredicate[])

remoteListenAsync

public <T> GridFuture<?> remoteListenAsync(@Nullable
                                           Collection<? extends GridNode> nodes,
                                           @Nullable
                                           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. 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.

Specified by:
remoteListenAsync in interface GridProjection
Type Parameters:
T - Type of the message.
Parameters:
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.

Returns:
Future for this distributed operation.
See Also:
GridListenActor, GridProjection.listen(GridPredicate2[]), GridProjection.remoteListenAsync(GridPredicate, GridPredicate2[])

remoteListenAsync

public <T> GridFuture<?> remoteListenAsync(@Nullable
                                           GridPredicate<? super GridRichNode> pn,
                                           @Nullable
                                           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. Messages can be sent using one of the following methods: Essentially, this method allows to "wire up" sender(s) 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.

Specified by:
remoteListenAsync in interface GridProjection
Type Parameters:
T - Type of the message.
Parameters:
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.

Returns:
Future for this distributed operation.
See Also:
GridListenActor, GridProjection.listen(GridPredicate2[]), GridProjection.remoteListenAsync(Collection, GridPredicate2[])

removeLocalEventListener

public boolean removeLocalEventListener(GridLocalEventListener lsnr,
                                        @Nullable
                                        int... types)
Removes local event listener.

Specified by:
removeLocalEventListener in interface Grid
Parameters:
lsnr - 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.
Returns:
true if listener was removed, false otherwise.
See Also:
GridEventType, GridEvent

addMessageListener

public void addMessageListener(GridMessageListener lsnr,
                               @Nullable
                               GridPredicate<Object>... p)
Register a message listener to receive messages that are sent by remote nodes and which pass all provided message filters. See GridProjection.listen(GridPredicate2[]) method for more convenient message listening API.

Specified by:
addMessageListener in interface Grid
Parameters:
lsnr - Message listener to register.
p - Message filter predicates. If none is provided - every message received will be delivered to registered listener.
See Also:
GridProjection.listen(GridPredicate2[]), GridProjection.send(Collection, GridPredicate[]), GridProjection.send(Object, GridPredicate[]), Grid.removeMessageListener(GridMessageListener)

removeMessageListener

public boolean removeMessageListener(GridMessageListener lsnr)
Removes a previously registered message listener. See GridProjection.listen(GridPredicate2[]) method for more convenient message listening API.

Specified by:
removeMessageListener in interface Grid
Parameters:
lsnr - Message listener to remove.
Returns:
true of message listener was removed, false if it was not previously registered.
See Also:
GridProjection.listen(GridPredicate2[]), Grid.addMessageListener(GridMessageListener, GridPredicate[]), GridProjection.send(Collection, GridPredicate[]), GridProjection.send(Object, GridPredicate[])

localNode

public GridRichNode localNode()
Gets local grid node.

Specified by:
localNode in interface Grid
Returns:
Local grid node.

runLocal

public GridFuture<?> runLocal(@Nullable
                              Runnable r)
                       throws GridException
Executes given closure on internal system thread pool asynchronously.

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.

Specified by:
runLocal in interface Grid
Throws:
GridException - Thrown in case of rejected execution by internal system thread pool.
Parameters:
r - Runnable to execute. If null - this method is no-op.
Returns:
Future for this execution.
See Also:
Grid.callLocal(Callable), GridAbsClosure

callLocal

public <R> GridFuture<R> callLocal(@Nullable
                                   Callable<R> c)
                        throws GridException
Executes given callable on internal system thread pool asynchronously.

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.

Specified by:
callLocal in interface Grid
Throws:
GridException - Thrown in case of rejected execution by internal system thread pool.
Type Parameters:
R - Type of the return value for the closure.
Parameters:
c - Callable to execute. If null - this method is no-op.
Returns:
Future for this execution.
See Also:
Grid.runLocal(Runnable), GridOutClosure

scheduleLocal

public <R> GridScheduleFuture<R> scheduleLocal(@Nullable
                                               Callable<R> r,
                                               String pattern)
                                    throws GridException
Schedules closure for execution using local cron-based scheduling.

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.

Specified by:
scheduleLocal in interface Grid
Throws:
GridException - Thrown in case of any errors.
Parameters:
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.
Returns:
Scheduled execution future.

scheduleLocal

public GridScheduleFuture<?> scheduleLocal(@Nullable
                                           Runnable r,
                                           String pattern)
                                    throws GridException
Schedules closure for execution using local cron-based scheduling.

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.

Specified by:
scheduleLocal in interface Grid
Throws:
GridException - Thrown in case of any errors.
Parameters:
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.
Returns:
Scheduled execution future.

nodeLocal

public <K,V> GridNodeLocal<K,V> nodeLocal()
Gets node-local storage instance.

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.

Specified by:
nodeLocal in interface Grid
Returns:
Node local storage instance for the local node.

pingNode

public boolean pingNode(UUID nodeId)
Pings a remote node.

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.

Specified by:
pingNode in interface Grid
Parameters:
nodeId - ID of a node to ping.
Returns:
true if node for a given ID is alive, false otherwise.
See Also:
GridDiscoverySpi

deployTask

public void deployTask(Class<? extends GridTask> taskCls)
                throws GridException
Explicitly deploys given grid task on the local node. Upon completion of this method, a task can immediately be executed on the grid, considering that all participating remote nodes also have this task deployed. If peer-class-loading is enabled (see 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:

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.

Specified by:
deployTask in interface Grid
Throws:
GridException - If task is invalid and cannot be deployed.
Parameters:
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.
See Also:
GridDeploymentSpi

deployTask

public void deployTask(Class<? extends GridTask> taskCls,
                       ClassLoader clsLdr)
                throws GridException
Explicitly deploys given grid task on the local node. Upon completion of this method, a task can immediately be executed on the grid, considering that all participating remote nodes also have this task deployed. If peer-class-loading is enabled (see 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:

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.

Specified by:
deployTask in interface Grid
Throws:
GridException - If task is invalid and cannot be deployed.
Parameters:
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.
See Also:
GridDeploymentSpi

localTasks

public Map<String,Class<? extends GridTask<?,?>>> localTasks(@Nullable
                                                             GridPredicate<? super Class<? extends GridTask<?,?>>>... p)
Gets map of all locally deployed tasks keyed by their task name satisfying all given predicates. If no tasks were locally deployed, then empty map is returned. If no predicates provided - all locally deployed tasks, if any, will be returned.

Specified by:
localTasks in interface Grid
Parameters:
p - Set of filtering predicates. If no predicates provided - all locally deployed tasks, if any, will be returned.
Returns:
Map of locally deployed tasks keyed by their task name.

undeployTask

public void undeployTask(String taskName)
                  throws GridException
Makes the best attempt to undeploy a task from the whole grid. Note that this method returns immediately and does not wait until the task will actually be undeployed on every node.

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.

Specified by:
undeployTask in interface Grid
Throws:
GridException - Thrown if undeploy failed.
Parameters:
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.

localEvents

public Collection<GridEvent> localEvents(@Nullable
                                         GridPredicate<? super GridEvent>... p)
Queries local node for events using passed-in predicate filters for event selection.

Specified by:
localEvents in interface Grid
Parameters:
p - 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.

Returns:
Collection of grid events found on local node.
See Also:
PE

recordLocalEvent

public void recordLocalEvent(GridEvent evt)
Records locally generated event. Registered local listeners will be notified, if any. This event can be obtained from the remote nodes by performing a distributed query using GridProjection.remoteEvents(GridPredicate, long, GridPredicate[]) method.

Specified by:
recordLocalEvent in interface Grid
Parameters:
evt - Locally generated event.

name

public String name()
Gets the name of the grid this grid instance (and correspondingly its local node) belongs to. Note that single Java VM can have multiple grid instances all belonging to different grids. Grid name allows to indicate to what grid this particular grid instance (i.e. grid runtime and its local node) belongs to.

If default grid instance is used, then null is returned. Refer to GridFactory documentation for information on how to start named grids.

Specified by:
name in interface Grid
Returns:
Name of the grid, or null for default grid.

cache

public <K,V> GridCache<K,V> cache(String name)
Gets the cache instance for the given name if one is configured or null otherwise.

Specified by:
cache in interface Grid
Type Parameters:
K - Key type.
V - Value type.
Parameters:
name - Cache name.
Returns:
Cache instance for given name or null if one does not exist.

cache

public <K,V> GridCache<K,V> cache()
Gets default cache instance if one is configured or null otherwise. The GridCacheProjection.name() method on default instance returns null.

Specified by:
cache in interface Grid
Type Parameters:
K - Key type.
V - Value type.
Returns:
Default cache instance.

caches

public Collection<GridCache<?,?>> caches(@Nullable
                                         GridPredicate<? super GridCache<?,?>>... p)
Gets configured cache instance that satisfy all provided predicates. If no predicates provided - all configured caches will be returned.

Specified by:
caches in interface Grid
Parameters:
p - Predicates. If none provided - all configured caches will be returned.
Returns:
Configured cache instances that satisfy all provided predicates.

writeToSwap

public void writeToSwap(@Nullable
                        String space,
                        Object key,
                        @Nullable
                        Object val,
                        @Nullable
                        ClassLoader ldr)
                 throws GridException
Writes given data to specified swap space.

Specified by:
writeToSwap in interface Grid
Throws:
GridException - Thrown in case of any errors.
Parameters:
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).

readFromSwap

public <T> T readFromSwap(@Nullable
                          String space,
                          Object key,
                          @Nullable
                          ClassLoader ldr)
               throws GridException
Reads data stored by Grid.writeToSwap(String, Object, Object, ClassLoader) method.

Specified by:
readFromSwap in interface Grid
Throws:
GridException - Thrown in case of any errors.
Parameters:
space - Optional swap space name. If null is passed - global swap space will be used.
key - Data key.
ldr - Class loader (optional).
Returns:
Data read from swap space or null if no data was stored.

removeFromSwap

public void removeFromSwap(@Nullable
                           String space,
                           Object key,
                           @Nullable
                           GridInClosure<Object> c,
                           @Nullable
                           ClassLoader ldr)
                    throws GridException
Removes data stored by Grid.writeToSwap(String, Object, Object, ClassLoader) method.

Specified by:
removeFromSwap in interface Grid
Throws:
GridException - Thrown in case of any errors.
Parameters:
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).

clearSwapSpace

public void clearSwapSpace(@Nullable
                           String space)
                    throws GridException
Clears all entry from the specified swap space.

Specified by:
clearSwapSpace in interface Grid
Throws:
GridException - Thrown in case of any errors.
Parameters:
space - Optional swap space name. If null is passed - global swap space will be used.

executeSync

public <T,R> R executeSync(GridTask<T,R> task,
                           @Nullable
                           T arg,
                           long timeout,
                           @Nullable
                           GridPredicate<? super GridRichNode>... p)
              throws GridException
Companion to 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.

Specified by:
executeSync in interface GridProjection
Throws:
GridTaskTimeoutException - 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.
Type Parameters:
T - Type of the task's argument.
R - Type of the task result returning from GridTask.reduce(List) method.
Parameters:
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.
Returns:
Task result.
See Also:
GridProjection.execute(Class, Object, GridPredicate[]), GridProjection.execute(Class, Object, long, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withTopologySpi(String)

executeSync

public <T,R> R executeSync(Class<? extends GridTask<T,R>> taskCls,
                           @Nullable
                           T arg,
                           long timeout,
                           @Nullable
                           GridPredicate<? super GridRichNode>... p)
              throws GridException
Companion to 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.

Specified by:
executeSync in interface GridProjection
Throws:
GridTaskTimeoutException - 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.
Type Parameters:
T - Type of the task's argument.
R - Type of the task result returning from GridTask.reduce(List) method.
Parameters:
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.
Returns:
Task result.
See Also:
GridProjection.execute(Class, Object, GridPredicate[]), GridProjection.execute(Class, Object, long, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withTopologySpi(String)

executeSync

public <T,R> R executeSync(String taskName,
                           @Nullable
                           T arg,
                           long timeout,
                           @Nullable
                           GridPredicate<? super GridRichNode>... p)
              throws GridException
Companion to 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).

Specified by:
executeSync in interface GridProjection
Throws:
GridTaskTimeoutException - 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.
Type Parameters:
T - Type of the task's argument.
R - Type of the task result returning from GridTask.reduce(List) method.
Parameters:
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.
Returns:
Task result.
See Also:
GridProjection.execute(String, Object, GridPredicate[]), GridProjection.execute(String, Object, long, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withTopologySpi(String)

execute

public <T,R> GridTaskFuture<R> execute(String taskName,
                                       @Nullable
                                       T arg,
                                       @Nullable
                                       GridPredicate<? super GridRichNode>... p)
Executes a task on the grid. For information on how task gets split into remote jobs and how results are reduced back into one see 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.

Specified by:
execute in interface GridProjection
Type Parameters:
T - Type of the task's argument.
R - Type of the task result returning from GridTask.reduce(List) method.
Parameters:
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.
Returns:
Task future.
See Also:
for information about task execution., GridProjection.executeSync(String, Object, long, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withTopologySpi(String)

execute

public <T,R> GridTaskFuture<R> execute(String taskName,
                                       @Nullable
                                       T arg,
                                       long timeout,
                                       @Nullable
                                       GridPredicate<? super GridRichNode>... p)
Executes a task on the grid. For information on how task gets split into remote jobs and how results are reduced back into one see 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.

Specified by:
execute in interface GridProjection
Type Parameters:
T - Type of the task's argument.
R - Type of the task result returning from GridTask.reduce(List) method.
Parameters:
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.
Returns:
Task future.
See Also:
for information about task execution., GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withTopologySpi(String)

execute

public <T,R> GridTaskFuture<R> execute(String taskName,
                                       @Nullable
                                       T arg,
                                       GridTaskListener lsnr,
                                       @Nullable
                                       GridPredicate<? super GridRichNode>... p)
Asynchronously executes a task on the grid. For information on how task gets split into remote jobs and how results are reduced back into one see 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.

Specified by:
execute in interface GridProjection
Type Parameters:
T - Type of the task's argument.
R - Type of the task result returning from GridTask.reduce(List) method.
Parameters:
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.
Returns:
Task future.
See Also:
for information about task execution., GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withTopologySpi(String)

execute

public <T,R> GridTaskFuture<R> execute(String taskName,
                                       @Nullable
                                       T arg,
                                       long timeout,
                                       GridTaskListener lsnr,
                                       @Nullable
                                       GridPredicate<? super GridRichNode>... p)
Asynchronously executes a task on the grid. For information on how task gets split into remote jobs and how results are reduced back into one see 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.

Specified by:
execute in interface GridProjection
Type Parameters:
T - Type of the task's argument.
R - Type of the task result returning from GridTask.reduce(List) method.
Parameters:
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.
Returns:
Task future.
See Also:
for information about task execution., GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withTopologySpi(String)

execute

public <T,R> GridTaskFuture<R> execute(Class<? extends GridTask<T,R>> taskCls,
                                       @Nullable
                                       T arg,
                                       @Nullable
                                       GridPredicate<? super GridRichNode>... p)
Executes a task on the grid. For information on how task gets split into remote jobs and how results are reduced back into one see 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.

Specified by:
execute in interface GridProjection
Type Parameters:
T - Type of the task's argument.
R - Type of the task result returning from GridTask.reduce(List) method.
Parameters:
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.
Returns:
Task future.
See Also:
for information about task execution., GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withTopologySpi(String)

execute

public <T,R> GridTaskFuture<R> execute(Class<? extends GridTask<T,R>> taskCls,
                                       @Nullable
                                       T arg,
                                       long timeout,
                                       @Nullable
                                       GridPredicate<? super GridRichNode>... p)
Executes a task on the grid. For information on how task gets split into remote jobs and how results are reduced back into one see 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.

Specified by:
execute in interface GridProjection
Type Parameters:
T - Type of the task's argument.
R - Type of the task result returning from GridTask.reduce(List) method.
Parameters:
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.
Returns:
Task future.
See Also:
for information about task execution., GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withTopologySpi(String)

execute

public <T,R> GridTaskFuture<R> execute(Class<? extends GridTask<T,R>> taskCls,
                                       @Nullable
                                       T arg,
                                       GridTaskListener lsnr,
                                       @Nullable
                                       GridPredicate<? super GridRichNode>... p)
Asynchronously executes a task on the grid. For information on how task gets split into remote jobs and how results are reduced back into one see 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.

Specified by:
execute in interface GridProjection
Type Parameters:
T - Type of the task argument.
R - Type of the task result returning from GridTask.reduce(List) method.
Parameters:
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.
Returns:
Task future.
See Also:
for information about task execution.

execute

public <T,R> GridTaskFuture<R> execute(Class<? extends GridTask<T,R>> taskCls,
                                       @Nullable
                                       T arg,
                                       long timeout,
                                       GridTaskListener lsnr,
                                       @Nullable
                                       GridPredicate<? super GridRichNode>... p)
Asynchronously executes a task on the grid. For information on how task gets split into remote jobs and how results are reduced back into one see 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.

Specified by:
execute in interface GridProjection
Type Parameters:
T - Type of the task's argument.
R - Type of the task result returning from GridTask.reduce(List) method.
Parameters:
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.
Returns:
Task future.
See Also:
for information about task execution.

predicate

public GridPredicate<GridRichNode> predicate()
Gets predicate that defines a subset of nodes for this projection at the time of the call. Note that if projection is based on dynamically changing set of nodes - the predicate returning from this method will change accordingly from call to call.

Specified by:
predicate in interface GridProjection
Returns:
Predicate that defines a subset of nodes for this projection.

execute

public <T,R> GridTaskFuture<R> execute(GridTask<T,R> task,
                                       @Nullable
                                       T arg,
                                       @Nullable
                                       GridPredicate<? super GridRichNode>... p)
Executes a task on the grid. For information on how task gets split into remote jobs and how results are reduced back into one see 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.

Specified by:
execute in interface GridProjection
Type Parameters:
T - Type of the task's argument.
R - Type of the task result returning from GridTask.reduce(List) method.
Parameters:
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.
Returns:
Task future.
See Also:
for information about task execution., GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withTopologySpi(String)

execute

public <T,R> GridTaskFuture<R> execute(GridTask<T,R> task,
                                       @Nullable
                                       T arg,
                                       long timeout,
                                       @Nullable
                                       GridPredicate<? super GridRichNode>... p)
Executes a task on the grid. For information on how task gets split into remote jobs and how results are reduced back into one see 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.

Specified by:
execute in interface GridProjection
Type Parameters:
T - Type of the task's argument.
R - Type of the task result returning from GridTask.reduce(List) method.
Parameters:
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.
Returns:
Task future.
See Also:
for information about task execution., GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withTopologySpi(String)

execute

public <T,R> GridTaskFuture<R> execute(GridTask<T,R> task,
                                       @Nullable
                                       T arg,
                                       GridTaskListener lsnr,
                                       @Nullable
                                       GridPredicate<? super GridRichNode>... p)
Asynchronously executes a task on the grid. For information on how task gets split into remote jobs and how results are reduced back into one see 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.

Specified by:
execute in interface GridProjection
Type Parameters:
T - Type of the task's argument.
R - Type of the task result returning from GridTask.reduce(List) method.
Parameters:
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.
Returns:
Task future.
See Also:
for information about task execution.

execute

public <T,R> GridTaskFuture<R> execute(GridTask<T,R> task,
                                       @Nullable
                                       T arg,
                                       long timeout,
                                       GridTaskListener lsnr,
                                       @Nullable
                                       GridPredicate<? super GridRichNode>... p)
Asynchronously executes a task on the grid. For information on how task gets split into remote jobs and how results are reduced back into one see 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.

Specified by:
execute in interface GridProjection
Type Parameters:
T - Type of the task's argument.
R - Type of the task result returning from GridTask.reduce(List) method.
Parameters:
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.
Returns:
Task future.
See Also:
for information about task execution.

mapreduce

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
Executes given jobs on this projection with custom mapping and reducing logic.

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.

Specified by:
mapreduce in interface GridProjection
Throws:
GridException - 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.
Type Parameters:
R1 - Return type of the closures.
R2 - Return type of the final reduced value.
Parameters:
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.
Returns:
Reduced value from executing closures on this projection. if this method is no-op, null is returned.
See Also:
GridProjection.withResultClosure(GridClosure2X)

mapreduceAsync

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)
Asynchronously executes given jobs on this projection with custom mapping and reducing logic.

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.

Specified by:
mapreduceAsync in interface GridProjection
Type Parameters:
R1 - Return type of the closures.
R2 - Return type of the final reduced value.
Parameters:
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.
Returns:
Reduced value future from executing closures on this projection. if this method is no-op, future with null value is returned.
See Also:
GridProjection.withResultClosure(GridClosure2X)

isEnterprise

public boolean isEnterprise()
Tests whether or not this GridGain runtime runs on an enterprise edition. This method is primarily for informational purpose.

Specified by:
isEnterprise in interface Grid
Returns:
True for enterprise edition, false - for community edition.
See Also:
GridEnterpriseFeatureException, GridEnterpriseOnly

projectionForNodeIds

public GridProjection projectionForNodeIds(@Nullable
                                           UUID... ids)
Creates monadic projection with a given set of node IDs ouf of this projection. Note that nodes not in this projection at the moment of call will excluded.

Note that name with prefix 0 selected to avoid Java naming conflict.

Specified by:
projectionForNodeIds in interface GridProjection
Parameters:
ids - Collection of node IDs defining collection of nodes to create projection with.
Returns:
Monadic projection made out of nodes with given IDs.

projectionForPredicate

public GridProjection projectionForPredicate(@Nullable
                                             GridPredicate<? super GridRichNode>... p)
Creates monadic projection with the nodes from this projection that also satisfy given set of predicates.

Note that name with prefix 1 selected to avoid Java naming conflict.

Specified by:
projectionForPredicate in interface GridProjection
Parameters:
p - Collection of predicates that all should evaluate to true for a node to be included in the final projection.
Returns:
Monadic projection.
See Also:
PN

topologyHash

public long topologyHash(@Nullable
                         GridPredicate<? super GridRichNode>... p)
This method calculates hash value of the given set of nodes (a topology). Topology hash can be used in applications with optimistic locking scenario that relying on unchanged topology during a long operation.

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.

Specified by:
topologyHash in interface GridProjection
Parameters:
p - Collection of predicates that all should evaluate to true for node to be included in the final calculation.
Returns:
8-byte topology hash value.

remoteNodes

public Collection<GridRichNode> remoteNodes(@Nullable
                                            GridPredicate<? super GridRichNode>... p)
Gets read-only collections of nodes from this projection excluding local node, if any.

Specified by:
remoteNodes in interface GridProjection
Parameters:
p - Predicates to filter remote nodes. If none provided - all remote nodes will be returned.
Returns:
Collections of nodes from this projection excluding local node, if any.

remoteProjection

public GridProjection remoteProjection(@Nullable
                                       GridPredicate<? super GridRichNode>... p)
Gets monadic projection consisting from the nodes in this projection excluding the local node, if any.

Specified by:
remoteProjection in interface GridProjection
Parameters:
p - Predicates to filter remote nodes. If none provided - all remote nodes will be used.
Returns:
Monadic projection consisting from the nodes in this projection excluding the local node, if any.

nodes

public Collection<GridRichNode> nodes(@Nullable
                                      GridPredicate<? super GridRichNode>... p)
Gets read-only collections of nodes in this projection that evaluate to true for all given predicates.

Specified by:
nodes in interface GridProjection
Parameters:
p - Optional set of predicates. If none provided - all nodes will be returned.
Returns:
All nodes in this projection that evaluate to 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.
See Also:
GridProjection.daemonNodes(GridPredicate[])

run

public void run(@Nullable
                GridMapper<Runnable,GridRichNode> mapper,
                @Nullable
                Collection<? extends Runnable> jobs,
                @Nullable
                GridPredicate<? super GridRichNode>... p)
         throws GridException
Executes collections of closures using given mapper on this projection.

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.

Specified by:
run in interface GridProjection
Throws:
GridException - 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.
Parameters:
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.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

run

public void run(GridClosureCallMode mode,
                @Nullable
                Runnable job,
                @Nullable
                GridPredicate<? super GridRichNode>... p)
         throws GridException
Executes given closure on this projection.

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.

Specified by:
run in interface GridProjection
Throws:
GridException - 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.
Parameters:
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.
See Also:
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)

runAsync

public GridFuture<?> runAsync(GridClosureCallMode mode,
                              @Nullable
                              Runnable job,
                              @Nullable
                              GridPredicate<? super GridRichNode>... p)
Asynchronously executes given closure on this projection.

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.

Specified by:
runAsync in interface GridProjection
Parameters:
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.
Returns:
Non-cancellable future of this execution.
See Also:
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)

run

public void run(GridClosureCallMode mode,
                @Nullable
                Collection<? extends Runnable> jobs,
                @Nullable
                GridPredicate<? super GridRichNode>... p)
         throws GridException
Executes given closures on this projection.

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.

Specified by:
run in interface GridProjection
Throws:
GridException - 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.
Parameters:
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.
See Also:
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)

runAsync

public GridFuture<?> runAsync(GridClosureCallMode mode,
                              @Nullable
                              Collection<? extends Runnable> jobs,
                              @Nullable
                              GridPredicate<? super GridRichNode>... p)
Asynchronously executes given closures on this projection.

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.

Specified by:
runAsync in interface GridProjection
Parameters:
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.
Returns:
Non-cancellable future of this execution.
See Also:
PN, GridProjection.run(GridClosureCallMode, Collection, GridPredicate[])

withName

public GridProjection withName(@Nullable
                               String taskName)
Sets task name for the next executed task on this projection in the current thread. When task starts execution name is reset, so one name is used only once.

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!");
         }
     }
 );
 

Specified by:
withName in interface GridProjection
Parameters:
taskName - Task name.
Returns:
Grid projection (this).

withResultClosure

public GridProjection withResultClosure(@Nullable
                                        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. 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!");
         }
     }
 );
 

Specified by:
withResultClosure in interface GridProjection
Parameters:
res - Ad-hoc implementation for GridTask.result(GridJobResult, List) method.
Returns:
Grid projection (this).
See Also:
X.NO_FAILOVER

withFailoverSpi

public GridProjection withFailoverSpi(@Nullable
                                      String spiName)
Sets failover SPI for the next executed task on this projection in the current thread. When task starts execution the failover SPI set here is reset - so it is valid only for one execution from the current thread.

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!");
         }
     }
 );
 

Specified by:
withFailoverSpi in interface GridProjection
Parameters:
spiName - Failover SPI name to use.
Returns:
Grid projection (this).
See Also:
GridTaskSpis

withCheckpointSpi

public GridProjection withCheckpointSpi(@Nullable
                                        String spiName)
Sets checkpoint SPI for the next executed task on this projection in the current thread. When task starts execution the checkpoint SPI set here is reset - so it is valid only for one execution from the current thread.

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!");
         }
     }
 );
 

Specified by:
withCheckpointSpi in interface GridProjection
Parameters:
spiName - Checkpoint SPI name to use.
Returns:
Grid projection (this).
See Also:
GridTaskSpis

withLoadBalancingSpi

public GridProjection withLoadBalancingSpi(@Nullable
                                           String spiName)
Sets load balancing SPI for the next executed task on this projection in the current thread. When task starts execution the load balancing SPI set here is reset - so it is valid only for one execution from the current thread.

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!");
         }
     }
 );
 

Specified by:
withLoadBalancingSpi in interface GridProjection
Parameters:
spiName - Load balancing SPI name to use.
Returns:
Grid projection (this).
See Also:
GridTaskSpis

withTopologySpi

public GridProjection withTopologySpi(@Nullable
                                      String spiName)
Sets topology SPI for the next executed task on this projection in the current thread. When task starts execution the topology SPI set here is reset - so it is valid only for one execution from the current thread.

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!");
         }
     }
 );
 

Specified by:
withTopologySpi in interface GridProjection
Parameters:
spiName - Checkpoint SPI name to use.
Returns:
Grid projection (this).
See Also:
GridTaskSpis

call

public <R> R call(GridClosureCallMode mode,
                  @Nullable
                  Callable<R> job,
                  @Nullable
                  GridPredicate<? super GridRichNode>... p)
       throws GridException
Executes given closure on this projection.

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.

Specified by:
call in interface GridProjection
Throws:
GridException - 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.
Type Parameters:
R - Type of the closure return value.
Parameters:
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.
Returns:
Closure result. Note that in case when there are more than one result (when call mode is not 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).
See Also:
PN, GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

callAsync

public <R> GridFuture<R> callAsync(GridClosureCallMode mode,
                                   @Nullable
                                   Callable<R> job,
                                   @Nullable
                                   GridPredicate<? super GridRichNode>... p)
Asynchronously executes given closure on this projection.

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.

Specified by:
callAsync in interface GridProjection
Type Parameters:
R - Type of the closure return value.
Parameters:
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.
Returns:
Non-cancellable closure result future. Note that in case when there are more than one result (when call mode is not 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).
See Also:
PN, GridProjection.call(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

call

public <R> Collection<R> call(GridClosureCallMode mode,
                              @Nullable
                              Collection<? extends Callable<R>> jobs,
                              @Nullable
                              GridPredicate<? super GridRichNode>... p)
                   throws GridException
Executes given closures on this projection.

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.

Specified by:
call in interface GridProjection
Throws:
GridException - 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.
Parameters:
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.
Returns:
Collection of closure results. Order is undefined.
See Also:
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)

callAsync

public <R> GridFuture<Collection<R>> callAsync(GridClosureCallMode mode,
                                               @Nullable
                                               Collection<? extends Callable<R>> jobs,
                                               @Nullable
                                               GridPredicate<? super GridRichNode>... p)
Asynchronously executes given closures on this projection.

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.

Specified by:
callAsync in interface GridProjection
Type Parameters:
R - Type of the closure return value.
Parameters:
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.
Returns:
Future collection of closure results. Order is undefined.
See Also:
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)

reduce

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
Executes given jobs on this projection.

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.

Specified by:
reduce in interface GridProjection
Throws:
GridException - 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.
Type Parameters:
R1 - Closure result type.
R2 - Type of the reduced value.
Parameters:
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.
Returns:
Value produced by reducing closure. if this method is no-op, null is returned.
See Also:
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)

reduceAsync

public <R1,R2> GridFuture<R2> reduceAsync(GridClosureCallMode mode,
                                          Collection<? extends Callable<R1>> jobs,
                                          GridReducer<R1,R2> rdc,
                                          @Nullable
                                          GridPredicate<? super GridRichNode>... p)
Asynchronously executes given jobs on this projection.

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.

Specified by:
reduceAsync in interface GridProjection
Type Parameters:
R1 - Closure result type.
R2 - Type of the reduced value.
Parameters:
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.
Returns:
Future value produced by reducing closure. if this method is no-op, future with null value is returned.
See Also:
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)

send

public void send(@Nullable
                 Object msg,
                 @Nullable
                 GridPredicate<? super GridRichNode>... p)
          throws GridException
Sends given message to the nodes in this projection.

Specified by:
send in interface GridProjection
Throws:
GridException - 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.
Parameters:
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.

send

public void send(@Nullable
                 Collection<?> msgs,
                 @Nullable
                 GridPredicate<? super GridRichNode>... p)
          throws GridException
Sends given messages to the nodes in this projection.

Specified by:
send in interface GridProjection
Throws:
GridException - 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.
Parameters:
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.

node

public GridRichNode node(UUID nodeId,
                         @Nullable
                         GridPredicate<? super GridRichNode>... p)
Gets a node for given ID from this optionally filtered projection.

Specified by:
node in interface GridProjection
Parameters:
nodeId - Node ID.
p - Optional set of filtering predicates. If non provided - all nodes in this projection will be included.
Returns:
Node with given ID from this projection or null if such node does not exist in this projection.

isEmptyFor

public boolean isEmptyFor(@Nullable
                          GridPredicate<? super GridRichNode>... p)
Tests whether this optionally filtered projection has any nodes in it.

Specified by:
isEmptyFor in interface GridProjection
Parameters:
p - Optional set of filtering predicates. If non provided - all nodes in this projection will be included.
Returns:
true if at the time of calling this projection has at least one node - false otherwise.

isEmpty

public boolean isEmpty()
Tests whether this projection has any nodes in it.

Specified by:
isEmpty in interface GridProjection
Returns:
true if at the time of calling this projection has at least one node - false otherwise.

contains

public boolean contains(GridNode node,
                        @Nullable
                        GridPredicate<? super GridRichNode>... p)
Tests whether or not this optionally filtered projection contains given node.

Specified by:
contains in interface GridProjection
Parameters:
node - Node to check.
p - Optional set of filtering predicates. If non provided - all nodes in this projection will be included.
Returns:
true if this node is in this projection, false otherwise.

contains

public boolean contains(UUID nodeId,
                        @Nullable
                        GridPredicate<? super GridRichNode>... p)
Tests whether or not this optionally filtered projection contains a node with given node ID. Note that previously stored ID of the node does not necessarily point to a still valid node as that node may have left topology by now.

Specified by:
contains in interface GridProjection
Parameters:
nodeId - Node ID to check.
p - Optional set of filtering predicates. If non provided - all nodes in this projection will be included.
Returns:
true if the node with given node ID is in this projection, false otherwise.

remoteEvents

public List<GridEvent> remoteEvents(GridPredicate<? super GridEvent> pe,
                                    long timeout,
                                    @Nullable
                                    GridPredicate<? super GridRichNode>... pn)
                             throws GridException
Queries nodes in this projection for events using passed in predicate filter for event selection. This operation is distributed and hence can fail on communication layer and generally can take much longer than local event notifications. Note that this method will block until all results are received and method is complete.

Specified by:
remoteEvents in interface GridProjection
Throws:
GridException - 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.
Parameters:
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.
Returns:
Collection of grid events returned from specified nodes.
See Also:
GridProjection.remoteEventsAsync(GridPredicate, long, GridPredicate[]), PE, PN

listen

public <T> void listen(@Nullable
                       GridPredicate2<UUID,? super T>... p)
Convenient utility listening method for messages from the nodes in this projection. This method provides a convenient idiom of protocol-based message exchange with automatic listener management.

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.

Specified by:
listen in interface GridProjection
Type Parameters:
T - Type of the message.
Parameters:
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.

See Also:
GridListenActor, GridProjection.remoteListenAsync(Collection, GridPredicate2[]), GridProjection.remoteListenAsync(GridPredicate, GridPredicate2[])

executor

public ExecutorService executor(@Nullable
                                GridPredicate<? super GridRichNode>... p)
Creates new 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();
 ...
 

Specified by:
executor in interface GridProjection
Parameters:
p - 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.
Returns:
ExecutorService which delegates all calls to grid.

iterator

public Iterator<GridRichNode> iterator()

Specified by:
iterator in interface Iterable<GridRichNode>

remoteEventsAsync

public GridFuture<List<GridEvent>> remoteEventsAsync(GridPredicate<? super GridEvent> pe,
                                                     long timeout,
                                                     @Nullable
                                                     GridPredicate<? super GridRichNode>... pn)
Asynchronously queries nodes in this projection for events using passed in predicate filter for event selection. This operation is distributed and hence can fail on communication layer and generally can take much longer than local event notifications. Note that this method will not block and will return immediately with future.

Specified by:
remoteEventsAsync in interface GridProjection
Parameters:
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.
Returns:
Collection of grid events returned from specified nodes.
See Also:
GridProjection.remoteEvents(GridPredicate, long, GridPredicate[]), PE, PN

projectionForNodeIds

public GridProjection projectionForNodeIds(@Nullable
                                           Collection<UUID> nodeIds)
Creates monadic projection with a given set of node IDs out of this projection. Note that nodes not in this projection at the moment of call will excluded.

Note that name with prefix 0 selected to avoid Java naming conflict.

Specified by:
projectionForNodeIds in interface GridProjection
Parameters:
nodeIds - Collection of node IDs defining collection of nodes to create projection with.
Returns:
Monadic projection made out of nodes with given IDs.

split

public GridPair<GridProjection> split(@Nullable
                                      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. 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.

Specified by:
split in interface GridProjection
Parameters:
p - Optional set of splitting predicates.
Returns:
Pair of two monads split from the this one.

cross

public GridProjection cross(@Nullable
                            Collection<? extends GridNode> nodes)
Creates cross product of this projection and a set of nodes. Resulting projection will only have nodes from this projection that also present in given set of nodes.

Specified by:
cross in interface GridProjection
Parameters:
nodes - Set of nodes to cross by. If none provided - this projection is returned.
Returns:
Cross product projection.

cross0

public GridProjection cross0(@Nullable
                             GridRichNode... nodes)
Creates cross product of this projection and a set of nodes. Resulting projection will only have nodes from this projection that also present in given set of nodes.

Note that name with prefix 1 selected to avoid Java naming conflict.

Specified by:
cross0 in interface GridProjection
Parameters:
nodes - Set of nodes to cross by. If none provided - this projection is returned.
Returns:
Cross product projection.

call

public <R> Collection<R> call(@Nullable
                              GridMapper<Callable<R>,GridRichNode> mapper,
                              @Nullable
                              Collection<? extends Callable<R>> jobs,
                              @Nullable
                              GridPredicate<? super GridRichNode>... p)
                   throws GridException
Runs given collection of jobs producing result on this projection using given mapper to map jobs to nodes. See the description of 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.

Specified by:
call in interface GridProjection
Throws:
GridException - 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.
Type Parameters:
R - Type of job result.
Parameters:
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.
Returns:
Collection of job results.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

callAsync

public <R> GridFuture<Collection<R>> callAsync(@Nullable
                                               GridMapper<Callable<R>,GridRichNode> mapper,
                                               @Nullable
                                               Collection<? extends Callable<R>> jobs,
                                               @Nullable
                                               GridPredicate<? super GridRichNode>... p)
Runs given collection of jobs producing result on this projection using given mapper to map jobs to nodes. See the description of 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.

Specified by:
callAsync in interface GridProjection
Type Parameters:
R - Type of job result.
Parameters:
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.
Returns:
Future of job results collection.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

call

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
Runs given collection of jobs taking argument and producing result on this projection with given collection of arguments using given distribution mode.

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.

Specified by:
call in interface GridProjection
Throws:
GridException - 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.
Type Parameters:
T - Type of job argument.
R - Type of job result.
Parameters:
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.
Returns:
Collection of job results.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

callAsync

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)
Runs given collection of jobs taking argument and producing result on this projection with given collection of arguments using given distribution mode.

Note that unlike its sibling GridProjection.call(GridClosureCallMode, Collection, Collection, GridPredicate[]) this method doesn't block and immediately returns with future of execution.

Specified by:
callAsync in interface GridProjection
Type Parameters:
T - Type of job argument.
R - Type of job result.
Parameters:
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.
Returns:
Future of job results collection.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

call

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
Runs job taking argument and producing result on this projection with given collection of arguments using given distribution mode. The job is sequentially executed on every single argument from the collection so that number of actual executions for any distribution mode except 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.

Specified by:
call in interface GridProjection
Throws:
GridException - 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.
Type Parameters:
T - Type of job argument.
R - Type of job result.
Parameters:
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.
Returns:
Collection of job results.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

callAsync

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)
Runs job taking argument and producing result on this projection with given collection of arguments using given distribution mode. The job is sequentially executed on every single argument from the collection so that number of actual executions for any distribution mode except 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.

Specified by:
callAsync in interface GridProjection
Type Parameters:
T - Type of job argument.
R - Type of job result.
Parameters:
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.
Returns:
Future of job results collection.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

call

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
Runs job taking argument and producing result on this projection with given producer of arguments using given distribution mode. The job is sequentially executed on every single argument produced by the producer so that number of actual executions for any distribution mode except 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.

Specified by:
call in interface GridProjection
Throws:
GridException - 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.
Type Parameters:
T - Type of job argument.
R - Type of job result.
Parameters:
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.
Returns:
Collection of job results.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

callAsync

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)
Runs job taking argument and producing result on this projection with given producer of arguments using given distribution mode. The job is sequentially executed on every single argument produced by the producer so that number of actual executions for any distribution mode except 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.

Specified by:
callAsync in interface GridProjection
Type Parameters:
T - Type of job argument.
R - Type of job result.
Parameters:
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.
Returns:
Future of job results collection.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

run

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
Runs given collection of jobs taking argument on this projection with given collection of arguments using given distribution mode.

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.

Specified by:
run in interface GridProjection
Throws:
GridException - 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.
Type Parameters:
T - Type of job argument.
Parameters:
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.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

runAsync

public <T> GridFuture<?> runAsync(GridClosureCallMode mode,
                                  @Nullable
                                  Collection<? extends GridInClosure<? super T>> jobs,
                                  @Nullable
                                  Collection<? extends T> args,
                                  @Nullable
                                  GridPredicate<? super GridRichNode>... p)
Runs given collection of jobs taking argument on this projection with given collection of arguments using given distribution mode.

Note that unlike its sibling GridProjection.run(GridClosureCallMode, Collection, Collection, GridPredicate[]) this method doesn't block and immediately returns with future of execution.

Specified by:
runAsync in interface GridProjection
Type Parameters:
T - Type of job argument.
Parameters:
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.
Returns:
Future for jobs' execution.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

run

public <T> void run(GridClosureCallMode mode,
                    @Nullable
                    GridInClosure<? super T> job,
                    Collection<? extends T> args,
                    @Nullable
                    GridPredicate<? super GridRichNode>... p)
         throws GridException
Runs job taking argument on this projection with given collection of arguments using given distribution mode. The job is sequentially executed on every single argument from the collection so that number of actual executions for any distribution mode except 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.

Specified by:
run in interface GridProjection
Throws:
GridException - 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.
Type Parameters:
T - Type of job argument.
Parameters:
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.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

runAsync

public <T> GridFuture<?> runAsync(GridClosureCallMode mode,
                                  @Nullable
                                  GridInClosure<? super T> job,
                                  @Nullable
                                  Collection<? extends T> args,
                                  @Nullable
                                  GridPredicate<? super GridRichNode>... p)
Runs job taking argument on this projection with given collection of arguments using given distribution mode. The job is sequentially executed on every single argument from the collection so that number of actual executions for any distribution mode except 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.

Specified by:
runAsync in interface GridProjection
Type Parameters:
T - Type of job argument.
Parameters:
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.
Returns:
Future for job execution.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

run

public <T> void run(GridClosureCallMode mode,
                    @Nullable
                    GridInClosure<? super T> job,
                    @Nullable
                    GridOutClosure<T> pdc,
                    int cnt,
                    @Nullable
                    GridPredicate<? super GridRichNode>... p)
         throws GridException
Runs job taking argument on this projection with given producer of arguments using given distribution mode. The job is sequentially executed on every single argument produced by the producer so that number of actual executions for any distribution mode except 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.

Specified by:
run in interface GridProjection
Throws:
GridException - 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.
Type Parameters:
T - Type of job argument.
Parameters:
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.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

runAsync

public <T> GridFuture<?> runAsync(GridClosureCallMode mode,
                                  @Nullable
                                  GridInClosure<? super T> job,
                                  @Nullable
                                  GridOutClosure<T> pdc,
                                  int cnt,
                                  @Nullable
                                  GridPredicate<? super GridRichNode>... p)
Runs job taking argument on this projection with given producer of arguments using given distribution mode. The job is sequentially executed on every single argument produced by the producer so that number of actual executions for any distribution mode except 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.

Specified by:
runAsync in interface GridProjection
Type Parameters:
T - Type of job argument.
Parameters:
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.
Returns:
Future for job execution.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

reduce

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

Specified by:
reduce in interface GridProjection
Throws:
GridException - 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.
Type Parameters:
R1 - Type of job result.
R2 - Type of reduced result.
T - Type of job argument.
Parameters:
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.
Returns:
Result reduced from job results with given reducer. if this method is no-op, null is returned.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

reduceAsync

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)
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. See 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.

Specified by:
reduceAsync in interface GridProjection
Type Parameters:
R1 - Type of job result.
R2 - Type of reduced result.
T - Type of job argument.
Parameters:
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.
Returns:
Future of reduced result. if this method is no-op, future with null value is returned.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

reduce

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
Runs job taking argument and producing result on this projection with given collection of arguments using given distribution mode. The job is sequentially executed on every single argument from the collection so that number of actual executions for any distribution mode except 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.

Specified by:
reduce in interface GridProjection
Throws:
GridException - 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.
Type Parameters:
R1 - Type of job result.
R2 - Type of reduced result.
T - Type of job argument.
Parameters:
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.
Returns:
Result reduced from job results with given reducer. if this method is no-op, null is returned.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

reduceAsync

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)
Runs job taking argument and producing result on this projection with given collection of arguments using given distribution mode. The job is sequentially executed on every single argument from the collection so that number of actual executions for any distribution mode except 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.

Specified by:
reduceAsync in interface GridProjection
Type Parameters:
R1 - Type of job result.
R2 - Type of reduced result.
T - Type of job argument.
Parameters:
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.
Returns:
Future of reduced result. if this method is no-op, future with null value is returned.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

reduce

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
Runs job taking argument and producing result on this projection with given producer of arguments using given distribution mode. The job is sequentially executed on every single argument produced by the producer so that number of actual executions for any distribution mode except 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.

Specified by:
reduce in interface GridProjection
Throws:
GridException - 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.
Type Parameters:
R1 - Type of job result.
R2 - Type of reduced result.
T - Type of job argument.
Parameters:
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.
Returns:
Result reduced from job results with given reducer. if this method is no-op, null is returned.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

reduceAsync

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)
Runs job taking argument and producing result on this projection with given producer of arguments using given distribution mode. The job is sequentially executed on every single argument produced by the producer so that number of actual executions for any distribution mode except 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.

Specified by:
reduceAsync in interface GridProjection
Type Parameters:
R1 - Type of job result.
R2 - Type of reduced result.
T - Type of job argument.
Parameters:
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.
Returns:
Future of reduced result. if this method is no-op, future with null value is returned.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

mapreduce

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

Specified by:
mapreduce in interface GridProjection
Throws:
GridException - 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.
Type Parameters:
R1 - Type of job result.
R2 - Type of reduced result.
T - Type of job argument.
Parameters:
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.
Returns:
Result reduced from job results with given reducer. if this method is no-op, null is returned.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

mapreduceAsync

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)
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. See 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.

Specified by:
mapreduceAsync in interface GridProjection
Type Parameters:
R1 - Type of job result.
R2 - Type of reduced result.
T - Type of job argument.
Parameters:
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.
Returns:
Future of reduced result. if this method is no-op, future with null value is returned.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

mapreduce

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
Runs job taking argument and producing result on this projection with given collection of arguments using given mapper to map job executions to nodes. The job is sequentially executed on every single argument from the collection so that number of actual executions for any distribution mode except 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.

Specified by:
mapreduce in interface GridProjection
Throws:
GridException - 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.
Type Parameters:
R1 - Type of job result.
R2 - Type of reduced result.
T - Type of job argument.
Parameters:
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.
Returns:
Result reduced from job results with given reducer. if this method is no-op, null is returned.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

mapreduceAsync

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)
Runs job taking argument and producing result on this projection with given collection of arguments using given mapper to map job executions to nodes. The job is sequentially executed on every single argument from the collection so that number of actual executions for any distribution mode except 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.

Specified by:
mapreduceAsync in interface GridProjection
Type Parameters:
R1 - Type of job result.
R2 - Type of reduced result.
T - Type of job argument.
Parameters:
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.
Returns:
Future of reduced result. if this method is no-op, future with null value is returned.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

mapreduce

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
Runs job taking argument and producing result on this projection with given producer of arguments using given mapper to map job executions to nodes. The job is sequentially executed on every single argument produced by the producer so that number of actual executions for any distribution mode except 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.

Specified by:
mapreduce in interface GridProjection
Throws:
GridException - 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.
Type Parameters:
R1 - Type of job result.
R2 - Type of reduced result.
T - Type of job argument.
Parameters:
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.
Returns:
Result reduced from job results with given reducer. if this method is no-op, null is returned.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

mapreduceAsync

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)
Runs job taking argument and producing result on this projection with given producer of arguments using given mapper to map job executions to nodes. The job is sequentially executed on every single argument produced by the producer so that number of actual executions for any distribution mode except 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.

Specified by:
mapreduceAsync in interface GridProjection
Type Parameters:
R1 - Type of job result.
R2 - Type of reduced result.
T - Type of job argument.
Parameters:
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.
Returns:
Future of reduced result. if this method is no-op, future with null value is returned.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

run

public <T> void run(GridClosureCallMode mode,
                    @Nullable
                    GridInClosure<? super T> job,
                    @Nullable
                    T arg,
                    @Nullable
                    GridPredicate<? super GridRichNode>... p)
         throws GridException
Runs job that doesn't produce any result with given argument on this projection using given distribution mode. Note that unlike its sibling GridProjection.callAsync(GridClosureCallMode, GridClosure, Object, GridPredicate[]) this method will block until execution is complete, timeout expires, execution is cancelled or exception is thrown.

Specified by:
run in interface GridProjection
Throws:
GridException - 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.
Type Parameters:
T - Type of job argument.
Parameters:
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.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

runAsync

public <T> GridFuture<?> runAsync(GridClosureCallMode mode,
                                  @Nullable
                                  GridInClosure<? super T> job,
                                  @Nullable
                                  T arg,
                                  @Nullable
                                  GridPredicate<? super GridRichNode>... p)
Runs job that doesn't produce any result with given argument on this projection using given distribution mode. Note that unlike its sibling GridProjection.run(GridClosureCallMode, GridInClosure, Object, GridPredicate[]) this method doesn't block and immediately returns with future of execution.

Specified by:
runAsync in interface GridProjection
Type Parameters:
T - Type of job argument.
Parameters:
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.
Returns:
Future for job execution.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

call

public <R,T> R call(GridClosureCallMode mode,
                    @Nullable
                    GridClosure<? super T,R> job,
                    @Nullable
                    T arg,
                    @Nullable
                    GridPredicate<? super GridRichNode>... p)
       throws GridException
Runs job producing result with given argument on this projection using given distribution mode. Note that unlike its sibling GridProjection.callAsync(GridClosureCallMode, GridClosure, Object, GridPredicate[]) this method will block until execution is complete, timeout expires, execution is cancelled or exception is thrown.

Specified by:
call in interface GridProjection
Throws:
GridException - 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.
Type Parameters:
R - Type of job result.
T - Type of job argument.
Parameters:
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.
Returns:
Closure result. Note that in case when there are more than one result (when call mode is not 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).
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

callAsync

public <R,T> GridFuture<R> callAsync(GridClosureCallMode mode,
                                     @Nullable
                                     GridClosure<? super T,R> job,
                                     @Nullable
                                     T arg,
                                     @Nullable
                                     GridPredicate<? super GridRichNode>... p)
Runs job producing result with given argument on this projection using given distribution mode. Note that unlike its sibling GridProjection.call(GridClosureCallMode, GridClosure, Object, GridPredicate[]) this method doesn't block and immediately returns with future of execution.

Specified by:
callAsync in interface GridProjection
Type Parameters:
R - Type of job result.
T - Type of job argument.
Parameters:
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.
Returns:
Non-cancellable closure result future. Note that in case when there are more than one result (when call mode is not 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).
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

runAsync

public GridFuture<?> runAsync(@Nullable
                              GridMapper<Runnable,GridRichNode> mapper,
                              @Nullable
                              Collection<? extends Runnable> jobs,
                              @Nullable
                              GridPredicate<? super GridRichNode>... p)
Asynchronously executes collections of closures using given mapper on this projection.

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.

Specified by:
runAsync in interface GridProjection
Parameters:
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.
Returns:
Non-cancellable future of this execution.
See Also:
GridProjection.callAsync(GridClosureCallMode, Callable, GridPredicate[]), GridProjection.withCheckpointSpi(String), GridProjection.withFailoverSpi(String), GridProjection.withName(String), GridProjection.withResultClosure(GridClosure2X), GridProjection.withTopologySpi(String)

mapKeysToNodes

public <K> Map<GridRichNode,Collection<K>> mapKeysToNodes(String cacheName,
                                                          @Nullable
                                                          Collection<? extends K> keys)
                                               throws GridException
This method provides ability to detect which cache keys are mapped to which nodes on cache instance with given name. Use it to determine which nodes are storing which keys prior to sending jobs that access these keys.

This method works as following:

  • For local caches it returns only local node mapped to all keys.
  • For fully replicated caches, GridCacheAffinity is used to determine which keys are mapped to which groups of nodes.
  • For partitioned caches, the returned map represents node-to-key affinity.

Specified by:
mapKeysToNodes in interface GridProjection
Throws:
GridException - If failed to map cache keys.
Parameters:
cacheName - Cache name, if null, then default cache instance is used.
keys - Cache keys to map to nodes.
Returns:
Map of node IDs to cache keys.

mapKeysToNodes

public <K> Map<GridRichNode,Collection<K>> mapKeysToNodes(@Nullable
                                                          Collection<? extends K> keys)
                                               throws GridException
This method provides ability to detect which cache keys are mapped to which nodes on default unnamed cache instance. Use it to determine which nodes are storing which keys prior to sending jobs that access these keys.

This method works as following:

  • For local caches it returns only local node mapped to all keys.
  • For fully replicated caches GridCacheAffinity is used to determine which keys are mapped to which nodes.
  • For partitioned caches, the returned map represents node-to-key affinity.

Specified by:
mapKeysToNodes in interface GridProjection
Throws:
GridException - If failed to map cache keys.
Parameters:
keys - Cache keys to map to nodes.
Returns:
Map of nodes to cache keys.

mapKeyToNode

public <K> GridRichNode mapKeyToNode(K key)
                          throws GridException
This method provides ability to detect which keys are mapped to which nodes on default unnamed cache instance. Use it to determine which nodes are storing which keys prior to sending jobs that access these keys.

This method works as following:

  • For local caches it returns only local node ID.
  • For fully replicated caches first node ID returned by GridCacheAffinity is returned.
  • For partitioned caches, the returned node ID is the primary node for the key.

Specified by:
mapKeyToNode in interface GridProjection
Throws:
GridException - If failed to map key.
Parameters:
key - Cache key to map to a node.
Returns:
Primary node for the key or null if cache with default name is not present in the grid.

mapKeyToNode

public <K> GridRichNode mapKeyToNode(String cacheName,
                                     K key)
                          throws GridException
This method provides ability to detect which cache keys are mapped to which nodes on cache instance with given name. Use it to determine which nodes are storing which keys prior to sending jobs that access these keys.

This method works as following:

  • For local caches it returns only local node ID.
  • For fully replicated caches first node ID returned by GridCacheAffinity is returned.
  • For partitioned caches, the returned node ID is the primary node for the key.

Specified by:
mapKeyToNode in interface GridProjection
Throws:
GridException - If failed to map key.
Parameters:
cacheName - Cache name, if null, then default cache instance is used.
key - Cache key to map to a node.
Returns:
Primary node for the key or null if cache with given name is not present in the grid.

startNodes

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
Starts one or more nodes on remote host(s) defined by file with host specifications (one specification per line).

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.

Specified by:
startNodes in interface GridProjection
Throws:
GridException - In case of error.
Parameters:
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.
Returns:
Collection of tuples, each contains host name, result (success of failure) and error message (if any).

startNodes

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
Starts one or more nodes on remote host(s) defined by collection of host specifications.

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.

Specified by:
startNodes in interface GridProjection
Throws:
GridException - In case of error.
Parameters:
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.
Returns:
Collection of tuples, each contains host name, result (success of failure) and error message (if any).

stopNodes

public void stopNodes(@Nullable
                      GridPredicate<? super GridRichNode>... p)
               throws GridException
Stops nodes satisfying optional set of predicates.

Specified by:
stopNodes in interface GridProjection
Throws:
GridException - In case of error.
Parameters:
p - Optional set of filtering predicates. If none provided - all nodes in this projection will be stopped.

stopNodes

public void stopNodes(UUID id,
                      @Nullable
                      UUID... ids)
               throws GridException
Stops nodes defined by provided IDs.

Specified by:
stopNodes in interface GridProjection
Throws:
GridException - In case of error.
Parameters:
id - ID defining node to stop.
ids - IDs defining nodes to stop.

stopNodes

public void stopNodes(Collection<UUID> ids)
               throws GridException
Stops nodes defined by provided IDs.

Specified by:
stopNodes in interface GridProjection
Throws:
GridException - In case of error.
Parameters:
ids - IDs defining nodes to stop.

restartNodes

public void restartNodes(@Nullable
                         GridPredicate<? super GridRichNode>... p)
                  throws GridException
Restarts nodes satisfying optional set of predicates.

Specified by:
restartNodes in interface GridProjection
Throws:
GridException - In case of error.
Parameters:
p - Optional set of filtering predicates. If none provided - all nodes in this projection will be restarted.

restartNodes

public void restartNodes(UUID id,
                         @Nullable
                         UUID... ids)
                  throws GridException
Restarts nodes defined by provided IDs.

Specified by:
restartNodes in interface GridProjection
Throws:
GridException - In case of error.
Parameters:
id - ID defining node to restart.
ids - IDs defining nodes to restart.

restartNodes

public void restartNodes(Collection<UUID> ids)
                  throws GridException
Restarts nodes defined by provided IDs.

Specified by:
restartNodes in interface GridProjection
Throws:
GridException - In case of error.
Parameters:
ids - IDs defining nodes to restart.

toString

public String toString()

Overrides:
toString in class Object

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException

Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException

Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

GridGain™ 3.6.0e
Enterprise Edition

GridGain - Real Time Big Data
Enterprise Edition, ver. 3.6.0e.13012012
2012 Copyright © GridGain Systems
Follow us:   Follow GridGain on Github Follow GridGain on Facebook Join GridGain User Group Follow GridGain on Twitter Follow GridGain on YouTube