Ejemplo n.º 1
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());
            }
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        public void OnNext(IJobMessage value)
        {
            var message = "unable to deserialize message";

            try
            {
                message = ByteUtilities.ByteArraysToString(value.Message);
            }
            catch (SerializationException)
            {
                var opaque = ByteUtilities.DeserializeFromBinaryFormat(value.Message);
                message = opaque.ToString();
            }
            Log.Log(Level.Info, "Job {0} sent message {1}", value.Id, message);
        }
Ejemplo n.º 4
0
 private static Exception GetCause(byte[] serializedCause, string originalTaskExceptionToString)
 {
     // TODO[JIRA REEF-1422]: Distinguish between Java Task Exception and missing Exception.
     if (ByteUtilities.IsNullOrEmpty(serializedCause))
     {
         return(new TaskExceptionMissingException(
                    "Task failed without an Exception, presumably caused by an Exception failure. Please inspect the FailedTask message."));
     }
     try
     {
         return((Exception)ByteUtilities.DeserializeFromBinaryFormat(serializedCause));
     }
     catch (SerializationException se)
     {
         return(NonSerializableTaskException.UnableToDeserialize(originalTaskExceptionToString, se));
     }
 }
Ejemplo n.º 5
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));
     }
 }