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

The following examples show how to use org.apache.flink.util.ExceptionUtils#rethrowIfFatalError() . 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: MasterHooks.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private static <T> void restoreHook(
		final Object state,
		final MasterTriggerRestoreHook<?> hook,
		final long checkpointId) throws FlinkException {

	@SuppressWarnings("unchecked")
	final T typedState = (T) state;

	@SuppressWarnings("unchecked")
	final MasterTriggerRestoreHook<T> typedHook = (MasterTriggerRestoreHook<T>) hook;

	try {
		typedHook.restoreCheckpoint(checkpointId, typedState);
	}
	catch (FlinkException e) {
		throw e;
	}
	catch (Throwable t) {
		// catch all here, including Errors that may come from dependency and classpath issues
		ExceptionUtils.rethrowIfFatalError(t);
		throw new FlinkException("Error while calling restoreCheckpoint on checkpoint hook '"
				+ hook.getIdentifier() + '\'', t);
	}
}
 
Example 2
Source File: MasterHooks.java    From flink with Apache License 2.0 6 votes vote down vote up
private static <T> void restoreHook(
		final Object state,
		final MasterTriggerRestoreHook<?> hook,
		final long checkpointId) throws FlinkException {

	@SuppressWarnings("unchecked")
	final T typedState = (T) state;

	@SuppressWarnings("unchecked")
	final MasterTriggerRestoreHook<T> typedHook = (MasterTriggerRestoreHook<T>) hook;

	try {
		typedHook.restoreCheckpoint(checkpointId, typedState);
	}
	catch (FlinkException e) {
		throw e;
	}
	catch (Throwable t) {
		// catch all here, including Errors that may come from dependency and classpath issues
		ExceptionUtils.rethrowIfFatalError(t);
		throw new FlinkException("Error while calling restoreCheckpoint on checkpoint hook '"
				+ hook.getIdentifier() + '\'', t);
	}
}
 
Example 3
Source File: MasterHooks.java    From flink with Apache License 2.0 6 votes vote down vote up
private static <T> void restoreHook(
		final Object state,
		final MasterTriggerRestoreHook<?> hook,
		final long checkpointId) throws FlinkException {

	@SuppressWarnings("unchecked")
	final T typedState = (T) state;

	@SuppressWarnings("unchecked")
	final MasterTriggerRestoreHook<T> typedHook = (MasterTriggerRestoreHook<T>) hook;

	try {
		typedHook.restoreCheckpoint(checkpointId, typedState);
	}
	catch (FlinkException e) {
		throw e;
	}
	catch (Throwable t) {
		// catch all here, including Errors that may come from dependency and classpath issues
		ExceptionUtils.rethrowIfFatalError(t);
		throw new FlinkException("Error while calling restoreCheckpoint on checkpoint hook '"
				+ hook.getIdentifier() + '\'', t);
	}
}
 
Example 4
Source File: TaskExecutor.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Acknowledge> sendOperatorEventToTask(
		ExecutionAttemptID executionAttemptID,
		OperatorID operatorId,
		SerializedValue<OperatorEvent> evt) {

	log.debug("Operator event for {} - {}", executionAttemptID, operatorId);

	final Task task = taskSlotTable.getTask(executionAttemptID);
	if (task == null) {
		return FutureUtils.completedExceptionally(new TaskNotRunningException(
			"Task " + executionAttemptID.toHexString() + " not running on TaskManager"));
	}

	try {
		task.deliverOperatorEvent(operatorId, evt);
		return CompletableFuture.completedFuture(Acknowledge.get());
	}
	catch (Throwable t) {
		ExceptionUtils.rethrowIfFatalError(t);
		return FutureUtils.completedExceptionally(t);
	}
}
 
Example 5
Source File: RefCountedFile.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private boolean tryClose() {
	try {
		Files.deleteIfExists(file.toPath());
		return true;
	} catch (Throwable t) {
		ExceptionUtils.rethrowIfFatalError(t);
	}
	return false;
}
 
Example 6
Source File: ExecutionGraph.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Called whenever a vertex reaches state FINISHED (completed successfully).
 * Once all vertices are in the FINISHED state, the program is successfully done.
 */
void vertexFinished() {
	assertRunningInJobMasterMainThread();
	final int numFinished = verticesFinished.incrementAndGet();
	if (numFinished == numVerticesTotal) {
		// done :-)

		// check whether we are still in "RUNNING" and trigger the final cleanup
		if (state == JobStatus.RUNNING) {
			// we do the final cleanup in the I/O executor, because it may involve
			// some heavier work

			try {
				for (ExecutionJobVertex ejv : verticesInCreationOrder) {
					ejv.getJobVertex().finalizeOnMaster(getUserClassLoader());
				}
			}
			catch (Throwable t) {
				ExceptionUtils.rethrowIfFatalError(t);
				failGlobal(new Exception("Failed to finalize execution on master", t));
				return;
			}

			// if we do not make this state transition, then a concurrent
			// cancellation or failure happened
			if (transitionState(JobStatus.RUNNING, JobStatus.FINISHED)) {
				onTerminalState(JobStatus.FINISHED);
			}
		}
	}
}
 
Example 7
Source File: RefCountedFile.java    From flink with Apache License 2.0 5 votes vote down vote up
private boolean tryClose() {
	try {
		Files.deleteIfExists(file.toPath());
		return true;
	} catch (Throwable t) {
		ExceptionUtils.rethrowIfFatalError(t);
	}
	return false;
}
 
Example 8
Source File: ExecutionGraph.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Called whenever a vertex reaches state FINISHED (completed successfully).
 * Once all vertices are in the FINISHED state, the program is successfully done.
 */
void vertexFinished() {
	assertRunningInJobMasterMainThread();
	final int numFinished = verticesFinished.incrementAndGet();
	if (numFinished == numVerticesTotal) {
		// done :-)

		// check whether we are still in "RUNNING" and trigger the final cleanup
		if (state == JobStatus.RUNNING) {
			// we do the final cleanup in the I/O executor, because it may involve
			// some heavier work

			try {
				for (ExecutionJobVertex ejv : verticesInCreationOrder) {
					ejv.getJobVertex().finalizeOnMaster(getUserClassLoader());
				}
			}
			catch (Throwable t) {
				ExceptionUtils.rethrowIfFatalError(t);
				failGlobal(new Exception("Failed to finalize execution on master", t));
				return;
			}

			// if we do not make this state transition, then a concurrent
			// cancellation or failure happened
			if (transitionState(JobStatus.RUNNING, JobStatus.FINISHED)) {
				onTerminalState(JobStatus.FINISHED);
			}
		}
	}
}
 
Example 9
Source File: PageSizeUtil.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Tries to get the system page size. If the page size cannot be determined, this
 * returns -1.
 *
 * <p>This internally relies on the presence of "unsafe" and the resolution via some
 * Netty utilities.
 */
public static int getSystemPageSize() {
	try {
		return PageSizeUtilInternal.getSystemPageSize();
	}
	catch (Throwable t) {
		ExceptionUtils.rethrowIfFatalError(t);
		return PAGE_SIZE_UNKNOWN;
	}
}
 
Example 10
Source File: RefCountedFile.java    From flink with Apache License 2.0 5 votes vote down vote up
private boolean tryClose() {
	try {
		Files.deleteIfExists(file.toPath());
		return true;
	} catch (Throwable t) {
		ExceptionUtils.rethrowIfFatalError(t);
	}
	return false;
}
 
Example 11
Source File: ExecutionGraph.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Called whenever a vertex reaches state FINISHED (completed successfully).
 * Once all vertices are in the FINISHED state, the program is successfully done.
 */
void vertexFinished() {
	assertRunningInJobMasterMainThread();
	final int numFinished = ++verticesFinished;
	if (numFinished == numVerticesTotal) {
		// done :-)

		// check whether we are still in "RUNNING" and trigger the final cleanup
		if (state == JobStatus.RUNNING) {
			// we do the final cleanup in the I/O executor, because it may involve
			// some heavier work

			try {
				for (ExecutionJobVertex ejv : verticesInCreationOrder) {
					ejv.getJobVertex().finalizeOnMaster(getUserClassLoader());
				}
			}
			catch (Throwable t) {
				ExceptionUtils.rethrowIfFatalError(t);
				failGlobal(new Exception("Failed to finalize execution on master", t));
				return;
			}

			// if we do not make this state transition, then a concurrent
			// cancellation or failure happened
			if (transitionState(JobStatus.RUNNING, JobStatus.FINISHED)) {
				onTerminalState(JobStatus.FINISHED);
			}
		}
	}
}
 
Example 12
Source File: PageSizeUtil.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Tries to get the system page size. If the page size cannot be determined, this
 * returns -1.
 *
 * <p>This internally relies on the presence of "unsafe" and the resolution via some
 * Netty utilities.
 */
public static int getSystemPageSize() {
	try {
		return PageSizeUtilInternal.getSystemPageSize();
	}
	catch (Throwable t) {
		ExceptionUtils.rethrowIfFatalError(t);
		return PAGE_SIZE_UNKNOWN;
	}
}