GridGain™ 3.6.0e
Enterprise Edition

org.gridgain.grid
Interface GridProjection

All Superinterfaces:
GridMetadataAware, Iterable<GridRichNode>, Serializable
All Known Subinterfaces:
Grid, GridRichNode
All Known Implementing Classes:
GridSpringBean

public interface GridProjection
extends Iterable<GridRichNode>, GridMetadataAware

Defines grid projection interface and monadic set of operations on a set of grid nodes.

All main grid entities such as grid and a node instances can be viewed as collection of grid nodes (in case of the grid node this collection consist of only one element). As such they all share the same set of operations that can be performed on a set grid nodes. These operations are defined in GridProjection interface and called monadic as they are equally defined on any arbitrary set of nodes.

Nullable and Monads

Many methods in this interface accepts nullable parameters. Although it may seem counter intuitive for some of them - it is done to promote monadic usage of this interface. Java doesn't natively support concepts like Option in Scala and returning, accepting, and properly handling null values is Java's way to support such monadic invocations.

All methods that accept null values (for monadic purposes) will gracefully handle it by either returning a finished future, or empty collection, null value, or combination of the above. Most method calls therefore can be chained without an explicit checks for nulls.

The downside of this approach that inadvertent errors of passing null will not result in NullPointerException and may be harder to catch.

Wiki & Forum:


Wiki
Forum

 

Method Summary
<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.
<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> 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.
 boolean contains(GridNode node, GridPredicate<? super GridRichNode>... p)
          Tests whether or not this optionally filtered projection contains given node.
 boolean contains(UUID nid, GridPredicate<? super GridRichNode>... p)
          Tests whether or not this optionally filtered projection contains a node with given node ID.
 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.
 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.
<T> void
listen(GridPredicate2<UUID,? super T>... p)
          Convenient utility listening method for messages from the nodes in this projection.
<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.
 Collection<GridProjection> neighborhood()
          Gets collections of neighbors from this projection.
 GridRichNode node(UUID nid, 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.
 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.
 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> ids)
          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.
<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 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.
<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.
 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.
 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.
 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).
 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.
 GridRichNode youngest()
          Gets the youngest node in this topology.
 GridRichNode youngestx()
          Gets the youngest node in this topology.
 
Methods inherited from interface java.lang.Iterable
iterator
 
Methods inherited from interface org.gridgain.grid.GridMetadataAware
addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, putMetaIfAbsent, removeMeta, removeMeta, replaceMeta
 

Method Detail

runOptimistic

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.

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

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

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

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.

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

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

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

void affinityRun(String cacheName,
                 @Nullable
                 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.

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

affinityRun

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.

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

GridFuture<?> affinityRunAsync(String cacheName,
                               @Nullable
                               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.

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

affinityRunAsync

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.

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

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

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

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

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

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

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

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

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

projectionMetrics

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

Throws:
GridException - If projection is empty.
Returns:
Grid project metrics snapshot.
See Also:
GridNode.metrics()

neighborhood

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.

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

youngest

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

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

oldest

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

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

random

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

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

youngestx

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

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

oldestx

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

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

randomx

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

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

hosts

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.

Returns:
Number of unique hosts (always >= 1).

cpus

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

Returns:
Total number of CPUs (always >= 1).

dynamic

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

Returns:
Whether or not projection is dynamic.

size

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.

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

hasRemoteNodes

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.

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

hasLocalNode

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.

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

gridify

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

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

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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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.

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

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

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

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

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

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

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.

predicate

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.

Returns:
Predicate that defines a subset of nodes for this projection.

merge

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

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.

executeSync

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

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

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

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

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

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

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

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

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

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

<T,R> GridTaskFuture<R> execute(String taskName,
                                @Nullable
                                T arg,
                                @Nullable
                                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.

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

<T,R> GridTaskFuture<R> execute(String taskName,
                                @Nullable
                                T arg,
                                long timeout,
                                @Nullable
                                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.

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).
timeout - Optional timeout for this task execution in milliseconds. If 0, then 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

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

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

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

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

<T,R> GridTaskFuture<R> execute(Class<? extends GridTask<T,R>> taskCls,
                                @Nullable
                                T arg,
                                @Nullable
                                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.

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

<T,R> GridTaskFuture<R> execute(Class<? extends GridTask<T,R>> taskCls,
                                @Nullable
                                T arg,
                                long timeout,
                                @Nullable
                                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.

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.
lsnr - Optional grid task result listener that will be called once the execution is completed (successfully or not).
timeout - Optional timeout for this task execution in milliseconds. If 0, then 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.

execute

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

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

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

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

<T,R> GridTaskFuture<R> execute(GridTask<T,R> task,
                                @Nullable
                                T arg,
                                @Nullable
                                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.

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

<T,R> GridTaskFuture<R> execute(GridTask<T,R> task,
                                @Nullable
                                T arg,
                                long timeout,
                                @Nullable
                                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.

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).
timeout - Optional timeout for this task execution in milliseconds. If 0, then 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.

mapreduce

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

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

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

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)

nodes

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.

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.

nodes

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.

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[])

projectionForNodes

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.

Parameters:
nodes - Collection of nodes to create a projection from.
Returns:
Monadic projection with given nodes.

projectionForNodes

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.

Parameters:
nodes - Collection of nodes to create a projection from.
Returns:
Monadic projection with given nodes.

projectionForNodeIds

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.

Parameters:
ids - Collection of node IDs defining collection of nodes to create projection with.
Returns:
Monadic projection made out of nodes with given IDs.

projectionForNodeIds

GridProjection projectionForNodeIds(@Nullable
                                    Collection<UUID> ids)
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.

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

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.

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

projectionForAttribute

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.

Parameters:
n - Name of the attribute.
v - Optional attribute value to match.
Returns:
Monadic projection.

projectionForCaches

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

Parameters:
cacheName - Cache name.
cacheNames - Cache names.
Returns:
Monadic projection.

split

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.

Parameters:
p - Optional set of splitting predicates.
Returns:
Pair of two monads split from the this one.

cross

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.

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

cross0

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.

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

cross

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.

Parameters:
prjs - Other projections. If none provided - this projection is returned.
Returns:
Cross product projection.

topologyHash

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.

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

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

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

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

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.

grid

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

Returns:
Grid instance associated with this projection.

parent

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

Returns:
Parent projection of null.

withName

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

Parameters:
taskName - Task name.
Returns:
Grid projection (this).

withResultClosure

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

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

withFailoverSpi

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

Parameters:
spiName - Failover SPI name to use.
Returns:
Grid projection (this).
See Also:
GridTaskSpis

withCheckpointSpi

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

Parameters:
spiName - Checkpoint SPI name to use.
Returns:
Grid projection (this).
See Also:
GridTaskSpis

withLoadBalancingSpi

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

Parameters:
spiName - Load balancing SPI name to use.
Returns:
Grid projection (this).
See Also:
GridTaskSpis

withTopologySpi

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

Parameters:
spiName - Checkpoint SPI name to use.
Returns:
Grid projection (this).
See Also:
GridTaskSpis

run

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.

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)

runAsync

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.

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)

run

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.

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

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.

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

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.

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

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.

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[])

call

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

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

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

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

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

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

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

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

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

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

<R1,R2> GridFuture<R2> reduceAsync(GridClosureCallMode mode,
                                   @Nullable
                                   Collection<? extends Callable<R1>> jobs,
                                   @Nullable
                                   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.

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

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

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

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

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

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

Parameters:
nid - 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.

daemonNodes

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.

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.

nodeId8

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.

Parameters:
id8 - node ID8.
Returns:
Collection of nodes matching this ID8. Empty collection is returned when no nodes match given ID8.

isEmptyFor

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

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

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

Returns:
true if at the time of calling this projection has at least one node - false otherwise.

contains

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

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

boolean contains(UUID nid,
                 @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.

Parameters:
nid - 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

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.

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.
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.
timeout - Maximum time to wait for result, 0 to wait forever.
Returns:
Collection of grid events returned from specified nodes.
See Also:
GridProjection.remoteEventsAsync(GridPredicate, long, GridPredicate[]), PE, PN

remoteEventsAsync

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.

Parameters:
pe - Predicate filter used to query events on remote nodes.
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.
timeout - Maximum time to wait for result, 0 to wait forever.
Returns:
Collection of grid events returned from specified nodes.
See Also:
GridProjection.remoteEvents(GridPredicate, long, GridPredicate[]), PE, PN

listen

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

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[])

remoteListenAsync

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

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

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

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

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

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[])

executor

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

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.

call

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

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

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

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

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

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.
p - Optional set of predicates filtering execution topology. If not provided - all nodes in this projection will be included.
args - Jobs' arguments (closure free variables).
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

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

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.
p - Optional set of predicates filtering execution topology. If not provided - all nodes in this projection will be included.
args - Jobs' arguments (closure free variables).
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

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

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.
p - Optional set of predicates filtering execution topology. If not provided - all nodes in this projection will be included.
args - Job arguments (closure free variables).
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

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

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.
p - Optional set of predicates filtering execution topology. If not provided - all nodes in this projection will be included.
args - Job arguments (closure free variables).
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

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

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

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

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

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

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

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

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

<T> void run(GridClosureCallMode mode,
             @Nullable
             GridInClosure<? super T> job,
             @Nullable
             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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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)

mapKeysToNodes

@GridEnterpriseFeature(value="Data affinity outside of GridCache is enterprise-only feature.")
<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.

Throws:
GridException - If failed to map cache keys.
Parameters:
keys - Cache keys to map to nodes.
Returns:
Map of nodes to cache keys.

mapKeysToNodes

@GridEnterpriseFeature(value="Data affinity outside of GridCache is enterprise-only feature.")
<K> Map<GridRichNode,Collection<K>> mapKeysToNodes(@Nullable
                                                                              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.

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.

mapKeyToNode

@GridEnterpriseFeature(value="Data affinity outside of GridCache is enterprise-only feature.")
@Nullable
<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.

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

@GridEnterpriseFeature(value="Data affinity outside of GridCache is enterprise-only feature.")
@Nullable
<K> GridRichNode mapKeyToNode(@Nullable
                                                                  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.

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

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.

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

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.

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

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

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

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

Throws:
GridException - In case of error.
Parameters:
id - ID defining node to stop.
ids - IDs defining nodes to stop.

stopNodes

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

Throws:
GridException - In case of error.
Parameters:
ids - IDs defining nodes to stop.

restartNodes

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

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

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

Throws:
GridException - In case of error.
Parameters:
id - ID defining node to restart.
ids - IDs defining nodes to restart.

restartNodes

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

Throws:
GridException - In case of error.
Parameters:
ids - IDs defining nodes to restart.

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