@Internal public class ClosingFSDataOutputStream extends FSDataOutputStreamWrapper implements WrappingProxyCloseable<FSDataOutputStream>
WrappingProxy
for FSDataOutputStream
that is used to
implement a safety net against unclosed streams.
See SafetyNetCloseableRegistry
for more details on how this is utilized.
outputStream
Constructor and Description |
---|
ClosingFSDataOutputStream(FSDataOutputStream delegate,
SafetyNetCloseableRegistry registry) |
Modifier and Type | Method and 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) |
flush, getPos, getWrappedDelegate, sync, write, write, write
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getWrappedDelegate
public ClosingFSDataOutputStream(FSDataOutputStream delegate, SafetyNetCloseableRegistry registry) throws IOException
IOException
public boolean isClosed()
public void close() throws IOException
FSDataOutputStream
class-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 the FSDataOutputStream
to implement
this method directly.
close
in interface Closeable
close
in interface AutoCloseable
close
in class FSDataOutputStreamWrapper
IOException
- Thrown, if an error occurred while closing the stream or guaranteeing
that the data is persistent.public static ClosingFSDataOutputStream wrapSafe(FSDataOutputStream delegate, SafetyNetCloseableRegistry registry) throws IOException
IOException
public static ClosingFSDataOutputStream wrapSafe(FSDataOutputStream delegate, SafetyNetCloseableRegistry registry, String debugInfo) throws IOException
IOException
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.