public interface ResultSender<T>
ResultCollector
. For each result sent using this
method, ResultCollector.addResult(org.apache.geode.distributed.DistributedMember, Object)
is called, making that result available to the calling thread immediately.
Example:
execute(FunctionContext context){ ResultSender rs = context.getResultSender(); int lastResult = -1; for(int i=0;i< 10; i++) { rs.sendResult(i); } rs.lastResult(lastResult); } Application can receive the results as they are sent using ResultSender in the above for loop. It is very important to send a last result as it informsResultCollector
to stop waiting for the result.
ResultCollector.addResult(org.apache.geode.distributed.DistributedMember, Object)
Modifier and Type | Method and Description |
---|---|
void |
lastResult(T lastResult)
Sends a result back to the FunctionService calling thread and invokes
ResultCollector.addResult(org.apache.geode.distributed.DistributedMember, Object) and
then ResultCollector.endResults() if it is the last instance of the Function to report
results. |
void |
sendException(Throwable t)
Sends an Exception back to the FunctionService calling thread.
|
void |
sendResult(T oneResult)
Sends a result back to the FunctionService calling thread and invokes
ResultCollector.addResult(org.apache.geode.distributed.DistributedMember, Object) . |
void sendResult(T oneResult)
ResultCollector.addResult(org.apache.geode.distributed.DistributedMember, Object)
.oneResult
- the result to be sentvoid lastResult(T lastResult)
ResultCollector.addResult(org.apache.geode.distributed.DistributedMember, Object)
and
then ResultCollector.endResults()
if it is the last instance of the Function to report
results. The ResultCollector will keep waiting for results until it receives last result.
Therefore, it is very important to use this method to indicate end of function execution.lastResult
- the result to be sentIllegalStateException
- if called more than onceResultCollector.endResults()
void sendException(Throwable t)
ResultCollector.getResult()
will not throw exception but will have exception as a part of results received. Calling
sendException will act as a lastResult.t
- the Throwable
to be sentlastResult(Object)