org.apache.hadoop.hdfs
Interface BlockReader


public interface BlockReader

A BlockReader is responsible for reading a single block from a single datanode.


Method Summary
 void close()
           
 boolean hasSentStatusCode()
          Whether the BlockReader has reached the end of its input stream and successfully sent a status code back to the datanode.
 int read(byte[] buf, int off, int len)
           
 int readAll(byte[] buf, int offset, int len)
          Similar to readFully(byte[], int, int) except that it will not throw an exception on EOF.
 void readFully(byte[] buf, int readOffset, int amtToRead)
          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
 Socket takeSocket()
          Take the socket used to talk to the DN.
 

Method Detail

read

int read(byte[] buf,
         int off,
         int len)
         throws IOException
Throws:
IOException

skip

long skip(long n)
          throws IOException
Skip the given number of bytes

Throws:
IOException

close

void close()
           throws IOException
Throws:
IOException

readFully

void readFully(byte[] buf,
               int readOffset,
               int amtToRead)
               throws IOException
Read exactly the given amount of data, throwing an exception if EOF is reached before that amount

Throws:
IOException

readAll

int readAll(byte[] buf,
            int offset,
            int len)
            throws IOException
Similar to readFully(byte[], int, int) except that it will not throw an exception on EOF. However, it differs from the simple 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.

Throws:
IOException

takeSocket

Socket takeSocket()
Take the socket used to talk to the DN.


hasSentStatusCode

boolean hasSentStatusCode()
Whether the BlockReader has reached the end of its input stream and successfully sent a status code back to the datanode.



Copyright © 2012 Apache Software Foundation. All Rights Reserved.