@InterfaceAudience.Private public class DFSInputStream extends FSInputStream implements ByteBufferReadable, CanSetDropBehind, CanSetReadahead
| Modifier and Type | Class and Description |
|---|---|
static class |
DFSInputStream.ReadStatistics |
| Modifier and Type | Method and Description |
|---|---|
int |
available()
Return the size of the remaining available bytes
if the size is less than or equal to
Integer.MAX_VALUE,
otherwise, return Integer.MAX_VALUE. |
void |
close()
Close it down!
|
List<LocatedBlock> |
getAllBlocks()
Return collection of blocks that has already been located.
|
protected BlockReader |
getBlockReader(InetSocketAddress dnAddr,
DatanodeInfo chosenNode,
String file,
ExtendedBlock block,
Token<BlockTokenIdentifier> blockToken,
long startOffset,
long len,
int bufferSize,
boolean verifyChecksum,
String clientName)
Retrieve a BlockReader suitable for reading.
|
ExtendedBlock |
getCurrentBlock()
Returns the block containing the target position.
|
DatanodeInfo |
getCurrentDatanode()
Returns the datanode from which the stream is currently reading.
|
long |
getFileLength() |
long |
getPos()
Return the current offset from the start of the file
|
DFSInputStream.ReadStatistics |
getReadStatistics()
Get statistics about the reads which this DFSInputStream has done.
|
void |
mark(int readLimit) |
boolean |
markSupported()
We definitely don't support marks
|
int |
read() |
int |
read(byte[] buf,
int off,
int len)
Read the entire buffer.
|
int |
read(ByteBuffer buf)
Reads up to buf.remaining() bytes into buf.
|
int |
read(long position,
byte[] buffer,
int offset,
int length)
Read bytes starting from the specified position.
|
void |
reset() |
void |
seek(long targetPos)
Seek to a new arbitrary location
|
boolean |
seekToNewSource(long targetPos)
Seek to given position on a node other than the current node.
|
void |
setDropBehind(Boolean dropBehind)
Configure whether the stream should drop the cache.
|
void |
setReadahead(Long readahead)
Set the readahead on this stream.
|
long |
skip(long n) |
readFully, readFullyreadpublic long getFileLength()
public DatanodeInfo getCurrentDatanode()
public ExtendedBlock getCurrentBlock()
public List<LocatedBlock> getAllBlocks() throws IOException
IOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionpublic int read()
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] buf,
int off,
int len)
throws IOException
read in class InputStreamIOExceptionpublic int read(ByteBuffer buf) throws IOException
ByteBufferReadableUnsupportedOperationException, so
callers that are not confident in support for this method from the
underlying filesystem should be prepared to handle that exception.
Implementations should treat 0-length requests as legitimate, and must not
signal an error upon their receipt.read in interface ByteBufferReadablebuf - the ByteBuffer to receive the results of the read operation. Up to
buf.limit() - buf.position() bytes may be read.IOException - if there is some error performing the readprotected BlockReader getBlockReader(InetSocketAddress dnAddr, DatanodeInfo chosenNode, String file, ExtendedBlock block, Token<BlockTokenIdentifier> blockToken, long startOffset, long len, int bufferSize, boolean verifyChecksum, String clientName) throws IOException
dnAddr - Address of the datanodechosenNode - Chosen datanode informationfile - File locationblock - The Block objectblockToken - The access token for securitystartOffset - The read offset, relative to block headlen - The number of bytes to readbufferSize - The IO buffer size (not the client buffer size)verifyChecksum - Whether to verify checksumclientName - Client nameIOExceptionpublic int read(long position,
byte[] buffer,
int offset,
int length)
throws IOException
read in interface PositionedReadableread in class FSInputStreamposition - start read from this positionbuffer - read bufferoffset - offset into bufferlength - number of bytes to readIOExceptionpublic long skip(long n)
throws IOException
skip in class InputStreamIOExceptionpublic void seek(long targetPos)
throws IOException
seek in interface Seekableseek in class FSInputStreamIOExceptionpublic boolean seekToNewSource(long targetPos)
throws IOException
seekToNewSource in interface SeekableseekToNewSource in class FSInputStreamIOExceptionpublic long getPos()
throws IOException
FSInputStreamgetPos in interface SeekablegetPos in class FSInputStreamIOExceptionpublic int available()
throws IOException
Integer.MAX_VALUE,
otherwise, return Integer.MAX_VALUE.available in class InputStreamIOExceptionpublic boolean markSupported()
markSupported in class InputStreampublic void mark(int readLimit)
mark in class InputStreampublic void reset()
throws IOException
reset in class InputStreamIOExceptionpublic DFSInputStream.ReadStatistics getReadStatistics()
public void setReadahead(Long readahead) throws IOException
CanSetReadaheadsetReadahead in interface CanSetReadaheadreadahead - The readahead to use. null means to use the default.IOException - If there was an error changing the dropBehind
setting.
UnsupportedOperationException If this stream doesn't support
setting readahead.public void setDropBehind(Boolean dropBehind) throws IOException
CanSetDropBehindsetDropBehind in interface CanSetDropBehinddropBehind - Whether to drop the cache. null means to use the
default value.IOException - If there was an error changing the dropBehind
setting.
UnsupportedOperationException If this stream doesn't support
setting the drop-behind.Copyright © 2013 Apache Software Foundation. All rights reserved.