Search in sources :

Example 1 with SavepointRuntimeContext

use of org.apache.flink.state.api.runtime.SavepointRuntimeContext 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);
    }
}
Also used : SavepointRuntimeContext(org.apache.flink.state.api.runtime.SavepointRuntimeContext) StreamOperatorStateContext(org.apache.flink.streaming.api.operators.StreamOperatorStateContext) AbstractKeyedStateBackend(org.apache.flink.runtime.state.AbstractKeyedStateBackend) IOException(java.io.IOException) CloseableRegistry(org.apache.flink.core.fs.CloseableRegistry) InternalTimeServiceManager(org.apache.flink.streaming.api.operators.InternalTimeServiceManager) IOException(java.io.IOException) DefaultKeyedStateStore(org.apache.flink.runtime.state.DefaultKeyedStateStore)

Aggregations

IOException (java.io.IOException)1 CloseableRegistry (org.apache.flink.core.fs.CloseableRegistry)1 AbstractKeyedStateBackend (org.apache.flink.runtime.state.AbstractKeyedStateBackend)1 DefaultKeyedStateStore (org.apache.flink.runtime.state.DefaultKeyedStateStore)1 SavepointRuntimeContext (org.apache.flink.state.api.runtime.SavepointRuntimeContext)1 InternalTimeServiceManager (org.apache.flink.streaming.api.operators.InternalTimeServiceManager)1 StreamOperatorStateContext (org.apache.flink.streaming.api.operators.StreamOperatorStateContext)1