@Deprecated @PublicEvolving public class FsStateBackend extends AbstractFileStateBackend implements ConfigurableStateBackend
FsStateBackend
is deprecated in favor of HashMapStateBackend
and FileSystemCheckpointStorage
. 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("hdfs:///checkpoints");
If you are configuring your state backend via the config.yaml
please make the
following changes set your state backend type to "hashmap" state.backend.type: hashmap
.
This state backend holds the working state in the memory (JVM heap) of the TaskManagers. The state backend checkpoints state as files to a file system (hence the backend's name).
Each checkpoint individually will store all its files in a subdirectory that includes the
checkpoint number, such as hdfs://namenode:port/flink-checkpoints/chk-17/
.
Working state is kept on the TaskManager heap. If a TaskManager executes multiple tasks concurrently (if the TaskManager has multiple slots, or if slot-sharing is used) then the aggregate state of all tasks needs to fit into that TaskManager's memory.
This state backend stores small state chunks directly with the metadata, to avoid creating
many small files. The threshold for that is configurable. When increasing this threshold, the
size of the checkpoint metadata increases. The checkpoint metadata of all retained completed
checkpoints needs to fit into the JobManager's heap memory. This is typically not a problem,
unless the threshold getMinFileSizeThreshold()
is increased significantly.
Checkpoints from this state backend are as persistent and available as filesystem that is written to. If the file system is a persistent distributed file system, this state backend supports highly available setups. The backend additionally supports savepoints and externalized checkpoints.
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
latencyTrackingConfigBuilder
Constructor and Description |
---|
FsStateBackend(Path checkpointDataUri)
Deprecated.
Creates a new state backend that stores its checkpoint data in the file system and location
defined by the given URI.
|
FsStateBackend(Path checkpointDataUri,
boolean asynchronousSnapshots)
Deprecated.
Creates a new state backend that stores its checkpoint data in the file system and location
defined by the given URI.
|
FsStateBackend(String checkpointDataUri)
Deprecated.
Creates a new state backend that stores its checkpoint data in the file system and location
defined by the given URI.
|
FsStateBackend(String checkpointDataUri,
boolean asynchronousSnapshots)
Deprecated.
Creates a new state backend that stores its checkpoint data in the file system and location
defined by the given URI.
|
FsStateBackend(URI checkpointDataUri)
Deprecated.
Creates a new state backend that stores its checkpoint data in the file system and location
defined by the given URI.
|
FsStateBackend(URI checkpointDataUri,
boolean asynchronousSnapshots)
Deprecated.
Creates a new state backend that stores its checkpoint data in the file system and location
defined by the given URI.
|
FsStateBackend(URI checkpointDataUri,
int fileStateSizeThreshold)
Deprecated.
Creates a new state backend that stores its checkpoint data in the file system and location
defined by the given URI.
|
FsStateBackend(URI checkpointDataUri,
int fileStateSizeThreshold,
boolean asynchronousSnapshots)
Deprecated.
Creates a new state backend that stores its checkpoint data in the file system and location
defined by the given URI.
|
FsStateBackend(URI checkpointDataUri,
URI defaultSavepointDirectory)
Deprecated.
Creates a new state backend that stores its checkpoint data in the file system and location
defined by the given URI.
|
FsStateBackend(URI checkpointDirectory,
URI defaultSavepointDirectory,
int fileStateSizeThreshold,
int writeBufferSize,
TernaryBoolean asynchronousSnapshots)
Deprecated.
Creates a new state backend that stores its checkpoint data in the file system and location
defined by the given URI.
|
Modifier and Type | Method and Description |
---|---|
FsStateBackend |
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. |
Path |
getBasePath()
Deprecated.
Deprecated in favor of
getCheckpointPath() . |
Path |
getCheckpointPath()
Deprecated.
Gets the base directory where all the checkpoints are stored.
|
int |
getMinFileSizeThreshold()
Deprecated.
Gets the threshold below which state is stored as part of the metadata, rather than in files.
|
int |
getWriteBufferSize()
Deprecated.
Gets the write buffer size for created checkpoint stream.
|
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.
|
getSavepointPath, resolveCheckpoint
getCompressionDecorator
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createAsyncKeyedStateBackend, getName, supportsAsyncKeyedStateBackend, useManagedMemory
public FsStateBackend(String checkpointDataUri)
A file system for the file system scheme in the URI (e.g., 'file://', 'hdfs://', or
'S3://') must be accessible via FileSystem.get(URI)
.
For a state backend targeting HDFS, this means that the URI must either specify the authority (host and port), or that the Hadoop configuration that describes that information must be in the classpath.
checkpointDataUri
- The URI describing the filesystem (scheme and optionally authority),
and the path to the checkpoint data directory.public FsStateBackend(String checkpointDataUri, boolean asynchronousSnapshots)
A file system for the file system scheme in the URI (e.g., 'file://', 'hdfs://', or
'S3://') must be accessible via FileSystem.get(URI)
.
For a state backend targeting HDFS, this means that the URI must either specify the authority (host and port), or that the Hadoop configuration that describes that information must be in the classpath.
checkpointDataUri
- The URI describing the filesystem (scheme and optionally authority),
and the path to the checkpoint data directory.asynchronousSnapshots
- This parameter is only there for API compatibility. Checkpoints
are always asynchronous now.public FsStateBackend(Path checkpointDataUri)
A file system for the file system scheme in the URI (e.g., 'file://', 'hdfs://', or
'S3://') must be accessible via FileSystem.get(URI)
.
For a state backend targeting HDFS, this means that the URI must either specify the authority (host and port), or that the Hadoop configuration that describes that information must be in the classpath.
checkpointDataUri
- The URI describing the filesystem (scheme and optionally authority),
and the path to the checkpoint data directory.public FsStateBackend(Path checkpointDataUri, boolean asynchronousSnapshots)
A file system for the file system scheme in the URI (e.g., 'file://', 'hdfs://', or
'S3://') must be accessible via FileSystem.get(URI)
.
For a state backend targeting HDFS, this means that the URI must either specify the authority (host and port), or that the Hadoop configuration that describes that information must be in the classpath.
checkpointDataUri
- The URI describing the filesystem (scheme and optionally authority),
and the path to the checkpoint data directory.asynchronousSnapshots
- This parameter is only there for API compatibility. Checkpoints
are always asynchronous now.public FsStateBackend(URI checkpointDataUri)
A file system for the file system scheme in the URI (e.g., 'file://', 'hdfs://', or
'S3://') must be accessible via FileSystem.get(URI)
.
For a state backend targeting HDFS, this means that the URI must either specify the authority (host and port), or that the Hadoop configuration that describes that information must be in the classpath.
checkpointDataUri
- The URI describing the filesystem (scheme and optionally authority),
and the path to the checkpoint data directory.public FsStateBackend(URI checkpointDataUri, @Nullable URI defaultSavepointDirectory)
A file system for the file system scheme in the URI (e.g., 'file://', 'hdfs://', or
'S3://') must be accessible via FileSystem.get(URI)
.
For a state backend targeting HDFS, this means that the URI must either specify the authority (host and port), or that the Hadoop configuration that describes that information must be in the classpath.
checkpointDataUri
- The URI describing the filesystem (scheme and optionally authority),
and the path to the checkpoint data directory.defaultSavepointDirectory
- The default directory to store savepoints to. May be null.public FsStateBackend(URI checkpointDataUri, boolean asynchronousSnapshots)
A file system for the file system scheme in the URI (e.g., 'file://', 'hdfs://', or
'S3://') must be accessible via FileSystem.get(URI)
.
For a state backend targeting HDFS, this means that the URI must either specify the authority (host and port), or that the Hadoop configuration that describes that information must be in the classpath.
checkpointDataUri
- The URI describing the filesystem (scheme and optionally authority),
and the path to the checkpoint data directory.asynchronousSnapshots
- This parameter is only there for API compatibility. Checkpoints
are always asynchronous now.public FsStateBackend(URI checkpointDataUri, int fileStateSizeThreshold)
A file system for the file system scheme in the URI (e.g., 'file://', 'hdfs://', or
'S3://') must be accessible via FileSystem.get(URI)
.
For a state backend targeting HDFS, this means that the URI must either specify the authority (host and port), or that the Hadoop configuration that describes that information must be in the classpath.
checkpointDataUri
- The URI describing the filesystem (scheme and optionally authority),
and the path to the checkpoint data directory.fileStateSizeThreshold
- State up to this size will be stored as part of the metadata,
rather than in filespublic FsStateBackend(URI checkpointDataUri, int fileStateSizeThreshold, boolean asynchronousSnapshots)
A file system for the file system scheme in the URI (e.g., 'file://', 'hdfs://', or
'S3://') must be accessible via FileSystem.get(URI)
.
For a state backend targeting HDFS, this means that the URI must either specify the authority (host and port), or that the Hadoop configuration that describes that information must be in the classpath.
checkpointDataUri
- The URI describing the filesystem (scheme and optionally authority),
and the path to the checkpoint data directory.fileStateSizeThreshold
- State up to this size will be stored as part of the metadata,
rather than in files (-1 for default value).asynchronousSnapshots
- This parameter is only there for API compatibility. Checkpoints
are always asynchronous now.public FsStateBackend(URI checkpointDirectory, @Nullable URI defaultSavepointDirectory, int fileStateSizeThreshold, int writeBufferSize, TernaryBoolean asynchronousSnapshots)
A file system for the file system scheme in the URI (e.g., 'file://', 'hdfs://', or
'S3://') must be accessible via FileSystem.get(URI)
.
For a state backend targeting HDFS, this means that the URI must either specify the authority (host and port), or that the Hadoop configuration that describes that information must be in the classpath.
checkpointDirectory
- The path to write checkpoint metadata to.defaultSavepointDirectory
- The path to write savepoints to. If null, the value from the
runtime configuration will be used, or savepoint target locations need to be passed when
triggering a savepoint.fileStateSizeThreshold
- State below this size will be stored as part of the metadata,
rather than in files. If -1, the value configured in the runtime configuration will be
used, or the default value (1KB) if nothing is configured.writeBufferSize
- Write buffer size used to serialize state. If -1, the value configured
in the runtime configuration will be used, or the default value (4KB) if nothing is
configured.asynchronousSnapshots
- This parameter is only there for API compatibility. Checkpoints
are always asynchronous now.@Deprecated public Path getBasePath()
getCheckpointPath()
.@Nonnull public Path getCheckpointPath()
getCheckpointPath
in class AbstractFileStateBackend
public int getMinFileSizeThreshold()
If not explicitly configured, this is the default value of CheckpointingOptions.FS_SMALL_FILE_THRESHOLD
.
public int getWriteBufferSize()
If not explicitly configured, this is the default value of CheckpointingOptions.FS_WRITE_BUFFER_SIZE
.
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 FsStateBackend configure(ReadableConfig config, ClassLoader classLoader)
configure
in interface ConfigurableStateBackend
config
- the configurationclassLoader
- The class loader that should be used to load the state backend.public 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 <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
public OperatorStateBackend createOperatorStateBackend(StateBackend.OperatorStateBackendParameters parameters) throws BackendBuildingException
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
.BackendBuildingException
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.