Brunet.Services.MapReduce.MapReduceComputation.TryNextReduce C# (CSharp) Метод

TryNextReduce() защищенный Метод

protected TryNextReduce ( State new_s, State old_s, RpcResult v, bool cont ) : bool
new_s State
old_s State
v Brunet.Messaging.RpcResult
cont bool
Результат bool
    protected bool TryNextReduce(State new_s, State old_s, RpcResult v, bool cont) {
      if( new_s.Done ) {
        SendResult( new_s.ReduceResult );
        return false;
      }
      bool start_red = new_s.Reducing && (cont || (false == old_s.Reducing));
      if (LogEnabled) {
        ProtocolLog.Write(ProtocolLog.MapReduce,        
                          String.Format("MapReduce: {0}, TryNextReduce: {1}.",
                          _node.Address, start_red));
      }
      if( start_red ) {
        Channel r_chan = new Channel(1, v);
        r_chan.CloseEvent += this.ReduceHandler;
        object startval = new_s.ReduceResult == State.DEFAULT_OBJ ? null : new_s.ReduceResult;
        if (LogEnabled) {
          ProtocolLog.Write(ProtocolLog.MapReduce,        
                          String.Format("MapReduce: {0} abt to Reduce({1},{2},{3})",
                            _node.Address, _mr_args.ReduceArg, startval, v));
        }
        try {
          _mr_task.Reduce(r_chan, _mr_args.ReduceArg, startval, v);
        }
        catch(Exception x) {
          //Reduce is where we do error handling, if that doesn't work, oh well:
          if (LogEnabled) {
            ProtocolLog.Write(ProtocolLog.MapReduce,        
                          String.Format("MapReduce: {0}, reduce threw: {1}.", _node.Address, x));
          }
          SendResult(x);
          return false;
        }
      }
      return start_red;
    }