GigaSpaces XAP 7.0 API

org.openspaces.core.executor.support
Class AvgTask<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.AvgTask<T,R>
All Implemented Interfaces:
AsyncResultFilter<T>, AsyncResultsReducer<T,R>, Externalizable, Serializable, DistributedTask<T,R>, DelegatingTask<T>, Task<T>, TaskRoutingProvider

public class AvgTask<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

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.gigaspaces.async.AsyncResultFilter
AsyncResultFilter.Decision
 
Constructor Summary
AvgTask()
          Here for externalizable.
AvgTask(Class<R> reduceType, Task<T> task)
          Constructs a new sum distributed task that delegates the actual execution to th provided task.
AvgTask(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
 AvgTask ignoreExceptions()
          Sests 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

AvgTask

public AvgTask()
Here for externalizable.


AvgTask

public AvgTask(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

AvgTask

public AvgTask(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 AvgTask 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

GigaSpaces XAP 7.0 API

Copyright © GigaSpaces.