@Internal public class DefaultOperatorStateBackend extends Object implements OperatorStateBackend
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_OPERATOR_STATE_NAME
The default namespace for state in cases where no state name is provided
|
Constructor and Description |
---|
DefaultOperatorStateBackend(ClassLoader userClassLoader,
ExecutionConfig executionConfig,
boolean asynchronousSnapshots) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
dispose()
Disposes the backend and releases all resources.
|
ExecutionConfig |
getExecutionConfig() |
<S> ListState<S> |
getListState(ListStateDescriptor<S> stateDescriptor)
Creates (or restores) a list state.
|
<S> ListState<S> |
getOperatorState(ListStateDescriptor<S> stateDescriptor)
Deprecated.
This was deprecated as part of a refinement to the function names.
Please use
getListState(ListStateDescriptor) instead. |
Set<String> |
getRegisteredStateNames()
Returns a set with the names of all currently registered states.
|
<T extends Serializable> |
getSerializableListState(String stateName)
Deprecated.
Using Java serialization for persisting state is not encouraged.
Please use
getListState(ListStateDescriptor) instead. |
<S> ListState<S> |
getUnionListState(ListStateDescriptor<S> stateDescriptor)
Creates (or restores) a list state.
|
void |
restore(Collection<OperatorStateHandle> restoreSnapshots)
Restores state that was previously snapshotted from the provided parameters.
|
RunnableFuture<OperatorStateHandle> |
snapshot(long checkpointId,
long timestamp,
CheckpointStreamFactory streamFactory,
CheckpointOptions checkpointOptions)
Operation that writes a snapshot into a stream that is provided by the given
CheckpointStreamFactory and
returns a @RunnableFuture that gives a state handle to the snapshot. |
public static final String DEFAULT_OPERATOR_STATE_NAME
public DefaultOperatorStateBackend(ClassLoader userClassLoader, ExecutionConfig executionConfig, boolean asynchronousSnapshots) throws IOException
IOException
public ExecutionConfig getExecutionConfig()
public Set<String> getRegisteredStateNames()
OperatorStateStore
getRegisteredStateNames
in interface OperatorStateStore
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void dispose()
OperatorStateBackend
dispose
in interface OperatorStateBackend
public <S> ListState<S> getListState(ListStateDescriptor<S> stateDescriptor) throws Exception
OperatorStateStore
Note the semantic differences between an operator list state and a keyed list state
(see KeyedStateStore.getListState(ListStateDescriptor)
). Under the context of operator state,
the list is a collection of state items that are independent from each other and eligible for redistribution
across operator instances in case of changed operator parallelism. In other words, these state items are
the finest granularity at which non-keyed state can be redistributed, and should not be correlated with
each other.
The redistribution scheme of this list state upon operator rescaling is a round-robin pattern, such that the logical whole state (a concatenation of all the lists of state elements previously managed by each operator before the restore) is evenly divided into as many sublists as there are parallel operators.
getListState
in interface OperatorStateStore
S
- The generic type of the statestateDescriptor
- The descriptor for this state, providing a name and serializer.Exception
public <S> ListState<S> getUnionListState(ListStateDescriptor<S> stateDescriptor) throws Exception
OperatorStateStore
Note the semantic differences between an operator list state and a keyed list state
(see KeyedStateStore.getListState(ListStateDescriptor)
). Under the context of operator state,
the list is a collection of state items that are independent from each other and eligible for redistribution
across operator instances in case of changed operator parallelism. In other words, these state items are
the finest granularity at which non-keyed state can be redistributed, and should not be correlated with
each other.
The redistribution scheme of this list state upon operator rescaling is a broadcast pattern, such that the logical whole state (a concatenation of all the lists of state elements previously managed by each operator before the restore) is restored to all parallel operators so that each of them will get the union of all state items before the restore.
getUnionListState
in interface OperatorStateStore
S
- The generic type of the statestateDescriptor
- The descriptor for this state, providing a name and serializer.Exception
@Deprecated public <S> ListState<S> getOperatorState(ListStateDescriptor<S> stateDescriptor) throws Exception
getListState(ListStateDescriptor)
instead.OperatorStateStore
getOperatorState
in interface OperatorStateStore
S
- The generic type of the statestateDescriptor
- The descriptor for this state, providing a name and serializer.Exception
@Deprecated public <T extends Serializable> ListState<T> getSerializableListState(String stateName) throws Exception
getListState(ListStateDescriptor)
instead.OperatorStateStore
This is a simple convenience method. For more flexibility on how state serialization
should happen, use the OperatorStateStore.getListState(ListStateDescriptor)
method.
getSerializableListState
in interface OperatorStateStore
stateName
- The name of state to createException
public RunnableFuture<OperatorStateHandle> snapshot(long checkpointId, long timestamp, CheckpointStreamFactory streamFactory, CheckpointOptions checkpointOptions) throws Exception
Snapshotable
CheckpointStreamFactory
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.snapshot
in interface Snapshotable<OperatorStateHandle>
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.StateObject
.Exception
public void restore(Collection<OperatorStateHandle> restoreSnapshots) throws Exception
Snapshotable
restore
in interface Snapshotable<OperatorStateHandle>
restoreSnapshots
- the old state to restore.Exception
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.