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 aWrappingProxy
forFSDataOutputStream
that is used to implement a safety net against unclosed streams.See
SafetyNetCloseableRegistry
for 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 void
close()
Closes the output stream.boolean
equals(Object obj)
int
hashCode()
boolean
isClosed()
String
toString()
static ClosingFSDataOutputStream
wrapSafe(FSDataOutputStream delegate, SafetyNetCloseableRegistry registry)
static ClosingFSDataOutputStream
wrapSafe(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 IOException
Description copied from class:FSDataOutputStream
Closes 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
IOException
to 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
OutputStream
as abstract to force implementations of theFSDataOutputStream
to implement this method directly.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in 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
-
-