Package org.apache.hadoop.fs
Class FSDataOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.DataOutputStream
org.apache.hadoop.fs.FSDataOutputStream
- All Implemented Interfaces:
Closeable,DataOutput,Flushable,AutoCloseable,Abortable,CanSetDropBehind,org.apache.hadoop.fs.statistics.IOStatisticsSource,StreamCapabilities,Syncable
- Direct Known Subclasses:
HdfsDataOutputStream
@Public
@Stable
public class FSDataOutputStream
extends DataOutputStream
implements Syncable, CanSetDropBehind, StreamCapabilities, org.apache.hadoop.fs.statistics.IOStatisticsSource, Abortable
Utility that wraps a
OutputStream in a DataOutputStream.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hadoop.fs.Abortable
org.apache.hadoop.fs.Abortable.AbortableResultNested classes/interfaces inherited from interface org.apache.hadoop.fs.StreamCapabilities
StreamCapabilities.StreamCapability -
Field Summary
Fields inherited from class java.io.DataOutputStream
writtenFields 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
ConstructorsConstructorDescriptionFSDataOutputStream(OutputStream out, org.apache.hadoop.fs.FileSystem.Statistics stats) FSDataOutputStream(OutputStream out, org.apache.hadoop.fs.FileSystem.Statistics stats, long startPosition) -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hadoop.fs.Abortable.AbortableResultabort()Invokeabort()on the wrapped stream if it is Abortable, otherwise raise anUnsupportedOperationException.voidclose()Close the underlying output stream.Get the IO Statistics of the nested stream, falling back to empty statistics if the stream does not implement the interfaceIOStatisticsSource.longgetPos()Get the current position in the output stream.getWrappedStream()Get a reference to the wrapped output stream.booleanhasCapability(String capability) Query the stream for a specific capability.voidhflush()Flush out the data in client's user buffer.voidhsync()Similar to posix fsync, flush out the data in client's user buffer all the way to the disk device (but the disk may have it in its cache).voidsetDropBehind(Boolean dropBehind) Configure whether the stream should drop the cache.toString()Methods inherited from class java.io.DataOutputStream
flush, size, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTFMethods inherited from class java.io.FilterOutputStream
writeMethods inherited from class java.io.OutputStream
nullOutputStreamMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.io.DataOutput
write
-
Constructor Details
-
FSDataOutputStream
-
FSDataOutputStream
public FSDataOutputStream(OutputStream out, org.apache.hadoop.fs.FileSystem.Statistics stats, long startPosition)
-
-
Method Details
-
getPos
public long getPos()Get the current position in the output stream.- Returns:
- the current position in the output stream
-
close
Close the underlying output stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterOutputStream- Throws:
IOException
-
toString
-
getWrappedStream
Get a reference to the wrapped output stream.- Returns:
- the underlying output stream
-
hasCapability
Description copied from interface:StreamCapabilitiesQuery the stream for a specific capability.- Specified by:
hasCapabilityin interfaceStreamCapabilities- Parameters:
capability- string to query the stream support for.- Returns:
- True if the stream supports capability.
-
hflush
Description copied from interface:SyncableFlush out the data in client's user buffer. After the return of this call, new readers will see the data.- Specified by:
hflushin interfaceSyncable- Throws:
IOException- if any error occurs
-
hsync
Description copied from interface:SyncableSimilar to posix fsync, flush out the data in client's user buffer all the way to the disk device (but the disk may have it in its cache).- Specified by:
hsyncin interfaceSyncable- Throws:
IOException- if error occurs
-
setDropBehind
Description copied from interface:CanSetDropBehindConfigure whether the stream should drop the cache.- Specified by:
setDropBehindin interfaceCanSetDropBehind- Parameters:
dropBehind- Whether to drop the cache. null means to use the default value.- Throws:
IOException- If there was an error changing the dropBehind setting. UnsupportedOperationException If this stream doesn't support setting the drop-behind.
-
getIOStatistics
Get the IO Statistics of the nested stream, falling back to empty statistics if the stream does not implement the interfaceIOStatisticsSource.- Specified by:
getIOStatisticsin interfaceorg.apache.hadoop.fs.statistics.IOStatisticsSource- Returns:
- an IOStatistics instance.
-
abort
public org.apache.hadoop.fs.Abortable.AbortableResult abort()Invokeabort()on the wrapped stream if it is Abortable, otherwise raise anUnsupportedOperationException.- Specified by:
abortin interfaceAbortable- Returns:
- the result.
- Throws:
UnsupportedOperationException- if not available.
-