Example #1
0
 public void Handle(EvaluatorControlProto message)
 {
     lock (_heartBeatManager)
     {
         LOGGER.Log(Level.Info, "Handle Evaluator control message");
         if (!message.identifier.Equals(_evaluatorId, StringComparison.OrdinalIgnoreCase))
         {
             Handle(new InvalidOperationException(
                        string.Format(CultureInfo.InvariantCulture, "Identifier mismatch: message for evaluator id[{0}] sent to evaluator id[{1}]", message.identifier, _evaluatorId)));
         }
         else if (_state != State.RUNNING)
         {
             Handle(new InvalidOperationException(
                        string.Format(CultureInfo.InvariantCulture, "Evaluator received a control message but its state is not {0} but rather {1}", State.RUNNING, _state)));
         }
         else
         {
             if (message.context_control != null)
             {
                 LOGGER.Log(Level.Info, "Send task control message to ContextManager");
                 try
                 {
                     _contextManager.HandleTaskControl(message.context_control);
                     if (_contextManager.ContextStackIsEmpty() && _state == State.RUNNING)
                     {
                         LOGGER.Log(Level.Info, "Context stack is empty, done");
                         _state = State.DONE;
                         _heartBeatManager.OnNext(GetEvaluatorStatus());
                         _clock.Dispose();
                     }
                 }
                 catch (Exception e)
                 {
                     Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER);
                     Handle(e);
                     Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(new InvalidOperationException(e.ToString(), e), LOGGER);
                 }
             }
             if (message.kill_evaluator != null)
             {
                 LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Evaluator {0} has been killed by the driver.", _evaluatorId));
                 _state = State.KILLED;
                 _clock.Dispose();
             }
         }
     }
 }
Example #2
0
 private void Heartbeat()
 {
     _heartBeatManager.OnNext(ToProto());
 }