@Test public void testShouldShutdownOnFatalError() throws Exception { Configuration configuration = createConfiguration(); configuration.setString(TaskManagerOptions.REGISTRATION_TIMEOUT, "42 h"); taskManagerRunner = createTaskManagerRunner(configuration); taskManagerRunner.onFatalError(new RuntimeException()); Integer statusCode = systemExitTrackingSecurityManager.getSystemExitFuture().get(); assertThat(statusCode, is(equalTo(TaskManagerRunner.RUNTIME_FAILURE_RETURN_CODE))); }
@Override public void onFatalError(Throwable exception) { LOG.error("Fatal error occurred while executing the TaskManager. Shutting it down...", exception); if (ExceptionUtils.isJvmFatalOrOutOfMemoryError(exception)) { terminateJVM(); } else { closeAsync(); FutureUtils.orTimeout(terminationFuture, FATAL_ERROR_SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS); terminationFuture.whenComplete( (Void ignored, Throwable throwable) -> { terminateJVM(); }); } }
TaskManagerRunner implements FatalErrorHandler, AutoCloseableAsync { @Override public void onFatalError(Throwable exception) { LOG.error("Fatal error occurred while executing the TaskManager. Shutting it down...", exception); if (ExceptionUtils.isJvmFatalOrOutOfMemoryError(exception)) { terminateJVM(); } else { closeAsync(); FutureUtils.orTimeout(terminationFuture, FATAL_ERROR_SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS); terminationFuture.whenComplete( (Void ignored, Throwable throwable) -> { terminateJVM(); }); } } }
TaskManagerRunner implements FatalErrorHandler, AutoCloseableAsync { @Override public void onFatalError(Throwable exception) { LOG.error("Fatal error occurred while executing the TaskManager. Shutting it down...", exception); if (ExceptionUtils.isJvmFatalOrOutOfMemoryError(exception)) { terminateJVM(); } else { closeAsync(); FutureUtils.orTimeout(terminationFuture, FATAL_ERROR_SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS); terminationFuture.whenComplete( (Void ignored, Throwable throwable) -> { terminateJVM(); }); } } TaskManagerRunner(Configuration configuration, ResourceID resourceId); }
TaskManagerRunner implements FatalErrorHandler, AutoCloseableAsync { @Override public void onFatalError(Throwable exception) { LOG.error("Fatal error occurred while executing the TaskManager. Shutting it down...", exception); if (ExceptionUtils.isJvmFatalOrOutOfMemoryError(exception)) { terminateJVM(); } else { closeAsync(); FutureUtils.orTimeout(terminationFuture, FATAL_ERROR_SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS); terminationFuture.whenComplete( (Void ignored, Throwable throwable) -> { terminateJVM(); }); } } TaskManagerRunner(Configuration configuration, ResourceID resourceId); void start(); @Override CompletableFuture<Void> closeAsync(); CompletableFuture<Void> getTerminationFuture(); @Override void onFatalError(Throwable exception); static void main(String[] args); static void runTaskManager(Configuration configuration, ResourceID resourceId); static TaskExecutor startTaskManager(
			Configuration configuration,
			ResourceID resourceID,
			RpcService rpcService,
			HighAvailabilityServices highAvailabilityServices,
			HeartbeatServices heartbeatServices,
			MetricRegistry metricRegistry,
			BlobCacheService blobCacheService,
			boolean localCommunicationOnly,
			FatalErrorHandler fatalErrorHandler); static RpcService createRpcService(
			final Configuration configuration,
			final HighAvailabilityServices haServices); }
TaskManagerRunner implements FatalErrorHandler, AutoCloseableAsync { @Override public void onFatalError(Throwable exception) { LOG.error("Fatal error occurred while executing the TaskManager. Shutting it down...", exception); if (ExceptionUtils.isJvmFatalOrOutOfMemoryError(exception)) { terminateJVM(); } else { closeAsync(); FutureUtils.orTimeout(terminationFuture, FATAL_ERROR_SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS); terminationFuture.whenComplete( (Void ignored, Throwable throwable) -> { terminateJVM(); }); } } TaskManagerRunner(Configuration configuration, ResourceID resourceId); void start(); @Override CompletableFuture<Void> closeAsync(); CompletableFuture<Void> getTerminationFuture(); @Override void onFatalError(Throwable exception); static void main(String[] args); static void runTaskManager(Configuration configuration, ResourceID resourceId); static TaskExecutor startTaskManager(
			Configuration configuration,
			ResourceID resourceID,
			RpcService rpcService,
			HighAvailabilityServices highAvailabilityServices,
			HeartbeatServices heartbeatServices,
			MetricRegistry metricRegistry,
			BlobCacheService blobCacheService,
			boolean localCommunicationOnly,
			FatalErrorHandler fatalErrorHandler); static RpcService createRpcService(
			final Configuration configuration,
			final HighAvailabilityServices haServices); static final int RUNTIME_FAILURE_RETURN_CODE; }