Package org.apache.hadoop.fs.statistics
Class BufferedIOStatisticsOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.BufferedOutputStream
org.apache.hadoop.fs.statistics.BufferedIOStatisticsOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,IOStatisticsSource,StreamCapabilities,Syncable
public class BufferedIOStatisticsOutputStream
extends BufferedOutputStream
implements IOStatisticsSource, Syncable, StreamCapabilities
An extension of
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.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hadoop.fs.StreamCapabilities
StreamCapabilities.StreamCapability -
Field Summary
Fields inherited from class java.io.BufferedOutputStream
buf, countFields inherited from class java.io.FilterOutputStream
outFields inherited from interface org.apache.hadoop.fs.StreamCapabilities
ABORTABLE_STREAM, DROPBEHIND, HFLUSH, HSYNC, IOSTATISTICS, IOSTATISTICS_CONTEXT, PREADBYTEBUFFER, READAHEAD, READBYTEBUFFER, UNBUFFER, VECTOREDIO, VECTOREDIO_BUFFERS_SLICED -
Constructor Summary
ConstructorsConstructorDescriptionBufferedIOStatisticsOutputStream(OutputStream out, boolean downgradeSyncable) Construct with default buffer size.BufferedIOStatisticsOutputStream(OutputStream out, int size, boolean downgradeSyncable) Construct with custom buffer size. -
Method Summary
Modifier and TypeMethodDescriptionAsk the inner stream for their IOStatistics.booleanhasCapability(String capability) If the inner stream supportsStreamCapabilities, forward the probe to it.voidhflush()If the inner stream is Syncable, flush the buffer and then invoke the inner stream's hflush() operation.voidhsync()If the inner stream is Syncable, flush the buffer and then invoke the inner stream's hsync() operation.Methods inherited from class java.io.BufferedOutputStream
flush, write, writeMethods inherited from class java.io.FilterOutputStream
close, writeMethods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
BufferedIOStatisticsOutputStream
Construct with default buffer size.- Parameters:
out- output stream to bufferdowngradeSyncable- should Syncable calls downgrade?
-
BufferedIOStatisticsOutputStream
Construct with custom buffer size.- Parameters:
out- output stream to buffersize- buffer.downgradeSyncable- should Syncable calls downgrade?
-
-
Method Details
-
getIOStatistics
Ask the inner stream for their IOStatistics.- Specified by:
getIOStatisticsin interfaceIOStatisticsSource- Returns:
- any IOStatistics offered by the inner stream.
-
hasCapability
If the inner stream supportsStreamCapabilities, forward the probe to it. Otherwise: return false.- Specified by:
hasCapabilityin interfaceStreamCapabilities- Parameters:
capability- string to query the stream support for.- Returns:
- true if a capability is known to be supported.
-
hflush
If the inner stream is Syncable, flush the buffer and then invoke the inner stream's hflush() operation. Otherwise: throw an exception, unless the stream was constructed withdowngradeSyncableset to true, in which case the stream is just flushed.- Specified by:
hflushin interfaceSyncable- Throws:
IOException- IO ProblemUnsupportedOperationException- if the inner class is not syncable
-
hsync
If the inner stream is Syncable, flush the buffer and then invoke the inner stream's hsync() operation. Otherwise: throw an exception, unless the stream was constructed withdowngradeSyncableset to true, in which case the stream is just flushed.- Specified by:
hsyncin interfaceSyncable- Throws:
IOException- IO ProblemUnsupportedOperationException- if the inner class is not syncable
-