Ejemplo n.º 1
0
        /// <summary>
        ///  Receives and routes heartbeats from Evaluators.
        /// </summary>
        /// <param name="evaluatorHearBeatProto"></param>
        private void Handle(IRemoteMessage <EvaluatorHeartbeatProto> evaluatorHearBeatProto)
        {
            EvaluatorHeartbeatProto heartbeat = evaluatorHearBeatProto.Message;
            EvaluatorStatusProto    status    = heartbeat.evaluator_status;
            string evaluatorId = status.evaluator_id;

            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Heartbeat from Evaluator {0} with state {1} timestamp {2}", evaluatorId, status.state, heartbeat.timestamp));
            _sanityChecker.check(evaluatorId, heartbeat.timestamp);

            lock (_evaluators)
            {
                if (_evaluators.ContainsKey(evaluatorId))
                {
                    EvaluatorManager evaluatorManager = _evaluators[evaluatorId];
                    evaluatorManager.Handle(evaluatorHearBeatProto);
                }
                else
                {
                    string msg = "Contact from unkonwn evaluator with id: " + evaluatorId;
                    if (heartbeat.evaluator_status != null)
                    {
                        msg += " with state" + status.state;
                    }
                    LOGGER.Log(Level.Error, msg);
                    Exceptions.Throw(new InvalidOperationException(msg), LOGGER);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This handles runtime error occurs on the evaluator
        /// </summary>
        /// <param name="runtimeErrorProto"></param>
        public void Handle(RuntimeErrorProto runtimeErrorProto)
        {
            FailedRuntime error = new FailedRuntime(runtimeErrorProto);

            LOGGER.Log(Level.Warning, "Runtime error:" + error);

            EvaluatorException evaluatorException = error.Cause != null
                ? new EvaluatorException(error.Id, error.Cause.Value)
                : new EvaluatorException(error.Id, "Runtime error");
            EvaluatorManager evaluatorManager = null;

            lock (_evaluators)
            {
                if (_evaluators.ContainsKey(error.Id))
                {
                    evaluatorManager = _evaluators[error.Id];
                }
                else
                {
                    LOGGER.Log(Level.Warning, "Unknown evaluator runtime error: " + error.Cause);
                }
            }
            if (null != evaluatorManager)
            {
                evaluatorManager.Handle(evaluatorException);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// This resource status message comes from the ResourceManager layer; telling me what it thinks
 /// about the state of the resource executing an Evaluator; This method simply passes the message
 /// off to the referenced EvaluatorManager
 /// </summary>
 /// <param name="resourceStatusProto"></param>
 private void Handle(ResourceStatusProto resourceStatusProto)
 {
     lock (_evaluators)
     {
         if (_evaluators.ContainsKey(resourceStatusProto.identifier))
         {
             EvaluatorManager evaluatorManager = _evaluators[resourceStatusProto.identifier];
             evaluatorManager.Handle(resourceStatusProto);
         }
         else
         {
             var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Unknown resource status from evaluator {0} with state {1}", resourceStatusProto.identifier, resourceStatusProto.state));
             Exceptions.Throw(e, LOGGER);
         }
     }
 }
Ejemplo n.º 4
0
        public void Dispose()
        {
            if (_disposed)
            {
                var e = new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Active context [{0}] already closed", _identifier));
                Exceptions.Throw(e, LOGGER);
            }
            LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Submit close context: RunningEvaluator id [{0}] for context id [{1}]", EvaluatorId, Id));
            RemoveContextProto removeContextProto = new RemoveContextProto();

            removeContextProto.context_id = Id;
            ContextControlProto contextControlProto = new ContextControlProto();

            contextControlProto.remove_context = removeContextProto;
            _evaluatorManager.Handle(contextControlProto);
            _disposed = true;
        }