public static class DFSClient.RemoteBlockReader extends FSInputChecker implements BlockReader
file, LOG| 限定符 | 构造器和说明 |
|---|---|
protected |
DFSClient.RemoteBlockReader(Path file,
int numRetries,
DataChecksum checksum,
boolean verifyChecksum) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close() |
protected long |
getChunkPosition(long pos)
Return position of beginning of chunk containing pos.
|
static BlockReader |
newBlockReader(Socket sock,
String file,
long blockId,
Token<BlockTokenIdentifier> accessToken,
long genStamp,
long startOffset,
long len,
int bufferSize) |
static BlockReader |
newBlockReader(Socket sock,
String file,
long blockId,
Token<BlockTokenIdentifier> accessToken,
long genStamp,
long startOffset,
long len,
int bufferSize,
boolean verifyChecksum)
Creates a new
BlockReader for the given blockId. |
static BlockReader |
newBlockReader(Socket sock,
String file,
long blockId,
Token<BlockTokenIdentifier> accessToken,
long genStamp,
long startOffset,
long len,
int bufferSize,
boolean verifyChecksum,
String clientName) |
int |
read()
Read one checksum-verified byte
|
int |
read(byte[] buf,
int off,
int len)
Read checksum verified bytes from this byte-input stream into
the specified byte array, starting at the given offset.
|
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)
Reads in next checksum chunk data into
buf at offset
and checksum into checksum. |
void |
seek(long pos)
Seek to the given position in the stream.
|
boolean |
seekToNewSource(long targetPos)
Seeks a different copy of the data.
|
long |
skip(long n)
Skips over and discards
n bytes of data from the
input stream. |
available, checksum2long, getPos, mark, markSupported, needChecksum, readFully, reset, setread, readFully, readFullyreadprotected DFSClient.RemoteBlockReader(Path file, int numRetries, DataChecksum checksum, boolean verifyChecksum)
public int read(byte[] buf,
int off,
int len)
throws IOException
FSInputChecker This method implements the general contract of the corresponding
method of
the read class. As an additional
convenience, it attempts to read as many bytes as possible by repeatedly
invoking the InputStreamread method of the underlying stream. This
iterated read continues until one of the following
conditions becomes true:
read method of the underlying stream returns
-1, indicating end-of-file.
read on the underlying stream returns
-1 to indicate end-of-file then this method returns
-1. Otherwise this method returns the number of bytes
actually read.read 在接口中 BlockReaderread 在类中 FSInputCheckerbuf - destination buffer.off - offset at which to start storing bytes.len - maximum number of bytes to read.-1 if the end of
the stream has been reached.IOException - if an I/O error occurs.
ChecksumException if any checksum error occurspublic long skip(long n)
throws IOException
FSInputCheckern bytes of data from the
input stream.
This method may skip more bytes than are remaining in the backing file. This produces no exception and the number of bytes skipped may include some number of bytes that were beyond the EOF of the backing file. Attempting to read from the stream after skipping past the end will result in -1 indicating the end of the file.
If n is negative, no bytes are skipped.
skip 在接口中 BlockReaderskip 在类中 FSInputCheckern - the number of bytes to be skipped.IOException - if an I/O error occurs.
ChecksumException if the chunk to skip to is corruptedpublic int read()
throws IOException
FSInputCheckerread 在类中 FSInputChecker-1 if the end of the
stream is reached.IOException - if an I/O error occurs.public boolean seekToNewSource(long targetPos)
throws IOException
FSInputStreamseekToNewSource 在接口中 SeekableseekToNewSource 在类中 FSInputStreamIOExceptionpublic void seek(long pos)
throws IOException
FSInputCheckerThis method may seek past the end of the file. This produces no exception and an attempt to read from the stream will result in -1 indicating the end of the file.
seek 在接口中 Seekableseek 在类中 FSInputCheckerpos - the postion to seek to.IOException - if an I/O error occurs.
ChecksumException if the chunk to seek to is corruptedprotected long getChunkPosition(long pos)
FSInputCheckergetChunkPosition 在类中 FSInputCheckerpos - a postion in the fileprotected int readChunk(long pos,
byte[] buf,
int offset,
int len,
byte[] checksumBuf)
throws IOException
FSInputCheckerbuf at offset
and checksum into checksum.
The method is used for implementing read, therefore, it should be optimized
for sequential readingreadChunk 在类中 FSInputCheckerpos - chunkPosbuf - desitination bufferoffset - offset in buf at which to store datalen - maximun number of bytes to readIOExceptionpublic static BlockReader newBlockReader(Socket sock, String file, long blockId, Token<BlockTokenIdentifier> accessToken, long genStamp, long startOffset, long len, int bufferSize) throws IOException
IOExceptionpublic static BlockReader newBlockReader(Socket sock, String file, long blockId, Token<BlockTokenIdentifier> accessToken, long genStamp, long startOffset, long len, int bufferSize, boolean verifyChecksum) throws IOException
BlockReader for the given blockId.sock - Socket to read the block.file - File to which this block belongs.blockId - Block id.accessToken - Block access token.genStamp - Generation stamp of the block.startOffset - Start offset for the data.len - Length to be read.bufferSize - Buffer size to use.verifyChecksum - Checksum verification is required or not.IOExceptionpublic static BlockReader newBlockReader(Socket sock, String file, long blockId, Token<BlockTokenIdentifier> accessToken, long genStamp, long startOffset, long len, int bufferSize, boolean verifyChecksum, String clientName) throws IOException
IOExceptionpublic void close()
throws IOException
close 在接口中 Closeableclose 在接口中 AutoCloseableclose 在类中 InputStreamIOExceptionpublic int readAll(byte[] buf,
int offset,
int len)
throws IOException
readAll 在接口中 BlockReaderIOExceptionCopyright © 2009 The Apache Software Foundation