|
GemFire 6.6.2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface ResultCollector<T,S>
Defines the interface for a container that gathers results from function
execution.
GemFire provides a default implementation for ResultCollector. Applications
can choose to implement their own custom ResultCollector. A custom
ResultCollector facilitates result sorting or aggregation. Aggregation
functions like sum, minimum, maximum and average can also be applied to the
result using a custom ResultCollector. Results arrive as they are sent using
the ResultSender.sendResult(Object) and can be used as they
arrive. To indicate that all results have been received endResults()
is called.
Region region ;
Set keySet = Collections.singleton("myKey");
Function multiGetFunction ;
Object args ;
ResultCollector rc = FunctionService.onRegion(region)
.withArgs(args)
.withFilter(keySet)
.withCollector(new MyCustomResultCollector())
.execute(multiGetFunction.getId());
Application can do something else here before retrieving the result
Or it can have some logic in {addResult(DistributedMember, Object) to use the partial results.
If it wants to see all the results it can use
Object functionResult = rc.getResult();
or
Object functionResult = rc.getResult(timeout,TimeUnit);
depending on if it wants to wait for all the results or wait for a timeout period.
For default implementation of the ResultCollector interface, refer to
DefaultResultCollector. There is no need to provide a synchronization
mechanism in the user implementations of ResultCollector
| Method Summary | |
|---|---|
void |
addResult(DistributedMember memberID,
T resultOfSingleExecution)
Method used to feed result to the ResultCollector. |
void |
clearResults()
GemFire will invoke this method before re-executing function (in case of Function Execution HA). |
void |
endResults()
GemFire will invoke this method when function execution has completed and all results for the execution have been obtained and added to the ResultCollector
Unless the ResultCollector has received
last result from all the
executing nodes, it keeps waiting for more results to come. |
S |
getResult()
Method used to pull results from the ResultCollector. |
S |
getResult(long timeout,
TimeUnit unit)
Method used to pull results from the ResultCollector. |
| Method Detail |
|---|
S getResult()
throws FunctionException
all
the results are available has been called.
FunctionException - if result retrieval fails
S getResult(long timeout,
TimeUnit unit)
throws FunctionException,
InterruptedException
all the results are available. If all the results are
not received in provided time a FunctionException is thrown.
timeout - the maximum time to waitunit - the time unit of the timeout argument
FunctionException - if result retrieval fails within timeout provided
InterruptedException - if the current thread was interrupted while waiting
void addResult(DistributedMember memberID,
T resultOfSingleExecution)
resultOfSingleExecution - memberID - DistributedMember ID to which result belongsvoid endResults()
added to the ResultCollector
Unless the ResultCollector has received
last result from all the
executing nodes, it keeps waiting for more results to come.
ResultSender.lastResult(Object)void clearResults()
|
GemFire 6.6.2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||