Exemplo n.º 1
0
        private void OnException(Exception e)
        {
            lock (_heartBeatManager)
            {
                Logger.Log(Level.Error, "Evaluator {0} failed with exception {1}.", _evaluatorId, e);
                _state = State.FAILED;

                byte[] errorBytes = null;

                try
                {
                    errorBytes = ByteUtilities.SerializeToBinaryFormat(e);
                }
                catch (SerializationException se)
                {
                    errorBytes = ByteUtilities.SerializeToBinaryFormat(
                        NonSerializableEvaluatorException.UnableToSerialize(e, se));
                }

                var evaluatorStatusProto = new EvaluatorStatusProto
                {
                    evaluator_id = _evaluatorId,
                    error        = errorBytes,
                    state        = _state
                };

                _heartBeatManager.OnNext(evaluatorStatusProto);
                _contextManager.Dispose();

                _evaluatorExitLogger.LogExit(false);
            }
        }
Exemplo n.º 2
0
        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());
            }
        }
Exemplo n.º 3
0
        private static EvaluatorException CreateEvaluatorException(EvaluatorInfo eval)
        {
            var failureInfo = eval.Failure;
            var errorBytes  = failureInfo.Exception.Data.ToByteArray();

            if (errorBytes == null || errorBytes.Length == 0)
            {
                Logger.Log(Level.Error, "Exception without object details: {0}", failureInfo.Exception.Message);
                return(new EvaluatorException(
                           eval.EvaluatorId,
                           failureInfo.Exception.Message,
                           string.Join(";", failureInfo.Exception.StackTrace)));
            }
            // 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);
            }
            return(new EvaluatorException(eval.EvaluatorId, inner.Message, inner));
        }
Exemplo n.º 4
0
 public Exception AsError()
 {
     if (Data.IsPresent())
     {
         Exception inner;
         try
         {
             inner = (Exception)ByteUtilities.DeserializeFromBinaryFormat(Data.Value);
         }
         catch (SerializationException se)
         {
             inner = NonSerializableEvaluatorException.UnableToDeserialize(
                 "Exception from Evaluator was not able to be deserialized, returning a NonSerializableEvaluatorException.",
                 se);
         }
         return(new JobException(Id, Message, inner));
     }
     else
     {
         return(new JobException(Id, Message));
     }
 }