Class FsCheckpointStreamFactory.FsCheckpointStateOutputStream
- 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
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
- Direct Known Subclasses:
FileMergingCheckpointStateOutputStream
- Enclosing class:
- FsCheckpointStreamFactory
public static class FsCheckpointStreamFactory.FsCheckpointStateOutputStream extends CheckpointStateOutputStream
ACheckpointStateOutputStream
that writes into a file and returns aStreamStateHandle
upon closing.
-
-
Constructor Summary
Constructors Constructor Description FsCheckpointStateOutputStream(org.apache.flink.core.fs.Path basePath, org.apache.flink.core.fs.FileSystem fs, int bufferSize, int localStateThreshold)
FsCheckpointStateOutputStream(org.apache.flink.core.fs.Path basePath, org.apache.flink.core.fs.FileSystem fs, int bufferSize, int localStateThreshold, boolean allowRelativePaths)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
If the stream is only closed, we remove the produced file (cleanup through the auto close feature, for example).StreamStateHandle
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 abovelocalStateThreshold
.void
flushToFile()
long
getPos()
boolean
isClosed()
Checks whether the stream is closed.void
sync()
void
write(byte[] b, int off, int len)
void
write(int b)
-
Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
-
-
-
Constructor Detail
-
FsCheckpointStateOutputStream
public FsCheckpointStateOutputStream(org.apache.flink.core.fs.Path basePath, org.apache.flink.core.fs.FileSystem fs, int bufferSize, int localStateThreshold)
-
FsCheckpointStateOutputStream
public FsCheckpointStateOutputStream(org.apache.flink.core.fs.Path basePath, org.apache.flink.core.fs.FileSystem fs, int bufferSize, int localStateThreshold, boolean allowRelativePaths)
-
-
Method Detail
-
write
public void write(int b) throws IOException
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) throws IOException
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
getPos
public long getPos() throws IOException
- Specified by:
getPos
in classorg.apache.flink.core.fs.FSDataOutputStream
- Throws:
IOException
-
flushToFile
public void flushToFile() throws IOException
- Throws:
IOException
-
flush
public void flush() throws IOException
Flush buffers to file if their size is abovelocalStateThreshold
.- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in classorg.apache.flink.core.fs.FSDataOutputStream
- Throws:
IOException
-
sync
public void sync() throws IOException
- Specified by:
sync
in classorg.apache.flink.core.fs.FSDataOutputStream
- Throws:
IOException
-
isClosed
public boolean isClosed()
Checks whether the stream is closed.- Returns:
- True if the stream was closed, false if it is still open.
-
close
public void close()
If the stream is only closed, we remove the produced file (cleanup through the auto close feature, for example). This method throws no exception if the deletion fails, but only logs the error.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classCheckpointStateOutputStream
-
closeAndGetHandle
@Nullable public StreamStateHandle 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.- Specified by:
closeAndGetHandle
in classCheckpointStateOutputStream
- 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.
-
-