GridGain™ 3.6.0e
Enterprise Edition

org.gridgain.grid.lang
Class GridOutClosure<T>

java.lang.Object
  extended by org.gridgain.grid.lang.GridMetadataAwareAdapter
      extended by org.gridgain.grid.lang.GridLambdaAdapter
          extended by org.gridgain.grid.lang.GridOutClosure<T>
Type Parameters:
T - Type of return value from this closure.
All Implemented Interfaces:
Serializable, Cloneable, Callable<T>, GridJob, GridMetadataAware, GridPeerDeployAware, GridLambda
Direct Known Subclasses:
CO, GridEither, GridOutClosureX, GridReducer, GridReducer2, GridReducer3

public abstract class GridOutClosure<T>
extends GridLambdaAdapter
implements Callable<T>, GridJob

Defines a convenient side-effect only factory closure. This closure takes no parameters and returns instance of given type every time its GridOutClosure.apply() method is called. Most implementations will return a new instance every time, however, there's no requirement for that. Note also that factory closure doesn't have free variables (i.e. it has void as its fre variable).

Thread Safety

Note that this interface does not impose or assume any specific thread-safety by its implementations. Each implementation can elect what type of thread-safety it provides, if any.

Note that this class implements GridJob interface for convenience and can be used in GridTask implementations directly, if needed, as an alternative to GridJobAdapterEx.

Wiki & Forum:


Wiki
Forum

See Also:
GridFunc, Serialized Form
 

Constructor Summary
GridOutClosure()
           
 
Method Summary
<A> GridOutClosure<A>
andThen(GridClosure<T,A> c)
          Gets closure that applies given closure over the result of this closure.
 GridAbsClosure andThen(GridInClosure<T> c)
          Gets closure that applies given closure over the result of this closure.
abstract  T apply()
          Factory closure body.
 T call()
          Delegates to GridOutClosure.apply() method.
 void cancel()
          Does nothing by default.
 Object execute()
          Delegates to GridOutClosure.apply() method.
<E> GridClosure<E,T>
uncurry()
          Gets closure that ignores its argument and returns the same value as this out closure.
<E1,E2> GridClosure2<E1,E2,T>
uncurry2()
          Gets closure that ignores its arguments and returns the same value as this out closure.
<E1,E2,E3> GridClosure3<E1,E2,E3,T>
uncurry3()
          Gets closure that ignores its arguments and returns the same value as this out closure.
 
Methods inherited from class org.gridgain.grid.lang.GridLambdaAdapter
classLoader, deployClass, peerDeployLike, withMeta
 
Methods inherited from class org.gridgain.grid.lang.GridMetadataAwareAdapter
addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, clone, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, putMetaIfAbsent, readExternalMeta, removeMeta, removeMeta, replaceMeta, writeExternalMeta
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.gridgain.grid.GridMetadataAware
addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, putMetaIfAbsent, removeMeta, removeMeta, replaceMeta
 

Constructor Detail

GridOutClosure

public GridOutClosure()
Method Detail

apply

public abstract T apply()
Factory closure body.

Returns:
Element.

call

public final T call()
Delegates to GridOutClosure.apply() method.

Specified by:
call in interface Callable<T>

cancel

public void cancel()
Does nothing by default. Child classes may override this method to provide implementation-specific cancellation logic.

Note that this method is here only to support GridJob interface and only makes sense whenever this class is used as grid job or is executed via any of GridProjection methods.

This method is called when when system detects that completion of this job can no longer alter the overall outcome (for example, when parent task has already reduced the results). Job is also cancelled when GridFuture.cancel() is called.

Note that job cancellation is only a hint, and just like with Thread.interrupt() method, it is really up to the actual job instance to gracefully finish execution and exit.

Specified by:
cancel in interface GridJob

uncurry

public <E> GridClosure<E,T> uncurry()
Gets closure that ignores its argument and returns the same value as this out closure.

Type Parameters:
E - Type of ignore argument.
Returns:
Closure that ignores its argument and returns the same value as this out closure.

uncurry2

public <E1,E2> GridClosure2<E1,E2,T> uncurry2()
Gets closure that ignores its arguments and returns the same value as this out closure.

Type Parameters:
E1 - Type of 1st ignore argument.
E2 - Type of 2nd ignore argument.
Returns:
Closure that ignores its arguments and returns the same value as this out closure.

uncurry3

public <E1,E2,E3> GridClosure3<E1,E2,E3,T> uncurry3()
Gets closure that ignores its arguments and returns the same value as this out closure.

Type Parameters:
E1 - Type of 1st ignore argument.
E2 - Type of 2nd ignore argument.
E3 - Type of 3rd ignore argument.
Returns:
Closure that ignores its arguments and returns the same value as this out closure.

execute

public final Object execute()
                     throws GridException
Delegates to GridOutClosure.apply() method.

Executes this job.

Specified by:
execute in interface GridJob
Throws:
GridException - If job execution caused an exception. This exception will be returned in GridJobResult.getException() method passed into GridTask.result(GridJobResult, List) method into task on caller node. If execution produces a RuntimeException or Error, then it will be wrapped into GridException.
Returns:
Job execution result (possibly null). This result will be returned in GridJobResult.getData() method passed into GridTask.result(GridJobResult, List) method into task on caller node.

andThen

public <A> GridOutClosure<A> andThen(GridClosure<T,A> c)
Gets closure that applies given closure over the result of this closure.

Type Parameters:
A - Return type of new closure.
Parameters:
c - Closure.
Returns:
New closure.

andThen

public GridAbsClosure andThen(GridInClosure<T> c)
Gets closure that applies given closure over the result of this closure.

Parameters:
c - Closure.
Returns:
New closure.

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