Exemplo n.º 1
0
        public void Handle(EvaluatorControlProto message)
        {
            lock (_heartBeatManager)
            {
                Logger.Log(Level.Info, "Handle Evaluator control message");
                if (!message.identifier.Equals(_evaluatorId, StringComparison.OrdinalIgnoreCase))
                {
                    OnException(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.DONE)
                {
                    if (message.done_evaluator != null)
                    {
                        Logger.Log(Level.Info, "Received ACK from Driver, shutting down Evaluator.");
                        _clock.Dispose();

                        return;
                    }
                    else
                    {
                        OnException(new InvalidOperationException("Received a control message from Driver after Evaluator is done."));
                    }
                }
                else if (_state != State.RUNNING)
                {
                    OnException(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());
                            }
                        }
                        catch (Exception e)
                        {
                            Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, Logger);
                            OnException(e);
                            Utilities.Diagnostics.Exceptions.Throw(new InvalidOperationException(e.ToString(), e), Logger);
                        }
                    }
                    if (message.kill_evaluator != null)
                    {
                        Logger.Log(Level.Info, "Evaluator {0} has been killed by the driver.", _evaluatorId);
                        _state = State.KILLED;
                        _clock.Dispose();
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void OnError(Exception error)
        {
            LOGGER.Log(Level.Error, "job excemption", error);
            JobStatusProto proto = new JobStatusProto();

            proto.identifier = _jobId;
            proto.state      = State.FAILED;
            proto.exception  = ByteUtilities.StringToByteArrays(error.Message);
            _clock.Dispose();
        }