当前位置: 首页>>代码示例>>Java>>正文


Java ListCheckpointed类代码示例

本文整理汇总了Java中org.apache.flink.streaming.api.checkpoint.ListCheckpointed的典型用法代码示例。如果您正苦于以下问题:Java ListCheckpointed类的具体用法?Java ListCheckpointed怎么用?Java ListCheckpointed使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ListCheckpointed类属于org.apache.flink.streaming.api.checkpoint包,在下文中一共展示了ListCheckpointed类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkUdfCheckpointingPreconditions

import org.apache.flink.streaming.api.checkpoint.ListCheckpointed; //导入依赖的package包/类
private void checkUdfCheckpointingPreconditions() {

		if (userFunction instanceof CheckpointedFunction
			&& userFunction instanceof ListCheckpointed) {

			throw new IllegalStateException("User functions are not allowed to implement " +
				"CheckpointedFunction AND ListCheckpointed.");
		}
	}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:AbstractUdfStreamOperator.java

示例2: trySnapshotFunctionState

import org.apache.flink.streaming.api.checkpoint.ListCheckpointed; //导入依赖的package包/类
private static boolean trySnapshotFunctionState(
		StateSnapshotContext context,
		OperatorStateBackend backend,
		Function userFunction) throws Exception {

	if (userFunction instanceof CheckpointedFunction) {
		((CheckpointedFunction) userFunction).snapshotState(context);

		return true;
	}

	if (userFunction instanceof ListCheckpointed) {
		@SuppressWarnings("unchecked")
		List<Serializable> partitionableState = ((ListCheckpointed<Serializable>) userFunction).
				snapshotState(context.getCheckpointId(), context.getCheckpointTimestamp());

		ListState<Serializable> listState = backend.
				getSerializableListState(DefaultOperatorStateBackend.DEFAULT_OPERATOR_STATE_NAME);

		listState.clear();

		if (null != partitionableState) {
			try {
				for (Serializable statePartition : partitionableState) {
					listState.add(statePartition);
				}
			} catch (Exception e) {
				listState.clear();

				throw new Exception("Could not write partitionable state to operator " +
					"state backend.", e);
			}
		}

		return true;
	}

	return false;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:40,代码来源:StreamingFunctionUtils.java

示例3: tryRestoreFunction

import org.apache.flink.streaming.api.checkpoint.ListCheckpointed; //导入依赖的package包/类
private static boolean tryRestoreFunction(
		StateInitializationContext context,
		Function userFunction) throws Exception {

	if (userFunction instanceof CheckpointedFunction) {
		((CheckpointedFunction) userFunction).initializeState(context);

		return true;
	}

	if (context.isRestored() && userFunction instanceof ListCheckpointed) {
		@SuppressWarnings("unchecked")
		ListCheckpointed<Serializable> listCheckpointedFun = (ListCheckpointed<Serializable>) userFunction;

		ListState<Serializable> listState = context.getOperatorStateStore().
				getSerializableListState(DefaultOperatorStateBackend.DEFAULT_OPERATOR_STATE_NAME);

		List<Serializable> list = new ArrayList<>();

		for (Serializable serializable : listState.get()) {
			list.add(serializable);
		}

		try {
			listCheckpointedFun.restoreState(list);
		} catch (Exception e) {

			throw new Exception("Failed to restore state to function: " + e.getMessage(), e);
		}

		return true;
	}

	return false;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:36,代码来源:StreamingFunctionUtils.java


注:本文中的org.apache.flink.streaming.api.checkpoint.ListCheckpointed类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。