org.apache.hadoop.io
Class ReadaheadPool

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

@InterfaceAudience.Private
@InterfaceStability.Evolving
public class ReadaheadPool
extends Object

Manages a pool of threads which can issue readahead requests on file descriptors.


Nested Class Summary
static interface ReadaheadPool.ReadaheadRequest
          An outstanding readahead request that has been submitted to the pool.
 
Method Summary
static ReadaheadPool getInstance()
          Return the singleton instance for the current process.
 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.
 ReadaheadPool.ReadaheadRequest submitReadahead(String identifier, FileDescriptor fd, long off, long len)
          Submit a request to readahead on the given file descriptor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ReadaheadPool getInstance()
Return the singleton instance for the current process.


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


Copyright © 2009 The Apache Software Foundation