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); } }
public void OnShutdown(Exception ex) { Logger.Log(Level.Error, "Driver shutdown with error", ex); byte[] errorBytes; try { errorBytes = ByteUtilities.SerializeToBinaryFormat(ex); } catch (SerializationException se) { Logger.Log(Level.Warning, "Unable to serialize exception", ex); errorBytes = ByteUtilities.SerializeToBinaryFormat( NonSerializableJobException.UnableToSerialize(ex, se)); } _driverServiceStub.Shutdown(new ShutdownRequest() { Exception = new ExceptionInfo() { NoError = false, Message = ex.Message, Name = ex.Source, Data = ByteString.CopyFrom(errorBytes) } }); }
/// <summary> /// THIS ASSUMES THAT IT IS CALLED ON A THREAD HOLDING THE LOCK ON THE HeartBeatManager /// </summary> /// <param name="e"></param> private void HandleTaskInitializationException(TaskClientCodeException e) { byte[] error; try { error = ByteUtilities.SerializeToBinaryFormat(e); } catch (SerializationException se) { error = ByteUtilities.SerializeToBinaryFormat( TaskClientCodeException.CreateWithNonSerializableInnerException(e, se)); } var avroFailedTask = new AvroFailedTask { identifier = e.TaskId, cause = error, data = ByteUtilities.StringToByteArrays(e.ToString()), message = e.Message }; var taskStatus = new TaskStatusProto { context_id = e.ContextId, task_id = e.TaskId, result = AvroJsonSerializer <AvroFailedTask> .ToBytes(avroFailedTask), state = State.FAILED }; LOGGER.Log(Level.Error, "Sending Heartbeat for a failed task: {0}", taskStatus); _heartBeatManager.OnNext(taskStatus); }
public TaskStatusProto ToProto() { // This is locked because the Task continuation thread which sets the // result is potentially different from the HeartBeat thread. lock (_heartBeatManager) { Check(); TaskStatusProto taskStatusProto = new TaskStatusProto() { context_id = ContextId, task_id = TaskId, state = GetProtoState() }; if (_result.IsPresent()) { taskStatusProto.result = ByteUtilities.CopyBytesFrom(_result.Value); } else if (_lastException.IsPresent()) { byte[] error; try { error = ByteUtilities.SerializeToBinaryFormat(_lastException.Value); } catch (SerializationException se) { error = ByteUtilities.SerializeToBinaryFormat( NonSerializableTaskException.UnableToSerialize(_lastException.Value, se)); } var avroFailedTask = new AvroFailedTask { identifier = _taskId, cause = error, data = ByteUtilities.StringToByteArrays(_lastException.Value.ToString()), message = _lastException.Value.Message }; taskStatusProto.result = AvroJsonSerializer <AvroFailedTask> .ToBytes(avroFailedTask); } else if (_state == TaskState.Running) { foreach (TaskMessage message in GetMessages()) { TaskStatusProto.TaskMessageProto taskMessageProto = new TaskStatusProto.TaskMessageProto() { source_id = message.MessageSourceId, message = ByteUtilities.CopyBytesFrom(message.Message), }; taskStatusProto.task_message.Add(taskMessageProto); } } return(taskStatusProto); } }
public static ExceptionInfo SerializeException(Exception ex) { ByteString serializedException; try { serializedException = ByteString.CopyFrom(ByteUtilities.SerializeToBinaryFormat(ex)); } catch (SerializationException se) { Log.Log(Level.Warning, "Unable to serialize exception", ex); serializedException = ByteString.CopyFrom(ByteUtilities.SerializeToBinaryFormat( NonSerializableJobException.UnableToSerialize(ex, se))); } return(new ExceptionInfo() { NoError = false, Name = ex.GetType().ToString(), Message = ex.Message, Data = serializedException }); }