public void OnNext(RuntimeStop runtimeStop) { Logger.Log(Level.Verbose, "Runtime stop"); lock (_heartBeatManager) { if (_state == State.RUNNING) { const string msg = "RuntimeStopHandler invoked in state RUNNING."; if (runtimeStop.Exception != null) { OnException(new SystemException(msg, runtimeStop.Exception)); } else { OnException(new SystemException(msg)); } } else { var successfulExit = true; try { _contextManager.Dispose(); _evaluatorControlChannel.Dispose(); } catch (Exception e) { successfulExit = false; Utilities.Diagnostics.Exceptions.CaughtAndThrow( new InvalidOperationException("Cannot stop evaluator properly", e), Level.Error, "Exception during shut down.", Logger); } finally { _evaluatorExitLogger.LogExit(successfulExit); } } } }
/// <summary> /// Handles RuntimeStop /// </summary> /// <param name="runtimeStop"></param> public void OnNext(RuntimeStop runtimeStop) { LOGGER.Log(Level.Info, "RuntimeStop: " + runtimeStop); if (runtimeStop.Exception != null) { string exceptionMessage = runtimeStop.Exception.Message; LOGGER.Log(Level.Warning, "Sending runtime error:" + exceptionMessage); RuntimeErrorProto runtimeErrorProto = new RuntimeErrorProto(); runtimeErrorProto.message = exceptionMessage; runtimeErrorProto.exception = ByteUtilities.StringToByteArrays(exceptionMessage); runtimeErrorProto.name = "REEF"; _runtimeErrorHandler.OnNext(runtimeErrorProto); LOGGER.Log(Level.Warning, "DONE Sending runtime error: " + exceptionMessage); } lock (_evaluators) { foreach (EvaluatorManager evaluatorManager in _evaluators.Values) { LOGGER.Log(Level.Warning, "Unclean shutdown of evaluator: " + evaluatorManager.Id); evaluatorManager.Dispose(); } } try { _heartbeatConnectionChannel.Dispose(); _errorChannel.Dispose(); Optional <Exception> e = runtimeStop.Exception != null ? Optional <Exception> .Of(runtimeStop.Exception) : Optional <Exception> .Empty(); _clientJobStatusHandler.Dispose(e); LOGGER.Log(Level.Info, "driver manager closed"); } catch (Exception e) { Exceptions.Caught(e, Level.Error, "Error disposing Driver manager", LOGGER); Exceptions.Throw(new InvalidOperationException("Cannot dispose driver manager"), LOGGER); } }
public void OnNext(RuntimeStop runtimeStop) { Logger.Log(Level.Info, "Runtime stop"); _contextManager.Dispose(); if (_state == State.RUNNING) { _state = State.DONE; _heartBeatManager.OnNext(); } try { _evaluatorControlChannel.Dispose(); } catch (Exception e) { Utilities.Diagnostics.Exceptions.CaughtAndThrow(new InvalidOperationException("Cannot stop evaluator properly", e), Level.Error, "Exception during shut down.", Logger); } Logger.Log(Level.Info, "EvaluatorRuntime shutdown complete"); }