GigaSpaces XAP 9.7.2 API

org.openspaces.core.executor.support
Class SumTask<T extends Number,R extends Number>

java.lang.Object
  extended by org.openspaces.core.executor.support.SimpleDelegatingTask<T>
      extended by org.openspaces.core.executor.support.AbstractDelegatingDistributedTask<T,R>
          extended by org.openspaces.core.executor.support.SumTask<T,R>
All Implemented Interfaces:
AsyncResultFilter<T>, AsyncResultsReducer<T,R>, Externalizable, Serializable, DistributedTask<T,R>, DelegatingTask<T>, Task<T>, TaskRoutingProvider

public class SumTask<T extends Number,R extends Number>
extends AbstractDelegatingDistributedTask<T,R>
implements Externalizable

A sum distrubuted task that accepts a Task to delegate the actual execution to and implements the reduce(java.util.List) operation.

By default, throws an exception if one of the execution fails. ignoreExceptions() can be called to only perform the operation on all the successful operations, ignoring the failed ones.

Can accept an optional AsyncResultFilter.

Author:
kimchy
See Also:
SumReducer, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.gigaspaces.async.AsyncResultFilter
AsyncResultFilter.Decision
 
Constructor Summary
SumTask()
           
SumTask(Class<R> reduceType, Task<T> task)
          Constructs a new sum distributed task that delegates the actual execution to th provided task.
SumTask(Class<R> reduceType, Task<T> task, AsyncResultFilter<T> filter)
          Constructs a new sum distributed task that delegates the actual execution to th provided task.
 
Method Summary
 SumTask ignoreExceptions()
          Sets the reduce(java.util.List) to ignore failed invocations.
 void readExternal(ObjectInput in)
           
 R reduce(List<AsyncResult<T>> results)
          Performs the actual sum operation by delegating to its internal SumReducer.
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.openspaces.core.executor.support.AbstractDelegatingDistributedTask
_readExternal, _writeExternal, getFilter, onResult
 
Methods inherited from class org.openspaces.core.executor.support.SimpleDelegatingTask
execute, getDelegatedTask, getRouting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openspaces.core.executor.Task
execute
 

Constructor Detail

SumTask

public SumTask()

SumTask

public SumTask(Class<R> reduceType,
               Task<T> task)
        throws IllegalArgumentException
Constructs a new sum distributed task that delegates the actual execution to th provided task.

Parameters:
task - The task to delegate the execution to.
Throws:
IllegalArgumentException

SumTask

public SumTask(Class<R> reduceType,
               Task<T> task,
               AsyncResultFilter<T> filter)
        throws IllegalArgumentException
Constructs a new sum distributed task that delegates the actual execution to th provided task.

Parameters:
task - The task to delegate the execution to.
filter - A result filter to be called for each result
Throws:
IllegalArgumentException
Method Detail

ignoreExceptions

public SumTask ignoreExceptions()
Sets the reduce(java.util.List) to ignore failed invocations.


reduce

public R reduce(List<AsyncResult<T>> results)
                        throws Exception
Performs the actual sum operation by delegating to its internal SumReducer.

Specified by:
reduce in interface AsyncResultsReducer<T extends Number,R extends Number>
Throws:
Exception

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

GigaSpaces XAP 9.7.2 API

Copyright © GigaSpaces.