Class FileMergingCheckpointStateOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.flink.core.fs.FSDataOutputStream
-
- org.apache.flink.runtime.state.CheckpointStateOutputStream
-
- org.apache.flink.runtime.state.filesystem.FsCheckpointStreamFactory.FsCheckpointStateOutputStream
-
- org.apache.flink.runtime.state.filesystem.FileMergingCheckpointStateOutputStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
public class FileMergingCheckpointStateOutputStream extends FsCheckpointStreamFactory.FsCheckpointStateOutputStream
ACheckpointStateOutputStream
that writes into a segment of a file and returns aSegmentFileStateHandle
upon closing. MultipleFileMergingCheckpointStateOutputStream
objects can reuse the same underlying file, so that the checkpoint files are merged.Important: This implementation is NOT thread-safe. Multiple data streams multiplexing the same file should NOT write concurrently. Instead, it is expected that only after one data stream is closed, will other data streams reuse and write to the same underlying file.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
FileMergingCheckpointStateOutputStream.FileMergingSnapshotManagerProxy
A proxy of theFileMergingSnapshotManager
that owns thisFileMergingCheckpointStateOutputStream
, with the interfaces for dealing with physical files.
-
Constructor Summary
Constructors Constructor Description FileMergingCheckpointStateOutputStream(int bufferSize, FileMergingCheckpointStateOutputStream.FileMergingSnapshotManagerProxy fileMergingSnapshotManagerProxy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
This method throws no exception if the close fails, but only logs the error.SegmentFileStateHandle
closeAndGetHandle()
Closes the stream and gets a state handle that can create an input stream producing the data written to this stream.void
flush()
Flush buffers to file if their size is aboveFsCheckpointStreamFactory.FsCheckpointStateOutputStream.localStateThreshold
.void
flushToFile()
org.apache.flink.core.fs.Path
getFilePath()
long
getPos()
void
sync()
void
write(byte[] b, int off, int len)
void
write(int b)
-
Methods inherited from class org.apache.flink.runtime.state.filesystem.FsCheckpointStreamFactory.FsCheckpointStateOutputStream
isClosed
-
Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
-
-
-
Constructor Detail
-
FileMergingCheckpointStateOutputStream
public FileMergingCheckpointStateOutputStream(int bufferSize, FileMergingCheckpointStateOutputStream.FileMergingSnapshotManagerProxy fileMergingSnapshotManagerProxy)
-
-
Method Detail
-
getPos
public long getPos() throws IOException
- Overrides:
getPos
in classFsCheckpointStreamFactory.FsCheckpointStateOutputStream
- Throws:
IOException
-
write
public void write(int b) throws IOException
- Overrides:
write
in classFsCheckpointStreamFactory.FsCheckpointStateOutputStream
- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) throws IOException
- Overrides:
write
in classFsCheckpointStreamFactory.FsCheckpointStateOutputStream
- Throws:
IOException
-
flush
public void flush() throws IOException
Description copied from class:FsCheckpointStreamFactory.FsCheckpointStateOutputStream
Flush buffers to file if their size is aboveFsCheckpointStreamFactory.FsCheckpointStateOutputStream.localStateThreshold
.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classFsCheckpointStreamFactory.FsCheckpointStateOutputStream
- Throws:
IOException
-
sync
public void sync() throws IOException
- Overrides:
sync
in classFsCheckpointStreamFactory.FsCheckpointStateOutputStream
- Throws:
IOException
-
closeAndGetHandle
@Nullable public SegmentFileStateHandle closeAndGetHandle() throws IOException
Description copied from class:CheckpointStateOutputStream
Closes the stream and gets a state handle that can create an input stream producing the data written to this stream.This closing must be called (also when the caller is not interested in the handle) to successfully close the stream and retain the produced resource. In contrast, the
CheckpointStateOutputStream.close()
method removes the target resource when called.- Overrides:
closeAndGetHandle
in classFsCheckpointStreamFactory.FsCheckpointStateOutputStream
- Returns:
- A state handle that can create an input stream producing the data written to this stream.
- Throws:
IOException
- Thrown, if the stream cannot be closed.
-
close
public void close()
This method throws no exception if the close fails, but only logs the error. This is to be consistent withFsCheckpointStreamFactory.FsCheckpointStateOutputStream.close()
.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFsCheckpointStreamFactory.FsCheckpointStateOutputStream
-
flushToFile
public void flushToFile() throws IOException
- Overrides:
flushToFile
in classFsCheckpointStreamFactory.FsCheckpointStateOutputStream
- Throws:
IOException
-
getFilePath
@VisibleForTesting @Nullable public org.apache.flink.core.fs.Path getFilePath()
-
-