|
GemFire 6.0.1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface ResultCollector<T extends Serializable>
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 it is sent using the ResultSender.sendResult(Serializable)
and can be used as it arrives. To indicate if all the results have been received endResults() is called.
Region region ;
Set keySet = Collections.singleton("myKey");
Function multiGetFunction ;
Serializable 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(Serializable) to use the partial results.
If it wants to see all the results it can use
Serializable functionResult = rc.getResult();
or
Serializable functionResult = rc.getResult(timeout,TimeUnit);
depending on if it wants to wait for all the results or wait for a timeout period.
| Method Summary | |
|---|---|
void |
addResult(T resultOfSingleExecution)
Adds a single function execution result to the ResultCollector It is invoked every time a result is sent using ResultSender. |
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. |
T |
getResult()
Returns the result of function execution, potentially blocking until all the results are available has been called. |
T |
getResult(long timeout,
TimeUnit unit)
Returns the result of function execution, blocking for the timeout period until all the results are available. |
| Method Detail |
|---|
T getResult()
throws FunctionException
all the results are available has been called.
FunctionException - if result retrieval fails
T 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 waitingvoid addResult(T resultOfSingleExecution)
resultOfSingleExecution - void 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(Serializable)
|
GemFire 6.0.1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||