Class CheckpointStateOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.flink.core.fs.FSDataOutputStream
-
- org.apache.flink.runtime.state.CheckpointStateOutputStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
- Direct Known Subclasses:
DuplicatingCheckpointOutputStream
,FileBasedStateOutputStream
,FsCheckpointStreamFactory.FsCheckpointStateOutputStream
,MemCheckpointStreamFactory.MemoryCheckpointOutputStream
@Internal public abstract class CheckpointStateOutputStream extends FSDataOutputStream
A dedicated output stream that produces aStreamStateHandle
when closed.Important: When closing this stream after the successful case, you must call
closeAndGetHandle()
- only that method will actually retain the resource written to. The method has the semantics of "close on success". Theclose()
method is supposed to remove the target resource if called beforecloseAndGetHandle()
, hence having the semantics of "close on failure". That way, simple try-with-resources statements automatically clean up unsuccessful partial state resources in case the writing does not complete.Note: This is an abstract class and not an interface because
OutputStream
is an abstract class.
-
-
Constructor Summary
Constructors Constructor Description CheckpointStateOutputStream()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract void
close()
This method should close the stream, if has not been closed before.abstract StreamStateHandle
closeAndGetHandle()
Closes the stream and gets a state handle that can create an input stream producing the data written to this stream.-
Methods inherited from class org.apache.flink.core.fs.FSDataOutputStream
flush, getPos, sync
-
Methods inherited from class java.io.OutputStream
nullOutputStream, write, write, write
-
-
-
-
Method Detail
-
closeAndGetHandle
@Nullable public abstract StreamStateHandle closeAndGetHandle() throws IOException
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
close()
method removes the target resource when called.- 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 abstract void close() throws IOException
This method should close the stream, if has not been closed before. If this method actually closes the stream, it should delete/release the resource behind the stream, such as the file that the stream writes to.The above implies that this method is intended to be the "unsuccessful close", such as when cancelling the stream writing, or when an exception occurs. Closing the stream for the successful case must go through
closeAndGetHandle()
.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classFSDataOutputStream
- Throws:
IOException
- Thrown, if the stream cannot be closed.
-
-