Java Code Examples for org.apache.flink.runtime.checkpoint.MasterTriggerRestoreHook#getIdentifier()

The following examples show how to use org.apache.flink.runtime.checkpoint.MasterTriggerRestoreHook#getIdentifier() . 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
/**
 * Resets the master hooks.
 *
 * @param hooks The hooks to reset
 *
 * @throws FlinkException Thrown, if the hooks throw an exception.
 */
public static void reset(
	final Collection<MasterTriggerRestoreHook<?>> hooks,
	final Logger log) throws FlinkException {

	for (MasterTriggerRestoreHook<?> hook : hooks) {
		final String id = hook.getIdentifier();
		try {
			hook.reset();
		}
		catch (Throwable t) {
			ExceptionUtils.rethrowIfFatalErrorOrOOM(t);
			throw new FlinkException("Error while resetting checkpoint master hook '" + id + '\'', t);
		}
	}
}
 
Example 2
Source File: MasterHooks.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private static <T> T deserializeState(MasterState state, MasterTriggerRestoreHook<?> hook) throws FlinkException {
	@SuppressWarnings("unchecked")
	final MasterTriggerRestoreHook<T> typedHook = (MasterTriggerRestoreHook<T>) hook;
	final String id = hook.getIdentifier();

	try {
		final SimpleVersionedSerializer<T> deserializer = typedHook.createCheckpointDataSerializer();
		if (deserializer == null) {
			throw new FlinkException("null serializer for state of hook " + hook.getIdentifier());
		}

		return deserializer.deserialize(state.version(), state.bytes());
	}
	catch (Throwable t) {
		throw new FlinkException("Cannot deserialize state for master hook '" + id + '\'', t);
	}
}
 
Example 3
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 4
Source File: MasterHooks.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Resets the master hooks.
 *
 * @param hooks The hooks to reset
 *
 * @throws FlinkException Thrown, if the hooks throw an exception.
 */
public static void reset(
	final Collection<MasterTriggerRestoreHook<?>> hooks,
	final Logger log) throws FlinkException {

	for (MasterTriggerRestoreHook<?> hook : hooks) {
		final String id = hook.getIdentifier();
		try {
			hook.reset();
		}
		catch (Throwable t) {
			ExceptionUtils.rethrowIfFatalErrorOrOOM(t);
			throw new FlinkException("Error while resetting checkpoint master hook '" + id + '\'', t);
		}
	}
}
 
Example 5
Source File: MasterHooks.java    From flink with Apache License 2.0 6 votes vote down vote up
private static <T> T deserializeState(MasterState state, MasterTriggerRestoreHook<?> hook) throws FlinkException {
	@SuppressWarnings("unchecked")
	final MasterTriggerRestoreHook<T> typedHook = (MasterTriggerRestoreHook<T>) hook;
	final String id = hook.getIdentifier();

	try {
		final SimpleVersionedSerializer<T> deserializer = typedHook.createCheckpointDataSerializer();
		if (deserializer == null) {
			throw new FlinkException("null serializer for state of hook " + hook.getIdentifier());
		}

		return deserializer.deserialize(state.version(), state.bytes());
	}
	catch (Throwable t) {
		throw new FlinkException("Cannot deserialize state for master hook '" + id + '\'', t);
	}
}
 
Example 6
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 7
Source File: MasterHooks.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Resets the master hooks.
 *
 * @param hooks The hooks to reset
 *
 * @throws FlinkException Thrown, if the hooks throw an exception.
 */
public static void reset(
	final Collection<MasterTriggerRestoreHook<?>> hooks,
	@SuppressWarnings("unused") final Logger log) throws FlinkException {

	for (MasterTriggerRestoreHook<?> hook : hooks) {
		final String id = hook.getIdentifier();
		try {
			hook.reset();
		}
		catch (Throwable t) {
			ExceptionUtils.rethrowIfFatalErrorOrOOM(t);
			throw new FlinkException("Error while resetting checkpoint master hook '" + id + '\'', t);
		}
	}
}
 
Example 8
Source File: MasterHooks.java    From flink with Apache License 2.0 6 votes vote down vote up
private static <T> T deserializeState(MasterState state, MasterTriggerRestoreHook<?> hook) throws FlinkException {
	@SuppressWarnings("unchecked")
	final MasterTriggerRestoreHook<T> typedHook = (MasterTriggerRestoreHook<T>) hook;
	final String id = hook.getIdentifier();

	try {
		final SimpleVersionedSerializer<T> deserializer = typedHook.createCheckpointDataSerializer();
		if (deserializer == null) {
			throw new FlinkException("null serializer for state of hook " + hook.getIdentifier());
		}

		return deserializer.deserialize(state.version(), state.bytes());
	}
	catch (Throwable t) {
		throw new FlinkException("Cannot deserialize state for master hook '" + id + '\'', t);
	}
}
 
Example 9
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);
	}
}