org.openspaces.core.executor.support
Class SumTask<T extends Number,R extends Number>
java.lang.Object
org.openspaces.core.executor.support.SimpleDelegatingTask<T>
org.openspaces.core.executor.support.AbstractDelegatingDistributedTask<T,R>
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 distrubted task that accepts a Task
to delegate
the actual execution to and implements the reduce(java.util.List)
operation.
By defualt, 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 optioanl AsyncResultFilter
.
- Author:
- kimchy
- See Also:
SumReducer
,
Serialized Form
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. |
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 |
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
ignoreExceptions
public SumTask ignoreExceptions()
- Sests 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
Copyright © GigaSpaces.