public class BufferedIOStatisticsOutputStream extends BufferedOutputStream implements IOStatisticsSource, Syncable, StreamCapabilities
BufferedOutputStream
which implements
IOStatisticsSource
and forwards requests for the
IOStatistics
to the wrapped stream.
This should be used when any output stream needs buffering while
allowing the inner stream to be a source of statistics.
It also implements StreamCapabilities
and Syncable
and forwards to to the inner stream,
if possible.StreamCapabilities.StreamCapability
buf, count
out
ABORTABLE_STREAM, DROPBEHIND, HFLUSH, HSYNC, IOSTATISTICS, PREADBYTEBUFFER, READAHEAD, READBYTEBUFFER, UNBUFFER
Constructor and Description |
---|
BufferedIOStatisticsOutputStream(OutputStream out,
boolean downgradeSyncable)
Construct with default buffer size.
|
BufferedIOStatisticsOutputStream(OutputStream out,
int size,
boolean downgradeSyncable)
Construct with custom buffer size.
|
Modifier and Type | Method and Description |
---|---|
IOStatistics |
getIOStatistics()
Ask the inner stream for their IOStatistics.
|
boolean |
hasCapability(String capability)
If the inner stream supports
StreamCapabilities ,
forward the probe to it. |
void |
hflush()
If the inner stream is Syncable, flush the buffer and then
invoke the inner stream's hflush() operation.
|
void |
hsync()
If the inner stream is Syncable, flush the buffer and then
invoke the inner stream's hsync() operation.
|
flush, write, write
close, write
public BufferedIOStatisticsOutputStream(OutputStream out, boolean downgradeSyncable)
out
- output stream to bufferdowngradeSyncable
- should Syncable calls downgrade?public BufferedIOStatisticsOutputStream(OutputStream out, int size, boolean downgradeSyncable)
out
- output stream to buffersize
- buffer.downgradeSyncable
- should Syncable calls downgrade?public IOStatistics getIOStatistics()
getIOStatistics
in interface IOStatisticsSource
public boolean hasCapability(String capability)
StreamCapabilities
,
forward the probe to it.
Otherwise: return false.hasCapability
in interface StreamCapabilities
capability
- string to query the stream support for.public void hflush() throws IOException
downgradeSyncable
set to true, in which case the stream
is just flushed.hflush
in interface Syncable
IOException
- IO ProblemUnsupportedOperationException
- if the inner class is not syncablepublic void hsync() throws IOException
downgradeSyncable
set to true, in which case the stream
is just flushed.hsync
in interface Syncable
IOException
- IO ProblemUnsupportedOperationException
- if the inner class is not syncableCopyright © 2008–2021 Apache Software Foundation. All rights reserved.