@Deprecated @PublicEvolving public class MemoryStateBackend extends AbstractFileStateBackend implements ConfigurableStateBackend
MemoryStateBackend
is deprecated in favor of HashMapStateBackend
and JobManagerCheckpointStorage
. This change does not affect
the runtime characteristics of your Jobs and is simply an API change to help better communicate
the ways Flink separates local state storage from fault tolerance. Jobs can be upgraded without
loss of state. If configuring your state backend via the StreamExecutionEnvironment
please make the following changes.
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setStateBackend(new HashMapStateBackend());
env.getCheckpointConfig().setCheckpointStorage(new JobManagerCheckpointStorage());
If you are configuring your state backend via the config.yaml
please make the
following changes:
state.backend.type: hashmap
execution.checkpointing.storage: jobmanager
This state backend holds the working state in the memory (JVM heap) of the TaskManagers. The state backend checkpoints state directly to the JobManager's memory (hence the backend's name), but the checkpoints will be persisted to a file system for high-availability setups and savepoints. The MemoryStateBackend is consequently a FileSystem-based backend that can work without a file system dependency in simple setups.
This state backend should be used only for experimentation, quick local setups, or for
streaming applications that have very small state: Because it requires checkpoints to go through
the JobManager's memory, larger state will occupy larger portions of the JobManager's main
memory, reducing operational stability. For any other setup, the FsStateBackend
should be used. The
FsStateBackend
holds the working state on the TaskManagers in the same way, but
checkpoints state directly to files rather than to the JobManager's memory, thus supporting large
state sizes.
State checkpointing with this state backend is subject to the following conditions:
getMaxStateSize()
.
For the use cases where the state sizes can be handled by this backend, the backend does guarantee persistence for savepoints, externalized checkpoints (of configured), and checkpoints (when high-availability is configured).
As for all state backends, this backend can either be configured within the application (by creating the backend with the respective constructor parameters and setting it on the execution environment) or by specifying it in the Flink configuration.
If the state backend was specified in the application, it may pick up additional configuration
parameters from the Flink configuration. For example, if the backend if configured in the
application without a default savepoint directory, it will pick up a default savepoint directory
specified in the Flink configuration of the running job/cluster. That behavior is implemented via
the configure(ReadableConfig, ClassLoader)
method.
StateBackend.CustomInitializationMetrics, StateBackend.KeyedStateBackendParameters<K>, StateBackend.OperatorStateBackendParameters
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_STATE_SIZE
Deprecated.
The default maximal size that the snapshotted memory state may have (5 MiBytes).
|
latencyTrackingConfigBuilder
Constructor and Description |
---|
MemoryStateBackend()
Deprecated.
Creates a new memory state backend that accepts states whose serialized forms are up to the
default state size (5 MB).
|
MemoryStateBackend(boolean asynchronousSnapshots)
Deprecated.
Creates a new memory state backend that accepts states whose serialized forms are up to the
default state size (5 MB).
|
MemoryStateBackend(int maxStateSize)
Deprecated.
Creates a new memory state backend that accepts states whose serialized forms are up to the
given number of bytes.
|
MemoryStateBackend(int maxStateSize,
boolean asynchronousSnapshots)
Deprecated.
Creates a new memory state backend that accepts states whose serialized forms are up to the
given number of bytes and that uses asynchronous snashots as configured.
|
MemoryStateBackend(String checkpointPath,
String savepointPath)
Deprecated.
Creates a new MemoryStateBackend, setting optionally the path to persist checkpoint metadata
to, and to persist savepoints to.
|
MemoryStateBackend(String checkpointPath,
String savepointPath,
int maxStateSize,
TernaryBoolean asynchronousSnapshots)
Deprecated.
Creates a new MemoryStateBackend, setting optionally the paths to persist checkpoint metadata
and savepoints to, as well as configuring state thresholds and asynchronous operations.
|
Modifier and Type | Method and Description |
---|---|
MemoryStateBackend |
configure(ReadableConfig config,
ClassLoader classLoader)
Deprecated.
Creates a copy of this state backend that uses the values defined in the configuration for
fields where that were not specified in this state backend.
|
CheckpointStorageAccess |
createCheckpointStorage(JobID jobId)
Deprecated.
Creates a storage for checkpoints for the given job.
|
<K> AbstractKeyedStateBackend<K> |
createKeyedStateBackend(StateBackend.KeyedStateBackendParameters<K> parameters)
Deprecated.
Creates a new
CheckpointableKeyedStateBackend that is responsible for holding
keyed state and checkpointing it. |
OperatorStateBackend |
createOperatorStateBackend(StateBackend.OperatorStateBackendParameters parameters)
Deprecated.
Creates a new
OperatorStateBackend that can be used for storing operator state. |
int |
getMaxStateSize()
Deprecated.
Gets the maximum size that an individual state can have, as configured in the constructor (by
default 5242880).
|
boolean |
isUsingAsynchronousSnapshots()
Deprecated.
Gets whether the key/value data structures are asynchronously snapshotted, which is always
true for this state backend.
|
boolean |
supportsNoClaimRestoreMode()
Deprecated.
Tells if a state backend supports the
RestoreMode.NO_CLAIM mode. |
boolean |
supportsSavepointFormat(SavepointFormatType formatType)
Deprecated.
|
String |
toString()
Deprecated.
|
getCheckpointPath, getSavepointPath, resolveCheckpoint
getCompressionDecorator
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createAsyncKeyedStateBackend, getName, supportsAsyncKeyedStateBackend, useManagedMemory
public static final int DEFAULT_MAX_STATE_SIZE
public MemoryStateBackend()
Checkpoint and default savepoint locations are used as specified in the runtime configuration.
public MemoryStateBackend(boolean asynchronousSnapshots)
Checkpoint and default savepoint locations are used as specified in the runtime configuration.
asynchronousSnapshots
- This parameter is only there for API compatibility. Checkpoints
are always asynchronous now.public MemoryStateBackend(int maxStateSize)
Checkpoint and default savepoint locations are used as specified in the runtime configuration.
WARNING: Increasing the size of this value beyond the default value (5242880) should be done with care. The checkpointed state needs to be send to the JobManager via limited size RPC messages, and there and the JobManager needs to be able to hold all aggregated state in its memory.
maxStateSize
- The maximal size of the serialized statepublic MemoryStateBackend(int maxStateSize, boolean asynchronousSnapshots)
Checkpoint and default savepoint locations are used as specified in the runtime configuration.
WARNING: Increasing the size of this value beyond the default value (5242880) should be done with care. The checkpointed state needs to be send to the JobManager via limited size RPC messages, and there and the JobManager needs to be able to hold all aggregated state in its memory.
maxStateSize
- The maximal size of the serialized stateasynchronousSnapshots
- This parameter is only there for API compatibility. Checkpoints
are always asynchronous now.public MemoryStateBackend(@Nullable String checkpointPath, @Nullable String savepointPath)
checkpointPath
- The path to write checkpoint metadata to. If null, the value from the
runtime configuration will be used.savepointPath
- The path to write savepoints to. If null, the value from the runtime
configuration will be used.public MemoryStateBackend(@Nullable String checkpointPath, @Nullable String savepointPath, int maxStateSize, TernaryBoolean asynchronousSnapshots)
WARNING: Increasing the size of this value beyond the default value (5242880) should be done with care. The checkpointed state needs to be send to the JobManager via limited size RPC messages, and there and the JobManager needs to be able to hold all aggregated state in its memory.
checkpointPath
- The path to write checkpoint metadata to. If null, the value from the
runtime configuration will be used.savepointPath
- The path to write savepoints to. If null, the value from the runtime
configuration will be used.maxStateSize
- The maximal size of the serialized state.asynchronousSnapshots
- This parameter is only there for API compatibility. Checkpoints
are always asynchronous now.public int getMaxStateSize()
public boolean isUsingAsynchronousSnapshots()
public boolean supportsNoClaimRestoreMode()
StateBackend
RestoreMode.NO_CLAIM
mode.
If a state backend supports NO_CLAIM
mode, it should create an independent
snapshot when it receives CheckpointType.FULL_CHECKPOINT
in Snapshotable.snapshot(long, long, CheckpointStreamFactory, CheckpointOptions)
.
supportsNoClaimRestoreMode
in interface StateBackend
RestoreMode.NO_CLAIM
mode.public boolean supportsSavepointFormat(SavepointFormatType formatType)
supportsSavepointFormat
in interface StateBackend
public MemoryStateBackend configure(ReadableConfig config, ClassLoader classLoader)
configure
in interface ConfigurableStateBackend
config
- The configurationclassLoader
- The class loaderpublic CheckpointStorageAccess createCheckpointStorage(JobID jobId) throws IOException
CheckpointStorage
createCheckpointStorage
in interface CheckpointStorage
jobId
- The job to store checkpoint data for.IOException
- Thrown if the checkpoint storage cannot be initialized.public OperatorStateBackend createOperatorStateBackend(StateBackend.OperatorStateBackendParameters parameters) throws Exception
StateBackend
OperatorStateBackend
that can be used for storing operator state.
Operator state is state that is associated with parallel operator (or function) instances, rather than with keys.
createOperatorStateBackend
in interface StateBackend
createOperatorStateBackend
in class AbstractStateBackend
parameters
- The arguments bundle for creating OperatorStateBackend
.Exception
- This method may forward all exceptions that occur while instantiating the
backend.public <K> AbstractKeyedStateBackend<K> createKeyedStateBackend(StateBackend.KeyedStateBackendParameters<K> parameters) throws BackendBuildingException
StateBackend
CheckpointableKeyedStateBackend
that is responsible for holding
keyed state and checkpointing it.
Keyed State is state where each value is bound to a key.
createKeyedStateBackend
in interface StateBackend
createKeyedStateBackend
in class AbstractStateBackend
K
- The type of the keys by which the state is organized.parameters
- The arguments bundle for creating CheckpointableKeyedStateBackend
.BackendBuildingException
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.