Class ExternalBlockReader
java.lang.Object
org.apache.hadoop.hdfs.client.impl.ExternalBlockReader
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.fs.ByteBufferReadable,BlockReader
An ExternalBlockReader uses pluggable ReplicaAccessor objects to read from
replicas.
-
Method Summary
Modifier and TypeMethodDescriptionintReturns an estimate of the number of bytes that can be read (or skipped over) from this input stream without performing network I/O.voidclose()Close the block reader.getClientMmap(EnumSet<org.apache.hadoop.fs.ReadOption> opts) Get a ClientMmap object for this BlockReader.org.apache.hadoop.util.DataChecksumintReturn the network distance between local machine and the remote machine.booleanintread(byte[] buf, int off, int len) intread(ByteBuffer buf) intreadAll(byte[] buf, int offset, int len) Similar toBlockReader.readFully(byte[], int, int)except that it will not throw an exception on EOF.voidreadFully(byte[] buf, int offset, int len) Read exactly the given amount of data, throwing an exception if EOF is reached before that amountlongskip(long n) Skip the given number of bytes
-
Method Details
-
read
- Specified by:
readin interfaceBlockReader- Throws:
IOException
-
read
- Specified by:
readin interfaceorg.apache.hadoop.fs.ByteBufferReadable- Throws:
IOException
-
skip
Description copied from interface:BlockReaderSkip the given number of bytes- Specified by:
skipin interfaceBlockReader- Throws:
IOException
-
available
public int available()Description copied from interface:BlockReaderReturns an estimate of the number of bytes that can be read (or skipped over) from this input stream without performing network I/O. This may return more than what is actually present in the block.- Specified by:
availablein interfaceBlockReader
-
close
Description copied from interface:BlockReaderClose the block reader.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceBlockReader- Specified by:
closein interfaceCloseable- Throws:
IOException
-
readFully
Description copied from interface:BlockReaderRead exactly the given amount of data, throwing an exception if EOF is reached before that amount- Specified by:
readFullyin interfaceBlockReader- Throws:
IOException
-
readAll
Description copied from interface:BlockReaderSimilar toBlockReader.readFully(byte[], int, int)except that it will not throw an exception on EOF. However, it differs from the simpleBlockReader.read(byte[], int, int)call in that it is guaranteed to read the data if it is available. In other words, if this call does not throw an exception, then either the buffer has been filled or the next call will return EOF.- Specified by:
readAllin interfaceBlockReader- Throws:
IOException
-
isShortCircuit
public boolean isShortCircuit()- Specified by:
isShortCircuitin interfaceBlockReader- Returns:
- true only if this is a short-circuit read. All short-circuit reads are also local.
-
getClientMmap
Description copied from interface:BlockReaderGet a ClientMmap object for this BlockReader.- Specified by:
getClientMmapin interfaceBlockReader- Parameters:
opts- The read options to use.- Returns:
- The ClientMmap object, or null if mmap is not supported.
-
getDataChecksum
public org.apache.hadoop.util.DataChecksum getDataChecksum()- Specified by:
getDataChecksumin interfaceBlockReader- Returns:
- The DataChecksum used by the read block
-
getNetworkDistance
public int getNetworkDistance()Description copied from interface:BlockReaderReturn the network distance between local machine and the remote machine.- Specified by:
getNetworkDistancein interfaceBlockReader
-