public abstract class FaultRecoveringOutputStream extends AbstractOutputStream
Subclasses must override replacementStream(java.io.IOException)
which will request a
replacement stream each time an IOException
is encountered on the
current stream.
closed
Constructor and Description |
---|
FaultRecoveringOutputStream(int maxReplayBufferLength,
OutputStream out) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
flush() |
boolean |
isRecoverable()
Returns true if errors in the underlying stream can currently be recovered.
|
protected abstract OutputStream |
replacementStream(IOException e)
Returns a replacement output stream to recover from
e thrown by the
previous stream. |
void |
replaceStream(OutputStream replacementStream)
Replaces the current output stream with
replacementStream , writing
any replay bytes to it if they exist. |
void |
write(byte[] buffer,
int offset,
int count) |
checkNotClosed, isClosed, write
write
public FaultRecoveringOutputStream(int maxReplayBufferLength, OutputStream out)
maxReplayBufferLength
- the maximum number of successfully written
bytes to buffer so they can be replayed in the event of an error.
Failure recoveries are not possible once this limit has been exceeded.public final void write(byte[] buffer, int offset, int count) throws IOException
write
in class OutputStream
IOException
public final void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public final void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
public boolean isRecoverable()
public final void replaceStream(OutputStream replacementStream) throws IOException
replacementStream
, writing
any replay bytes to it if they exist. The current output stream is closed.IOException
protected abstract OutputStream replacementStream(IOException e) throws IOException
e
thrown by the
previous stream. Returns a new OutputStream if recovery was successful, in
which case all previously-written data will be replayed. Returns null if
the failure cannot be recovered.IOException
Copyright © 2014. All rights reserved.