Class ExternalBlockReader

java.lang.Object
org.apache.hadoop.hdfs.client.impl.ExternalBlockReader
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.hadoop.fs.ByteBufferReadable, BlockReader

@Private public final class ExternalBlockReader extends Object implements BlockReader
An ExternalBlockReader uses pluggable ReplicaAccessor objects to read from replicas.
  • Method Details

    • read

      public int read(byte[] buf, int off, int len) throws IOException
      Specified by:
      read in interface BlockReader
      Throws:
      IOException
    • read

      public int read(ByteBuffer buf) throws IOException
      Specified by:
      read in interface org.apache.hadoop.fs.ByteBufferReadable
      Throws:
      IOException
    • skip

      public long skip(long n) throws IOException
      Description copied from interface: BlockReader
      Skip the given number of bytes
      Specified by:
      skip in interface BlockReader
      Throws:
      IOException
    • available

      public int available()
      Description copied from interface: BlockReader
      Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without performing network I/O. This may return more than what is actually present in the block.
      Specified by:
      available in interface BlockReader
    • close

      public void close() throws IOException
      Description copied from interface: BlockReader
      Close the block reader.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface BlockReader
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • readFully

      public void readFully(byte[] buf, int offset, int len) throws IOException
      Description copied from interface: BlockReader
      Read exactly the given amount of data, throwing an exception if EOF is reached before that amount
      Specified by:
      readFully in interface BlockReader
      Throws:
      IOException
    • readAll

      public int readAll(byte[] buf, int offset, int len) throws IOException
      Description copied from interface: BlockReader
      Similar to BlockReader.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.
      Specified by:
      readAll in interface BlockReader
      Throws:
      IOException
    • isShortCircuit

      public boolean isShortCircuit()
      Specified by:
      isShortCircuit in interface BlockReader
      Returns:
      true only if this is a short-circuit read. All short-circuit reads are also local.
    • getClientMmap

      public ClientMmap getClientMmap(EnumSet<org.apache.hadoop.fs.ReadOption> opts)
      Description copied from interface: BlockReader
      Get a ClientMmap object for this BlockReader.
      Specified by:
      getClientMmap in interface BlockReader
      Parameters:
      opts - The read options to use.
      Returns:
      The ClientMmap object, or null if mmap is not supported.
    • getDataChecksum

      public org.apache.hadoop.util.DataChecksum getDataChecksum()
      Specified by:
      getDataChecksum in interface BlockReader
      Returns:
      The DataChecksum used by the read block
    • getNetworkDistance

      public int getNetworkDistance()
      Description copied from interface: BlockReader
      Return the network distance between local machine and the remote machine.
      Specified by:
      getNetworkDistance in interface BlockReader