public class FsStateBackend extends StateBackend<FsStateBackend>
The state backend has one core directory into which it puts all checkpoint data. Inside that
directory, it creates a directory per job, inside which each checkpoint gets a directory, with
files for each state, for example:
hdfs://namenode:port/flink-checkpoints/<job-id>/chk-17/6ba7b810-9dad-11d1-80b4-00c04fd430c8
Modifier and Type | Class and Description |
---|---|
static class |
FsStateBackend.FsCheckpointStateOutputStream
A CheckpointStateOutputStream that writes into a file and returns the path to that file upon
closing.
|
StateBackend.CheckpointStateOutputStream, StateBackend.CheckpointStateOutputView
Constructor and Description |
---|
FsStateBackend(Path checkpointDataUri)
Creates a new state backend that stores its checkpoint data in the file system and location
defined by the given URI.
|
FsStateBackend(String checkpointDataUri)
Creates a new state backend that stores its checkpoint data in the file system and location
defined by the given URI.
|
FsStateBackend(URI checkpointDataUri)
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 |
---|---|
<S extends Serializable> |
checkpointStateSerializable(S state,
long checkpointID,
long timestamp)
Writes the given state into the checkpoint, and returns a handle that can retrieve the state back.
|
void |
close()
Closes the state backend, releasing all internal resources, but does not delete any persistent
checkpoint data.
|
FsStateBackend.FsCheckpointStateOutputStream |
createCheckpointStateOutputStream(long checkpointID,
long timestamp)
Creates an output stream that writes into the state of the given checkpoint.
|
<K,V> FsHeapKvState<K,V> |
createKvState(TypeSerializer<K> keySerializer,
TypeSerializer<V> valueSerializer,
V defaultValue)
Creates a key/value state backed by this state backend.
|
void |
disposeAllStateForCurrentJob()
Disposes all state associated with the current job.
|
Path |
getBasePath()
Gets the base directory where all state-containing files are stored.
|
Path |
getCheckpointDirectory()
Gets the directory where this state backend stores its checkpoint data.
|
FileSystem |
getFileSystem()
Gets the file system handle for the file system that stores the state for this backend.
|
void |
initializeForJob(JobID jobId)
This method is called by the task upon deployment to initialize the state backend for
data for a specific job.
|
boolean |
isInitialized()
Checks whether this state backend is initialized.
|
String |
toString() |
createCheckpointStateOutputView
public FsStateBackend(String checkpointDataUri) throws IOException
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 teh checkpoint data directory.IOException
- Thrown, if no file system can be found for the scheme in the URI.public FsStateBackend(Path checkpointDataUri) throws IOException
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 teh checkpoint data directory.IOException
- Thrown, if no file system can be found for the scheme in the URI.public FsStateBackend(URI checkpointDataUri) throws IOException
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 teh checkpoint data directory.IOException
- Thrown, if no file system can be found for the scheme in the URI.public Path getBasePath()
public Path getCheckpointDirectory()
public boolean isInitialized()
public FileSystem getFileSystem()
public void initializeForJob(JobID jobId) throws Exception
StateBackend
initializeForJob
in class StateBackend<FsStateBackend>
jobId
- The ID of the job for which the state backend instance checkpoints data.Exception
- Overwritten versions of this method may throw exceptions, in which
case the job that uses the state backend is considered failed during
deployment.public void disposeAllStateForCurrentJob() throws Exception
StateBackend
disposeAllStateForCurrentJob
in class StateBackend<FsStateBackend>
Exception
- Exceptions may occur during disposal of the state and should be forwarded.public void close() throws Exception
StateBackend
close
in class StateBackend<FsStateBackend>
Exception
- Exceptions can be forwarded and will be logged by the systempublic <K,V> FsHeapKvState<K,V> createKvState(TypeSerializer<K> keySerializer, TypeSerializer<V> valueSerializer, V defaultValue) throws Exception
StateBackend
createKvState
in class StateBackend<FsStateBackend>
K
- The type of the key.V
- The type of the value.keySerializer
- The serializer for the key.valueSerializer
- The serializer for the value.defaultValue
- The value that is returned when no other value has been associated with a key, yet.Exception
- Exceptions may occur during initialization of the state and should be forwarded.public <S extends Serializable> StateHandle<S> checkpointStateSerializable(S state, long checkpointID, long timestamp) throws Exception
StateBackend
checkpointStateSerializable
in class StateBackend<FsStateBackend>
S
- The type of the state.state
- The state to be checkpointed.checkpointID
- The ID of the checkpoint.timestamp
- The timestamp of the checkpoint.Exception
- Exceptions may occur during serialization / storing the state and should be forwarded.public FsStateBackend.FsCheckpointStateOutputStream createCheckpointStateOutputStream(long checkpointID, long timestamp) throws Exception
StateBackend
createCheckpointStateOutputStream
in class StateBackend<FsStateBackend>
checkpointID
- The ID of the checkpoint.timestamp
- The timestamp of the checkpoint.Exception
- Exceptions may occur while creating the stream and should be forwarded.Copyright © 2014–2016 The Apache Software Foundation. All rights reserved.