@Internal public abstract class CheckpointStateOutputStream extends FSDataOutputStream
StreamStateHandle
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". The close()
method is supposed to remove the
target resource if called before closeAndGetHandle()
, 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 and Description |
---|
CheckpointStateOutputStream() |
Modifier and Type | Method and 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.
|
flush, getPos, sync
write, write, write
@Nullable public abstract StreamStateHandle closeAndGetHandle() throws IOException
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.
IOException
- Thrown, if the stream cannot be closed.public abstract void close() throws IOException
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()
.
close
in interface Closeable
close
in interface AutoCloseable
close
in class FSDataOutputStream
IOException
- Thrown, if the stream cannot be closed.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.