public FailedEvaluator(IFailedEvaluatorClr2Java clr2Java) { FailedEvaluatorClr2Java = clr2Java; _id = FailedEvaluatorClr2Java.GetId(); _failedContexts = new List<IFailedContext>( FailedEvaluatorClr2Java.GetFailedContextsClr2Java().Select(clr2JavaFailedContext => new FailedContext(clr2JavaFailedContext))); var errorBytes = FailedEvaluatorClr2Java.GetErrorBytes(); if (errorBytes != null && errorBytes.Length != 0) { // When the Exception originates from the C# side. Exception inner; try { inner = (Exception)ByteUtilities.DeserializeFromBinaryFormat(errorBytes); } catch (SerializationException se) { inner = NonSerializableEvaluatorException.UnableToDeserialize( "Exception from Evaluator was not able to be deserialized, returning a NonSerializableEvaluatorException.", se); } _evaluatorException = new EvaluatorException(_id, inner.Message, inner); } else { // When the Exception originates from Java. _evaluatorException = new EvaluatorException( _id, FailedEvaluatorClr2Java.GetJavaCause(), FailedEvaluatorClr2Java.GetJavaStackTrace()); } }
public FailedEvaluator(IFailedEvaluatorClr2Java clr2Java) { FailedEvaluatorClr2Java = clr2Java; _id = FailedEvaluatorClr2Java.GetId(); _failedContexts = new List <IFailedContext>( FailedEvaluatorClr2Java.GetFailedContextsClr2Java().Select(clr2JavaFailedContext => new FailedContext(clr2JavaFailedContext))); var errorBytes = FailedEvaluatorClr2Java.GetErrorBytes(); if (errorBytes != null && errorBytes.Length != 0) { // When the Exception originates from the C# side. Exception inner; try { inner = (Exception)ByteUtilities.DeserializeFromBinaryFormat(errorBytes); } catch (SerializationException se) { inner = NonSerializableEvaluatorException.UnableToDeserialize( "Exception from Evaluator was not able to be deserialized, returning a NonSerializableEvaluatorException.", se); } _evaluatorException = new EvaluatorException(_id, inner.Message, inner); } else { // When the Exception originates from Java. _evaluatorException = new EvaluatorException( _id, FailedEvaluatorClr2Java.GetJavaCause(), FailedEvaluatorClr2Java.GetJavaStackTrace()); } }
/// <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); } }
public BridgeFailedEvaluator( string id, EvaluatorException evaluatorException, IList <IFailedContext> failedContexts, Optional <IFailedTask> failedTask) { Id = id; EvaluatorException = evaluatorException; FailedContexts = failedContexts; FailedTask = failedTask; }
/// <summary> /// EvaluatorException will trigger is FailedEvaluator and state transition to FAILED /// </summary> /// <param name="exception"></param> public void Handle(EvaluatorException exception) { lock (_evaluatorDescriptor) { if (_state >= STATE.DONE) { return; } LOGGER.Log(Level.Warning, "Failed Evaluator: " + Id + exception.Message); try { IList <FailedContext> failedContexts = new List <FailedContext>(); IList <EvaluatorContext> activeContexts = new List <EvaluatorContext>(_activeContexts); activeContexts = activeContexts.Reverse().ToList(); foreach (EvaluatorContext context in activeContexts) { Optional <IActiveContext> parentContext = context.ParentId.IsPresent() ? Optional <IActiveContext> .Of(GetEvaluatorContext(context.ParentId.Value)) : Optional <IActiveContext> .Empty(); failedContexts.Add(context.GetFailedContext(parentContext, exception)); } //Optional<FailedTask> failedTask = _runningTask != null ? // Optional<FailedTask>.Of(new FailedTask(_runningTask.Id, exception)) : Optional<FailedTask>.Empty(); //LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + failedTask.ToString()); //this.dispatcher.onNext(FailedEvaluator.class, new FailedEvaluatorImpl( //exception, failedContextList, failedTaskOptional, this.evaluatorId)); } catch (Exception e) { Exceptions.CaughtAndThrow(e, Level.Error, "Exception while handling FailedEvaluator.", LOGGER); } finally { _state = STATE.FAILED; Dispose(); } } }
public void Handle(IRemoteMessage <EvaluatorHeartbeatProto> evaluatorHearBeatProtoMessage) { lock (_evaluatorDescriptor) { EvaluatorHeartbeatProto heartbeatProto = evaluatorHearBeatProtoMessage.Message; if (heartbeatProto.evaluator_status != null) { EvaluatorStatusProto status = heartbeatProto.evaluator_status; if (status.error != null) { Handle(new EvaluatorException(Id, ByteUtilities.ByteArrarysToString(status.error))); return; } else if (_state == STATE.SUBMITTED) { string evaluatorRId = evaluatorHearBeatProtoMessage.Identifier.ToString(); LOGGER.Log(Level.Info, "TODO: REPLACE THIS " + evaluatorRId); // TODO // _evaluatorControlHandler = _remoteManager.getHandler(evaluatorRID, EvaluatorRuntimeProtocol.EvaluatorControlProto.class); _state = STATE.RUNNING; LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Evaluator {0} is running", _evaluatorId)); } } LOGGER.Log(Level.Info, "Evaluator heartbeat: " + heartbeatProto); EvaluatorStatusProto evaluatorStatusProto = heartbeatProto.evaluator_status; foreach (ContextStatusProto contextStatusProto in heartbeatProto.context_status) { Handle(contextStatusProto, heartbeatProto.task_status != null); } if (heartbeatProto.task_status != null) { Handle(heartbeatProto.task_status); } if (evaluatorStatusProto.state == State.FAILED) { _state = STATE.FAILED; EvaluatorException e = evaluatorStatusProto.error != null ? new EvaluatorException(_evaluatorId, ByteUtilities.ByteArrarysToString(evaluatorStatusProto.error)) : new EvaluatorException(_evaluatorId, "unknown cause"); LOGGER.Log(Level.Warning, "Failed evaluator: " + Id + e.Message); Handle(e); } else if (evaluatorStatusProto.state == State.DONE) { LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Evaluator {0} done", Id)); _state = STATE.DONE; // TODO // dispatcher.onNext(CompletedEvaluator.class, new CompletedEvaluator() { //@Override //public String getId() { // return EvaluatorManager.this.evaluatorId; Dispose(); } } LOGGER.Log(Level.Info, "DONE with evaluator heartbeat"); }