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
ACheckpointStateOutputStreamthat writes into a segment of a file and returns aSegmentFileStateHandleupon closing. MultipleFileMergingCheckpointStateOutputStreamobjects 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 interfaceFileMergingCheckpointStateOutputStream.FileMergingSnapshotManagerProxyA proxy of theFileMergingSnapshotManagerthat 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 voidclose()This method throws no exception if the close fails, but only logs the error.SegmentFileStateHandlecloseAndGetHandle()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.voidflushToFile()org.apache.flink.core.fs.PathgetFilePath()longgetPos()voidsync()voidwrite(byte[] b, int off, int len)voidwrite(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:
getPosin classFsCheckpointStreamFactory.FsCheckpointStateOutputStream- Throws:
IOException
-
write
public void write(int b) throws IOException- Overrides:
writein classFsCheckpointStreamFactory.FsCheckpointStateOutputStream- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) throws IOException- Overrides:
writein classFsCheckpointStreamFactory.FsCheckpointStateOutputStream- Throws:
IOException
-
flush
public void flush() throws IOExceptionDescription 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
public void sync() throws IOException- Overrides:
syncin classFsCheckpointStreamFactory.FsCheckpointStateOutputStream- Throws:
IOException
-
closeAndGetHandle
@Nullable public SegmentFileStateHandle closeAndGetHandle() throws IOException
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
public void flushToFile() throws IOException- Overrides:
flushToFilein classFsCheckpointStreamFactory.FsCheckpointStateOutputStream- Throws:
IOException
-
getFilePath
@VisibleForTesting @Nullable public org.apache.flink.core.fs.Path getFilePath()
-
-