|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
org.apache.hadoop.fs.FSInputStream
org.apache.hadoop.fs.FSInputChecker
org.apache.hadoop.hdfs.BlockReader
@InterfaceAudience.Private public class BlockReader
This is a wrapper around connection to datanode and understands checksum, offset etc. Terminology:
Field Summary |
---|
Fields inherited from class org.apache.hadoop.fs.FSInputChecker |
---|
CHECKSUM_SIZE, file, LOG |
Method Summary | |
---|---|
void |
close()
|
protected long |
getChunkPosition(long pos)
|
static String |
getFileName(InetSocketAddress s,
long blockId)
|
boolean |
hasSentStatusCode()
Whether the BlockReader has reached the end of its input stream and successfully sent a status code back to the datanode. |
static BlockReader |
newBlockReader(Socket sock,
String file,
Block block,
org.apache.hadoop.security.token.Token<BlockTokenIdentifier> blockToken,
long startOffset,
long len,
int bufferSize)
|
static BlockReader |
newBlockReader(Socket sock,
String file,
Block block,
org.apache.hadoop.security.token.Token<BlockTokenIdentifier> blockToken,
long startOffset,
long len,
int bufferSize,
boolean verifyChecksum)
Java Doc required |
static BlockReader |
newBlockReader(Socket sock,
String file,
Block block,
org.apache.hadoop.security.token.Token<BlockTokenIdentifier> blockToken,
long startOffset,
long len,
int bufferSize,
boolean verifyChecksum,
String clientName)
Create a new BlockReader specifically to satisfy a read. |
int |
read()
|
int |
read(byte[] buf,
int off,
int len)
|
int |
readAll(byte[] buf,
int offset,
int len)
kind of like readFully(). |
protected int |
readChunk(long pos,
byte[] buf,
int offset,
int len,
byte[] checksumBuf)
|
void |
seek(long pos)
|
boolean |
seekToNewSource(long targetPos)
|
long |
skip(long n)
|
Socket |
takeSocket()
Take the socket used to talk to the DN. |
Methods inherited from class org.apache.hadoop.fs.FSInputChecker |
---|
available, checksum2long, getPos, mark, markSupported, needChecksum, readFully, reset, set |
Methods inherited from class org.apache.hadoop.fs.FSInputStream |
---|
read, readFully, readFully |
Methods inherited from class java.io.InputStream |
---|
read |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public int read(byte[] buf, int off, int len) throws IOException
read
in class org.apache.hadoop.fs.FSInputChecker
IOException
public long skip(long n) throws IOException
skip
in class org.apache.hadoop.fs.FSInputChecker
IOException
public int read() throws IOException
read
in class org.apache.hadoop.fs.FSInputChecker
IOException
public boolean seekToNewSource(long targetPos) throws IOException
seekToNewSource
in interface org.apache.hadoop.fs.Seekable
seekToNewSource
in class org.apache.hadoop.fs.FSInputStream
IOException
public void seek(long pos) throws IOException
seek
in interface org.apache.hadoop.fs.Seekable
seek
in class org.apache.hadoop.fs.FSInputChecker
IOException
protected long getChunkPosition(long pos)
getChunkPosition
in class org.apache.hadoop.fs.FSInputChecker
protected int readChunk(long pos, byte[] buf, int offset, int len, byte[] checksumBuf) throws IOException
readChunk
in class org.apache.hadoop.fs.FSInputChecker
IOException
public static BlockReader newBlockReader(Socket sock, String file, Block block, org.apache.hadoop.security.token.Token<BlockTokenIdentifier> blockToken, long startOffset, long len, int bufferSize) throws IOException
IOException
public static BlockReader newBlockReader(Socket sock, String file, Block block, org.apache.hadoop.security.token.Token<BlockTokenIdentifier> blockToken, long startOffset, long len, int bufferSize, boolean verifyChecksum) throws IOException
IOException
public static BlockReader newBlockReader(Socket sock, String file, Block block, org.apache.hadoop.security.token.Token<BlockTokenIdentifier> blockToken, long startOffset, long len, int bufferSize, boolean verifyChecksum, String clientName) throws IOException
sock
- An established Socket to the DN. The BlockReader will not close it normallyfile
- File locationblock
- The block objectblockToken
- The block 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 name
IOException
public void close() throws IOException
close
in interface Closeable
close
in class InputStream
IOException
public int readAll(byte[] buf, int offset, int len) throws IOException
IOException
public Socket takeSocket()
public boolean hasSentStatusCode()
public static String getFileName(InetSocketAddress s, long blockId)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |