public void sendResult(Object oneResult) {
   if (!this.function.hasResult()) {
     throw new IllegalStateException(
         LocalizedStrings.ExecuteFunction_CANNOT_0_RESULTS_HASRESULT_FALSE.toLocalizedString(
             "send"));
   }
   if (this.serverSender != null) { // Client-Server
     if (dm.getLoggerI18n().fineEnabled()) {
       dm.getLoggerI18n()
           .fine(
               "MemberFunctionResultSender sending result from local node to client " + oneResult);
     }
     this.serverSender.sendResult(oneResult);
   } else { // P2P
     if (this.msg != null) {
       try {
         this.msg.sendReplyForOneResult(dm, oneResult, false, enableOrderedResultStreming, false);
       } catch (QueryException e) {
         throw new FunctionException(e);
       } catch (ForceReattemptException e) {
         throw new FunctionException(e);
       } catch (InterruptedException e) {
         throw new FunctionException(e);
       }
     } else {
       this.rc.addResult(this.dm.getDistributionManagerId(), oneResult);
       FunctionStats.getFunctionStats(function.getId(), this.dm.getSystem()).incResultsReceived();
     }
     // incrementing result sent stats.
     FunctionStats.getFunctionStats(function.getId(), this.dm.getSystem()).incResultsReturned();
   }
 }
 public void lastResult(
     Object oneResult, boolean completelyDone, ResultCollector reply, DistributedMember memberID) {
   if (this.serverSender != null) { // Client-Server
     if (completelyDone) {
       if (onlyRemote) {
         this.serverSender.lastResult(oneResult, memberID);
         reply.endResults();
       } else {
         lastResult(oneResult, reply, true, false, memberID);
       }
     } else {
       this.serverSender.sendResult(oneResult, memberID);
     }
   } else { // P2P
     if (completelyDone) {
       if (this.onlyRemote) {
         reply.addResult(memberID, oneResult);
         reply.endResults();
       } else {
         // call a synchronized method as local node is also waiting to send lastResult
         lastResult(oneResult, reply, true, false, memberID);
       }
     } else {
       reply.addResult(memberID, oneResult);
     }
     FunctionStats.getFunctionStats(function.getId(), this.dm.getSystem()).incResultsReceived();
   }
   FunctionStats.getFunctionStats(function.getId(), this.dm.getSystem()).incResultsReturned();
 }
  public final void lastResult(
      final Object oneResult,
      final boolean doTXFlush,
      final boolean sendTXChanges,
      final boolean finishTXRead) {
    if (!this.function.hasResult()) {
      throw new IllegalStateException(
          LocalizedStrings.ExecuteFunction_CANNOT_0_RESULTS_HASRESULT_FALSE.toLocalizedString(
              "send"));
    }
    if (doTXFlush) {
      // flush any pending transactional operations
      flushTXPendingOps();
    }

    if (this.serverSender != null) { // client-server
      if (this.localLastResultRecieved) {
        return;
      }
      if (onlyLocal) {
        this.serverSender.lastResult(oneResult);
        this.rc.endResults();
        this.localLastResultRecieved = true;
      } else {
        lastResult(oneResult, rc, false, true, this.dm.getId());
      }
    } else { // P2P
      if (this.msg != null) {
        try {
          this.msg.sendReplyForOneResult(
              dm, oneResult, true, enableOrderedResultStreming, sendTXChanges);
        } catch (QueryException e) {
          throw new FunctionException(e);
        } catch (ForceReattemptException e) {
          throw new FunctionException(e);
        } catch (InterruptedException e) {
          throw new FunctionException(e);
        }
      } else {
        if (this.localLastResultRecieved) {
          return;
        }
        if (onlyLocal) {
          this.rc.addResult(this.dm.getDistributionManagerId(), oneResult);
          this.rc.endResults();
          this.localLastResultRecieved = true;
        } else {
          // call a synchronized method as local node is also waiting to send lastResult
          lastResult(oneResult, rc, false, true, this.dm.getDistributionManagerId());
        }
        FunctionStats.getFunctionStats(function.getId(), this.dm.getSystem()).incResultsReceived();
      }
    }
    FunctionStats.getFunctionStats(function.getId(), this.dm.getSystem()).incResultsReturned();
  }