Java Code Examples for org.apache.flink.util.ExceptionUtils#isJvmFatalOrOutOfMemoryError()

The following examples show how to use org.apache.flink.util.ExceptionUtils#isJvmFatalOrOutOfMemoryError() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskManagerRunner.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@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();
			});
	}
}
 
Example 2
Source File: TaskManagerRunner.java    From flink with Apache License 2.0 6 votes vote down vote up
@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();
			});
	}
}
 
Example 3
Source File: TaskManagerRunner.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void onFatalError(Throwable exception) {
	Throwable enrichedException = TaskManagerExceptionUtils.tryEnrichTaskManagerError(exception);
	LOG.error("Fatal error occurred while executing the TaskManager. Shutting it down...", enrichedException);

	// In case of the Metaspace OutOfMemoryError, we expect that the graceful shutdown is possible,
	// as it does not usually require more class loading to fail again with the Metaspace OutOfMemoryError.
	if (ExceptionUtils.isJvmFatalOrOutOfMemoryError(enrichedException) &&
			!ExceptionUtils.isMetaspaceOutOfMemoryError(enrichedException)) {
		terminateJVM();
	} else {
		closeAsync();

		FutureUtils.orTimeout(terminationFuture, FATAL_ERROR_SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS);

		terminationFuture.whenComplete(
			(Void ignored, Throwable throwable) -> terminateJVM());
	}
}
 
Example 4
Source File: Task.java    From flink with Apache License 2.0 5 votes vote down vote up
private void cancelOrFailAndCancelInvokable(ExecutionState targetState, Throwable cause) {
	try {
		cancelOrFailAndCancelInvokableInternal(targetState, cause);
	} catch (Throwable t) {
		if (ExceptionUtils.isJvmFatalOrOutOfMemoryError(t)) {
			String message = String.format("FATAL - exception in cancelling task %s (%s).", taskNameWithSubtask, executionId);
			notifyFatalError(message, t);
		} else {
			throw t;
		}
	}
}