Class ReadaheadPool

java.lang.Object
org.apache.hadoop.io.ReadaheadPool

@Private @Evolving public class ReadaheadPool extends Object
Manages a pool of threads which can issue readahead requests on file descriptors.
  • Method Details

    • getInstance

      public static ReadaheadPool getInstance()
      Returns:
      Return the singleton instance for the current process.
    • resetInstance

      @VisibleForTesting public static void resetInstance()
    • readaheadStream

      public ReadaheadPool.ReadaheadRequest readaheadStream(String identifier, FileDescriptor fd, long curPos, long readaheadLength, long maxOffsetToRead, ReadaheadPool.ReadaheadRequest lastReadahead)
      Issue a request to readahead on the given file descriptor.
      Parameters:
      identifier - a textual identifier that will be used in error messages (e.g. the file name)
      fd - the file descriptor to read ahead
      curPos - the current offset at which reads are being issued
      readaheadLength - the configured length to read ahead
      maxOffsetToRead - the maximum offset that will be readahead (useful if, for example, only some segment of the file is requested by the user). Pass Long.MAX_VALUE to allow readahead to the end of the file.
      lastReadahead - the result returned by the previous invocation of this function on this file descriptor, or null if this is the first call
      Returns:
      an object representing this outstanding request, or null if no readahead was performed
    • submitReadahead

      public ReadaheadPool.ReadaheadRequest submitReadahead(String identifier, FileDescriptor fd, long off, long len)
      Submit a request to readahead on the given file descriptor.
      Parameters:
      identifier - a textual identifier used in error messages, etc.
      fd - the file descriptor to readahead
      off - the offset at which to start the readahead
      len - the number of bytes to read
      Returns:
      an object representing this pending request