java.io.Closeable, java.lang.AutoCloseable, org.apache.hadoop.fs.ByteBufferReadable, BlockReader@Private public class BlockReaderRemote extends java.lang.Object implements BlockReader
| Modifier | Constructor | Description |
|---|---|---|
protected |
BlockReaderRemote(java.lang.String file,
long blockId,
org.apache.hadoop.util.DataChecksum checksum,
boolean verifyChecksum,
long startOffset,
long firstChunkOffset,
long bytesToRead,
Peer peer,
DatanodeID datanodeID,
PeerCache peerCache,
int networkDistance) |
| Modifier and Type | Method | Description |
|---|---|---|
int |
available() |
Returns an estimate of the number of bytes that can be read
(or skipped over) from this input stream without performing
network I/O.
|
void |
close() |
Close the block reader.
|
ClientMmap |
getClientMmap(java.util.EnumSet<org.apache.hadoop.fs.ReadOption> opts) |
Get a ClientMmap object for this BlockReader.
|
org.apache.hadoop.util.DataChecksum |
getDataChecksum() |
|
static java.lang.String |
getFileName(java.net.InetSocketAddress s,
java.lang.String poolId,
long blockId) |
File name to print when accessing a block directly (from servlets)
|
int |
getNetworkDistance() |
Return the network distance between local machine and the remote machine.
|
Peer |
getPeer() |
|
boolean |
isShortCircuit() |
|
static BlockReader |
newBlockReader(java.lang.String file,
ExtendedBlock block,
org.apache.hadoop.security.token.Token<BlockTokenIdentifier> blockToken,
long startOffset,
long len,
boolean verifyChecksum,
java.lang.String clientName,
Peer peer,
DatanodeID datanodeID,
PeerCache peerCache,
CachingStrategy cachingStrategy,
int networkDistance,
org.apache.hadoop.conf.Configuration configuration) |
Create a new BlockReader specifically to satisfy a read.
|
int |
read(byte[] buf,
int off,
int len) |
|
int |
read(java.nio.ByteBuffer buf) |
|
int |
readAll(byte[] buf,
int offset,
int len) |
Similar to
BlockReader.readFully(byte[], int, int) except that it will
not throw an exception on EOF. |
void |
readFully(byte[] buf,
int off,
int len) |
Read exactly the given amount of data, throwing an exception
if EOF is reached before that amount
|
long |
skip(long n) |
Skip the given number of bytes
|
protected BlockReaderRemote(java.lang.String file,
long blockId,
org.apache.hadoop.util.DataChecksum checksum,
boolean verifyChecksum,
long startOffset,
long firstChunkOffset,
long bytesToRead,
Peer peer,
DatanodeID datanodeID,
PeerCache peerCache,
int networkDistance)
@VisibleForTesting public Peer getPeer()
public int read(byte[] buf,
int off,
int len)
throws java.io.IOException
read in interface BlockReaderjava.io.IOExceptionpublic int read(java.nio.ByteBuffer buf)
throws java.io.IOException
read in interface org.apache.hadoop.fs.ByteBufferReadablejava.io.IOExceptionpublic long skip(long n)
throws java.io.IOException
BlockReaderskip in interface BlockReaderjava.io.IOExceptionpublic void close()
throws java.io.IOException
BlockReaderclose in interface java.lang.AutoCloseableclose in interface BlockReaderclose in interface java.io.Closeablejava.io.IOExceptionpublic static java.lang.String getFileName(java.net.InetSocketAddress s,
java.lang.String poolId,
long blockId)
s - Address of the block locationpoolId - Block pool ID of the blockblockId - Block ID of the blockpublic int readAll(byte[] buf,
int offset,
int len)
throws java.io.IOException
BlockReaderBlockReader.readFully(byte[], int, int) except that it will
not throw an exception on EOF. However, it differs from the simple
BlockReader.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.readAll in interface BlockReaderjava.io.IOExceptionpublic void readFully(byte[] buf,
int off,
int len)
throws java.io.IOException
BlockReaderreadFully in interface BlockReaderjava.io.IOExceptionpublic static BlockReader newBlockReader(java.lang.String file, ExtendedBlock block, org.apache.hadoop.security.token.Token<BlockTokenIdentifier> blockToken, long startOffset, long len, boolean verifyChecksum, java.lang.String clientName, Peer peer, DatanodeID datanodeID, PeerCache peerCache, CachingStrategy cachingStrategy, int networkDistance, org.apache.hadoop.conf.Configuration configuration) throws java.io.IOException
file - File location.block - The block object.blockToken - The block token for security.startOffset - The read offset, relative to block head.len - The number of bytes to read.verifyChecksum - Whether to verify checksum.clientName - Client name.peer - The Peer to use.datanodeID - The DatanodeID this peer is connected to.peerCache - Caches TCP and UNIX domain sockets for reuse.cachingStrategy - Caching strategy to use when reading the block.networkDistance - Return the distance between two nodes by
comparing their network paths.configuration - Configuration of client.java.io.IOExceptionpublic int available()
BlockReaderavailable in interface BlockReaderpublic boolean isShortCircuit()
isShortCircuit in interface BlockReaderpublic ClientMmap getClientMmap(java.util.EnumSet<org.apache.hadoop.fs.ReadOption> opts)
BlockReadergetClientMmap in interface BlockReaderopts - The read options to use.public org.apache.hadoop.util.DataChecksum getDataChecksum()
getDataChecksum in interface BlockReaderpublic int getNetworkDistance()
BlockReadergetNetworkDistance in interface BlockReaderCopyright © 2008–2025 Apache Software Foundation. All rights reserved.