Package org.apache.flink.runtime.state
Class DefaultOperatorStateBackend
- java.lang.Object
-
- org.apache.flink.runtime.state.DefaultOperatorStateBackend
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.apache.flink.api.common.state.OperatorStateStore
,OperatorStateBackend
,Snapshotable<SnapshotResult<OperatorStateHandle>>
,org.apache.flink.util.Disposable
@Internal public class DefaultOperatorStateBackend extends Object implements OperatorStateBackend
Default implementation of OperatorStateStore that provides the ability to make snapshots.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_OPERATOR_STATE_NAME
The default namespace for state in cases where no state name is provided
-
Constructor Summary
Constructors Constructor Description DefaultOperatorStateBackend(org.apache.flink.api.common.ExecutionConfig executionConfig, org.apache.flink.core.fs.CloseableRegistry closeStreamOnCancelRegistry, Map<String,PartitionableListState<?>> registeredOperatorStates, Map<String,BackendWritableBroadcastState<?,?>> registeredBroadcastStates, Map<String,PartitionableListState<?>> accessedStatesByName, Map<String,BackendWritableBroadcastState<?,?>> accessedBroadcastStatesByName, SnapshotStrategyRunner<OperatorStateHandle,?> snapshotStrategyRunner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
dispose()
<K,V>
org.apache.flink.api.common.state.BroadcastState<K,V>getBroadcastState(org.apache.flink.api.common.state.MapStateDescriptor<K,V> stateDescriptor)
<K,V>
org.apache.flink.api.common.state.BroadcastState<K,V>getBroadcastState(org.apache.flink.api.common.state.v2.MapStateDescriptor<K,V> stateDescriptor)
org.apache.flink.api.common.ExecutionConfig
getExecutionConfig()
<S> org.apache.flink.api.common.state.ListState<S>
getListState(org.apache.flink.api.common.state.ListStateDescriptor<S> stateDescriptor)
<S> org.apache.flink.api.common.state.v2.ListState<S>
getListState(org.apache.flink.api.common.state.v2.ListStateDescriptor<S> stateDescriptor)
Set<String>
getRegisteredBroadcastStateNames()
Set<String>
getRegisteredStateNames()
<S> org.apache.flink.api.common.state.ListState<S>
getUnionListState(org.apache.flink.api.common.state.ListStateDescriptor<S> stateDescriptor)
<S> org.apache.flink.api.common.state.v2.ListState<S>
getUnionListState(org.apache.flink.api.common.state.v2.ListStateDescriptor<S> stateDescriptor)
RunnableFuture<SnapshotResult<OperatorStateHandle>>
snapshot(long checkpointId, long timestamp, CheckpointStreamFactory streamFactory, CheckpointOptions checkpointOptions)
Operation that writes a snapshot into a stream that is provided by the givenCheckpointStreamFactory
and returns a @RunnableFuture
that gives a state handle to the snapshot.
-
-
-
Field Detail
-
DEFAULT_OPERATOR_STATE_NAME
public static final String DEFAULT_OPERATOR_STATE_NAME
The default namespace for state in cases where no state name is provided- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultOperatorStateBackend
public DefaultOperatorStateBackend(org.apache.flink.api.common.ExecutionConfig executionConfig, org.apache.flink.core.fs.CloseableRegistry closeStreamOnCancelRegistry, Map<String,PartitionableListState<?>> registeredOperatorStates, Map<String,BackendWritableBroadcastState<?,?>> registeredBroadcastStates, Map<String,PartitionableListState<?>> accessedStatesByName, Map<String,BackendWritableBroadcastState<?,?>> accessedBroadcastStatesByName, SnapshotStrategyRunner<OperatorStateHandle,?> snapshotStrategyRunner)
-
-
Method Detail
-
getExecutionConfig
public org.apache.flink.api.common.ExecutionConfig getExecutionConfig()
-
getRegisteredStateNames
public Set<String> getRegisteredStateNames()
- Specified by:
getRegisteredStateNames
in interfaceorg.apache.flink.api.common.state.OperatorStateStore
-
getRegisteredBroadcastStateNames
public Set<String> getRegisteredBroadcastStateNames()
- Specified by:
getRegisteredBroadcastStateNames
in interfaceorg.apache.flink.api.common.state.OperatorStateStore
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceorg.apache.flink.util.Disposable
- Specified by:
dispose
in interfaceOperatorStateBackend
-
getBroadcastState
public <K,V> org.apache.flink.api.common.state.BroadcastState<K,V> getBroadcastState(org.apache.flink.api.common.state.MapStateDescriptor<K,V> stateDescriptor) throws org.apache.flink.util.StateMigrationException
- Specified by:
getBroadcastState
in interfaceorg.apache.flink.api.common.state.OperatorStateStore
- Throws:
org.apache.flink.util.StateMigrationException
-
getListState
public <S> org.apache.flink.api.common.state.ListState<S> getListState(org.apache.flink.api.common.state.ListStateDescriptor<S> stateDescriptor) throws Exception
- Specified by:
getListState
in interfaceorg.apache.flink.api.common.state.OperatorStateStore
- Throws:
Exception
-
getUnionListState
public <S> org.apache.flink.api.common.state.ListState<S> getUnionListState(org.apache.flink.api.common.state.ListStateDescriptor<S> stateDescriptor) throws Exception
- Specified by:
getUnionListState
in interfaceorg.apache.flink.api.common.state.OperatorStateStore
- Throws:
Exception
-
getBroadcastState
public <K,V> org.apache.flink.api.common.state.BroadcastState<K,V> getBroadcastState(org.apache.flink.api.common.state.v2.MapStateDescriptor<K,V> stateDescriptor) throws Exception
- Specified by:
getBroadcastState
in interfaceorg.apache.flink.api.common.state.OperatorStateStore
- Throws:
Exception
-
getListState
public <S> org.apache.flink.api.common.state.v2.ListState<S> getListState(org.apache.flink.api.common.state.v2.ListStateDescriptor<S> stateDescriptor) throws Exception
- Specified by:
getListState
in interfaceorg.apache.flink.api.common.state.OperatorStateStore
- Throws:
Exception
-
getUnionListState
public <S> org.apache.flink.api.common.state.v2.ListState<S> getUnionListState(org.apache.flink.api.common.state.v2.ListStateDescriptor<S> stateDescriptor) throws Exception
- Specified by:
getUnionListState
in interfaceorg.apache.flink.api.common.state.OperatorStateStore
- Throws:
Exception
-
snapshot
@Nonnull public RunnableFuture<SnapshotResult<OperatorStateHandle>> snapshot(long checkpointId, long timestamp, @Nonnull CheckpointStreamFactory streamFactory, @Nonnull CheckpointOptions checkpointOptions) throws Exception
Description copied from interface:Snapshotable
Operation that writes a snapshot into a stream that is provided by the givenCheckpointStreamFactory
and returns a @RunnableFuture
that gives a state handle to the snapshot. It is up to the implementation if the operation is performed synchronous or asynchronous. In the later case, the returned Runnable must be executed first before obtaining the handle.- Specified by:
snapshot
in interfaceSnapshotable<SnapshotResult<OperatorStateHandle>>
- Parameters:
checkpointId
- The ID of the checkpoint.timestamp
- The timestamp of the checkpoint.streamFactory
- The factory that we can use for writing our state to streams.checkpointOptions
- Options for how to perform this checkpoint.- Returns:
- A runnable future that will yield a
StateObject
. - Throws:
Exception
-
-