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, set
read, readFully, readFully
read
protected 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 InputStream
read
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
在接口中 BlockReader
read
在类中 FSInputChecker
buf
- 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
FSInputChecker
n
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
在接口中 BlockReader
skip
在类中 FSInputChecker
n
- 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
FSInputChecker
read
在类中 FSInputChecker
-1
if the end of the
stream is reached.IOException
- if an I/O error occurs.public boolean seekToNewSource(long targetPos) throws IOException
FSInputStream
seekToNewSource
在接口中 Seekable
seekToNewSource
在类中 FSInputStream
IOException
public void seek(long pos) throws IOException
FSInputChecker
This 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
在接口中 Seekable
seek
在类中 FSInputChecker
pos
- 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)
FSInputChecker
getChunkPosition
在类中 FSInputChecker
pos
- a postion in the fileprotected int readChunk(long pos, byte[] buf, int offset, int len, byte[] checksumBuf) throws IOException
FSInputChecker
buf
at offset
and checksum into checksum
.
The method is used for implementing read, therefore, it should be optimized
for sequential readingreadChunk
在类中 FSInputChecker
pos
- chunkPosbuf
- desitination bufferoffset
- offset in buf at which to store datalen
- maximun number of bytes to readIOException
public static BlockReader newBlockReader(Socket sock, String file, long blockId, Token<BlockTokenIdentifier> accessToken, long genStamp, long startOffset, long len, int bufferSize) throws IOException
IOException
public 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.IOException
public 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
IOException
public void close() throws IOException
close
在接口中 Closeable
close
在接口中 AutoCloseable
close
在类中 InputStream
IOException
public int readAll(byte[] buf, int offset, int len) throws IOException
readAll
在接口中 BlockReader
IOException
Copyright © 2009 The Apache Software Foundation