Package org.apache.flink.core.fs
Class ClosingFSDataOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.flink.core.fs.FSDataOutputStream
-
- org.apache.flink.core.fs.FSDataOutputStreamWrapper
-
- org.apache.flink.core.fs.ClosingFSDataOutputStream
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,WrappingProxyCloseable<FSDataOutputStream>,WrappingProxy<FSDataOutputStream>
@Internal public class ClosingFSDataOutputStream extends FSDataOutputStreamWrapper implements WrappingProxyCloseable<FSDataOutputStream>
This class is aWrappingProxyforFSDataOutputStreamthat is used to implement a safety net against unclosed streams.See
SafetyNetCloseableRegistryfor more details on how this is utilized.
-
-
Field Summary
-
Fields inherited from class org.apache.flink.core.fs.FSDataOutputStreamWrapper
outputStream
-
-
Constructor Summary
Constructors Constructor Description ClosingFSDataOutputStream(FSDataOutputStream delegate, SafetyNetCloseableRegistry registry)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the output stream.booleanequals(Object obj)inthashCode()booleanisClosed()StringtoString()static ClosingFSDataOutputStreamwrapSafe(FSDataOutputStream delegate, SafetyNetCloseableRegistry registry)static ClosingFSDataOutputStreamwrapSafe(FSDataOutputStream delegate, SafetyNetCloseableRegistry registry, String debugInfo)-
Methods inherited from class org.apache.flink.core.fs.FSDataOutputStreamWrapper
flush, getPos, getWrappedDelegate, sync, write, write, write
-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.flink.util.WrappingProxy
getWrappedDelegate
-
-
-
-
Constructor Detail
-
ClosingFSDataOutputStream
public ClosingFSDataOutputStream(FSDataOutputStream delegate, SafetyNetCloseableRegistry registry) throws IOException
- Throws:
IOException
-
-
Method Detail
-
isClosed
public boolean isClosed()
-
close
public void close() throws IOExceptionDescription copied from class:FSDataOutputStreamCloses the output stream. After this method returns, the implementation must guarantee that all data written to the stream is persistent/visible, as defined in theclass-level docs.The above implies that the method must block until persistence can be guaranteed. For example for distributed replicated file systems, the method must block until the replication quorum has been reached. If the calling thread is interrupted in the process, it must fail with an
IOExceptionto indicate that persistence cannot be guaranteed.If this method throws an exception, the data in the stream cannot be assumed to be persistent.
Implementation note: This overrides the method defined in
OutputStreamas abstract to force implementations of theFSDataOutputStreamto implement this method directly.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFSDataOutputStreamWrapper- Throws:
IOException- Thrown, if an error occurred while closing the stream or guaranteeing that the data is persistent.
-
wrapSafe
public static ClosingFSDataOutputStream wrapSafe(FSDataOutputStream delegate, SafetyNetCloseableRegistry registry) throws IOException
- Throws:
IOException
-
wrapSafe
public static ClosingFSDataOutputStream wrapSafe(FSDataOutputStream delegate, SafetyNetCloseableRegistry registry, String debugInfo) throws IOException
- Throws:
IOException
-
-