GigaSpaces XAP 8.0 API

org.openspaces.core.executor.juc
Class CallableDistributedTaskAdapter<T extends Serializable,R>

java.lang.Object
  extended by org.openspaces.core.executor.juc.CallableTaskAdapter<T>
      extended by org.openspaces.core.executor.juc.CallableDistributedTaskAdapter<T,R>
All Implemented Interfaces:
AsyncResultFilter<T>, AsyncResultsReducer<T,R>, Externalizable, Serializable, DistributedTask<T,R>, ProcessObjectsProvider, Task<T>, TaskRoutingProvider

public class CallableDistributedTaskAdapter<T extends Serializable,R>
extends CallableTaskAdapter<T>
implements DistributedTask<T,R>, AsyncResultFilter<T>

An adapter allowing to execute a Callable in a distributed fashion. In such a case, a AsyncResultsReducer must be implemented or provided (see the different constructors). An optional AsyncResultFilter can be also implemented or provided.

Author:
kimchy
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.gigaspaces.async.AsyncResultFilter
AsyncResultFilter.Decision
 
Constructor Summary
CallableDistributedTaskAdapter()
          Here just for externalizable.
CallableDistributedTaskAdapter(Callable<T> callable)
          Constructs a new callable distributed task adapter.
CallableDistributedTaskAdapter(Callable<T> callable, AsyncResultsReducer<T,R> reducer)
          Constructs a new callable distributed task adapter with a separate reducer.
CallableDistributedTaskAdapter(Callable<T> callable, AsyncResultsReducer<T,R> reducer, AsyncResultFilter<T> filter)
          Constructs a new callable distributed task adapter with a separate reducer and filter.
 
Method Summary
 AsyncResultFilter.Decision onResult(AsyncResultFilterEvent<T> event)
          If a filter is provided in one of the constructor methods, will delegate the call to it.
 void readExternal(ObjectInput in)
           
 R reduce(List<AsyncResult<T>> results)
          Delegates the call to the provided reducer.
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.openspaces.core.executor.juc.CallableTaskAdapter
execute, getCallable, getObjectsToProcess, 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

CallableDistributedTaskAdapter

public CallableDistributedTaskAdapter()
Here just for externalizable.


CallableDistributedTaskAdapter

public CallableDistributedTaskAdapter(Callable<T> callable)
                               throws IllegalArgumentException
Constructs a new callable distributed task adapter. The callable in this case must implements {link AsyncResultReducer} and optionally can implement AsyncResultFilter.

Throws:
IllegalArgumentException

CallableDistributedTaskAdapter

public CallableDistributedTaskAdapter(Callable<T> callable,
                                      AsyncResultsReducer<T,R> reducer)
                               throws IllegalArgumentException
Constructs a new callable distributed task adapter with a separate reducer. The reducer or the callable can optionally implement AsyncResultFilter.

Throws:
IllegalArgumentException

CallableDistributedTaskAdapter

public CallableDistributedTaskAdapter(Callable<T> callable,
                                      AsyncResultsReducer<T,R> reducer,
                                      AsyncResultFilter<T> filter)
                               throws IllegalArgumentException
Constructs a new callable distributed task adapter with a separate reducer and filter.

Throws:
IllegalArgumentException
Method Detail

reduce

public R reduce(List<AsyncResult<T>> results)
         throws Exception
Delegates the call to the provided reducer.

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

onResult

public AsyncResultFilter.Decision onResult(AsyncResultFilterEvent<T> event)
If a filter is provided in one of the constructor methods, will delegate the call to it. Otherwise it will return the default AsyncResultFilter.Decision.CONTINUE.

Specified by:
onResult in interface AsyncResultFilter<T extends Serializable>

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class CallableTaskAdapter<T extends Serializable>
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class CallableTaskAdapter<T extends Serializable>
Throws:
IOException
ClassNotFoundException

GigaSpaces XAP 8.0 API

Copyright © GigaSpaces.