/// <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); } } }
/// <summary> /// Resource status information from the (actual) resource manager. /// </summary> /// <param name="resourceStatusProto"></param> public void Handle(ResourceStatusProto resourceStatusProto) { lock (_evaluatorDescriptor) { State resourceState = resourceStatusProto.state; LOGGER.Log(Level.Info, "Resource manager state update: " + resourceState); if (resourceState == State.DONE || resourceState == State.FAILED) { if (_state < STATE.DONE) { // something is wrong, I think I'm alive but the resource manager runtime says I'm dead StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append( string.Format( CultureInfo.InvariantCulture, "The resource manager informed me that Evaluator {0} is in state {1} but I think I am in {2} state", _evaluatorId, resourceState, _state)); if (resourceStatusProto.diagnostics != null) { stringBuilder.Append("Cause: " + resourceStatusProto.diagnostics); } if (_runningTask != null) { stringBuilder.Append( string.Format( CultureInfo.InvariantCulture, "Taskruntime {0} did not complete before this evaluator died.", _runningTask.Id)); } // RM is telling me its DONE/FAILED - assuming it has already released the resources _isResourceReleased = true; //Handle(new EvaluatorException(_evaluatorId, stringBuilder.ToString(), _runningTask)); _state = STATE.KILLED; } } } }
/// <summary> /// A ResourceStatusProto message comes from the ResourceManager layer to indicate what it thinks /// about the current state of a given resource. Ideally, we should think the same thing. /// </summary> /// <param name="resourceStatusProto"></param> public void OnNext(ResourceStatusProto resourceStatusProto) { Handle(resourceStatusProto); }