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
A
CheckpointStateOutputStream that writes into a segment of a file and returns a SegmentFileStateHandle upon closing. Multiple FileMergingCheckpointStateOutputStream
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 ClassesModifier and TypeClassDescriptionstatic interfaceA proxy of theFileMergingSnapshotManagerthat owns thisFileMergingCheckpointStateOutputStream, with the interfaces for dealing with physical files. -
Constructor Summary
ConstructorsConstructorDescriptionFileMergingCheckpointStateOutputStream(int bufferSize, FileMergingCheckpointStateOutputStream.FileMergingSnapshotManagerProxy fileMergingSnapshotManagerProxy) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()This method throws no exception if the close fails, but only logs the error.Closes the stream and gets a state handle that can create an input stream producing the data written to this stream.voidflush()Flush buffers to file if their size is aboveFsCheckpointStreamFactory.FsCheckpointStateOutputStream.localStateThreshold.voidorg.apache.flink.core.fs.PathlonggetPos()voidsync()voidwrite(byte[] b, int off, int len) voidwrite(int b) Methods inherited from class org.apache.flink.runtime.state.filesystem.FsCheckpointStreamFactory.FsCheckpointStateOutputStream
isClosedMethods inherited from class java.io.OutputStream
nullOutputStream, write
-
Constructor Details
-
FileMergingCheckpointStateOutputStream
public FileMergingCheckpointStateOutputStream(int bufferSize, FileMergingCheckpointStateOutputStream.FileMergingSnapshotManagerProxy fileMergingSnapshotManagerProxy)
-
-
Method Details
-
getPos
- Overrides:
getPosin classFsCheckpointStreamFactory.FsCheckpointStateOutputStream- Throws:
IOException
-
write
- Overrides:
writein classFsCheckpointStreamFactory.FsCheckpointStateOutputStream- Throws:
IOException
-
write
- Overrides:
writein classFsCheckpointStreamFactory.FsCheckpointStateOutputStream- Throws:
IOException
-
flush
Description copied from class:FsCheckpointStreamFactory.FsCheckpointStateOutputStreamFlush buffers to file if their size is aboveFsCheckpointStreamFactory.FsCheckpointStateOutputStream.localStateThreshold.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classFsCheckpointStreamFactory.FsCheckpointStateOutputStream- Throws:
IOException
-
sync
- Overrides:
syncin classFsCheckpointStreamFactory.FsCheckpointStateOutputStream- Throws:
IOException
-
closeAndGetHandle
Description copied from class:CheckpointStateOutputStreamCloses 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:
closeAndGetHandlein 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFsCheckpointStreamFactory.FsCheckpointStateOutputStream
-
flushToFile
- Overrides:
flushToFilein classFsCheckpointStreamFactory.FsCheckpointStateOutputStream- Throws:
IOException
-
getFilePath
@VisibleForTesting @Nullable public org.apache.flink.core.fs.Path getFilePath()
-