Package org.apache.hadoop.io
Class ReadaheadPool
java.lang.Object
org.apache.hadoop.io.ReadaheadPool
Manages a pool of threads which can issue readahead requests on file descriptors.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAn outstanding readahead request that has been submitted to the pool. -
Method Summary
Modifier and TypeMethodDescriptionstatic ReadaheadPoolreadaheadStream(String identifier, FileDescriptor fd, long curPos, long readaheadLength, long maxOffsetToRead, ReadaheadPool.ReadaheadRequest lastReadahead) Issue a request to readahead on the given file descriptor.static voidsubmitReadahead(String identifier, FileDescriptor fd, long off, long len) Submit a request to readahead on the given file descriptor.
-
Method Details
-
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 aheadcurPos- the current offset at which reads are being issuedreadaheadLength- the configured length to read aheadmaxOffsetToRead- the maximum offset that will be readahead (useful if, for example, only some segment of the file is requested by the user). PassLong.MAX_VALUEto 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 readaheadoff- the offset at which to start the readaheadlen- the number of bytes to read- Returns:
- an object representing this pending request
-