use of org.apache.flink.streaming.api.operators.StreamOperatorStateContext in project flink by apache.
the class OperatorStateInputFormat method open.
@Override
public void open(OperatorStateInputSplit split) throws IOException {
registry = new CloseableRegistry();
final StreamOperatorStateContext context = new StreamOperatorContextBuilder(getRuntimeContext(), configuration, operatorState, split, registry, backend).build(LOG);
restoredBackend = context.operatorStateBackend();
try {
elements = getElements(restoredBackend).iterator();
} catch (Exception e) {
throw new IOException("Failed to read operator state from restored state backend", e);
}
}
use of org.apache.flink.streaming.api.operators.StreamOperatorStateContext in project flink by apache.
the class KeyedStateInputFormat method open.
@Override
@SuppressWarnings("unchecked")
public void open(KeyGroupRangeInputSplit split) throws IOException {
registry = new CloseableRegistry();
final StreamOperatorStateContext context = new StreamOperatorContextBuilder(getRuntimeContext(), configuration, operatorState, split, registry, stateBackend).withMaxParallelism(split.getNumKeyGroups()).withKey(operator, operator.getKeyType().createSerializer(getRuntimeContext().getExecutionConfig())).build(LOG);
AbstractKeyedStateBackend<K> keyedStateBackend = (AbstractKeyedStateBackend<K>) context.keyedStateBackend();
final DefaultKeyedStateStore keyedStateStore = new DefaultKeyedStateStore(keyedStateBackend, getRuntimeContext().getExecutionConfig());
SavepointRuntimeContext ctx = new SavepointRuntimeContext(getRuntimeContext(), keyedStateStore);
InternalTimeServiceManager<K> timeServiceManager = (InternalTimeServiceManager<K>) context.internalTimerServiceManager();
try {
operator.setup(getRuntimeContext().getExecutionConfig(), keyedStateBackend, timeServiceManager, ctx);
operator.open();
keysAndNamespaces = operator.getKeysAndNamespaces(ctx);
} catch (Exception e) {
throw new IOException("Failed to restore timer state", e);
}
}
Aggregations