當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultOperatorStateBackend類代碼示例

本文整理匯總了Java中org.apache.flink.runtime.state.DefaultOperatorStateBackend的典型用法代碼示例。如果您正苦於以下問題:Java DefaultOperatorStateBackend類的具體用法?Java DefaultOperatorStateBackend怎麽用?Java DefaultOperatorStateBackend使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DefaultOperatorStateBackend類屬於org.apache.flink.runtime.state包,在下文中一共展示了DefaultOperatorStateBackend類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initializeState

import org.apache.flink.runtime.state.DefaultOperatorStateBackend; //導入依賴的package包/類
@Override
public void initializeState(FunctionInitializationContext context) throws Exception {
  if (checkpointCoder == null) {
    // no checkpoint coder available in this source
    return;
  }

  OperatorStateStore stateStore = context.getOperatorStateStore();
  CoderTypeInformation<
      KV<? extends UnboundedSource<OutputT, CheckpointMarkT>, CheckpointMarkT>>
      typeInformation = (CoderTypeInformation) new CoderTypeInformation<>(checkpointCoder);
  stateForCheckpoint = stateStore.getOperatorState(
      new ListStateDescriptor<>(DefaultOperatorStateBackend.DEFAULT_OPERATOR_STATE_NAME,
          typeInformation.createSerializer(new ExecutionConfig())));

  if (context.isRestored()) {
    isRestored = true;
    LOG.info("Having restore state in the UnbounedSourceWrapper.");
  } else {
    LOG.info("No restore state for UnbounedSourceWrapper.");
  }
}
 
開發者ID:apache,項目名稱:beam,代碼行數:23,代碼來源:UnboundedSourceWrapper.java

示例2: createOperatorStateBackend

import org.apache.flink.runtime.state.DefaultOperatorStateBackend; //導入依賴的package包/類
@Override
public OperatorStateBackend createOperatorStateBackend(Environment env, String operatorIdentifier) throws Exception {
	return new DefaultOperatorStateBackend(
		env.getUserClassLoader(),
		env.getExecutionConfig(),
		true) {
		@Override
		public RunnableFuture<OperatorStateHandle> snapshot(
			long checkpointId,
			long timestamp,
			CheckpointStreamFactory streamFactory,
			CheckpointOptions checkpointOptions) throws Exception {

			throw new Exception("Sync part snapshot exception.");
		}
	};
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:18,代碼來源:TaskCheckpointingBehaviourTest.java

示例3: initializeState

import org.apache.flink.runtime.state.DefaultOperatorStateBackend; //導入依賴的package包/類
@Override
public void initializeState(FunctionInitializationContext context) throws Exception {

	OperatorStateStore stateStore = context.getOperatorStateStore();
	offsetsStateForCheckpoint = stateStore.getSerializableListState(DefaultOperatorStateBackend.DEFAULT_OPERATOR_STATE_NAME);

	if (context.isRestored()) {
		restoreToOffset = new HashMap<>();
		for (Tuple2<KafkaTopicPartition, Long> kafkaOffset : offsetsStateForCheckpoint.get()) {
			restoreToOffset.put(kafkaOffset.f0, kafkaOffset.f1);
		}

		LOG.info("Setting restore state in the FlinkKafkaConsumer.");
		if (LOG.isDebugEnabled()) {
			LOG.debug("Using the following offsets: {}", restoreToOffset);
		}
	} else {
		LOG.info("No restore state for FlinkKafkaConsumer.");
	}
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:21,代碼來源:FlinkKafkaConsumerBase.java

示例4: createOperatorStateBackend

import org.apache.flink.runtime.state.DefaultOperatorStateBackend; //導入依賴的package包/類
@Override
public OperatorStateBackend createOperatorStateBackend(
		Environment env,
		String operatorIdentifier) throws Exception {

	//the default for RocksDB; eventually there can be a operator state backend based on RocksDB, too.
	final boolean asyncSnapshots = true;
	return new DefaultOperatorStateBackend(
			env.getUserClassLoader(),
			env.getExecutionConfig(),
			asyncSnapshots);
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:13,代碼來源:RocksDBStateBackend.java

示例5: createOperatorStateBackend

import org.apache.flink.runtime.state.DefaultOperatorStateBackend; //導入依賴的package包/類
@Override
public OperatorStateBackend createOperatorStateBackend(
	Environment env,
	String operatorIdentifier) throws Exception {

	return new DefaultOperatorStateBackend(
		env.getUserClassLoader(),
		env.getExecutionConfig(),
			isUsingAsynchronousSnapshots());
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:11,代碼來源:FsStateBackend.java

示例6: createOperatorStateBackend

import org.apache.flink.runtime.state.DefaultOperatorStateBackend; //導入依賴的package包/類
@Override
public OperatorStateBackend createOperatorStateBackend(
		Environment env,
		String operatorIdentifier) throws Exception {

	return new DefaultOperatorStateBackend(
			env.getUserClassLoader(),
			env.getExecutionConfig(),
			isUsingAsynchronousSnapshots());
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:11,代碼來源:MemoryStateBackend.java

示例7: trySnapshotFunctionState

import org.apache.flink.runtime.state.DefaultOperatorStateBackend; //導入依賴的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

示例8: tryRestoreFunction

import org.apache.flink.runtime.state.DefaultOperatorStateBackend; //導入依賴的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

示例9: createOperatorStateBackend

import org.apache.flink.runtime.state.DefaultOperatorStateBackend; //導入依賴的package包/類
@Override
public OperatorStateBackend createOperatorStateBackend(Environment env, String operatorIdentifier) throws Exception {
	return new DefaultOperatorStateBackend(
		getClass().getClassLoader(),
		new ExecutionConfig(),
		true);
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:8,代碼來源:BlockingCheckpointsTest.java


注:本文中的org.apache.flink.runtime.state.DefaultOperatorStateBackend類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。