Class CachingBlockManager
java.lang.Object
org.apache.hadoop.fs.impl.prefetch.BlockManager
org.apache.hadoop.fs.impl.prefetch.CachingBlockManager
- All Implemented Interfaces:
Closeable,AutoCloseable
Provides read access to the underlying file one block at a time.
Improve read performance by prefetching and locall caching blocks.
-
Constructor Summary
ConstructorsConstructorDescriptionCachingBlockManager(BlockManagerParameters blockManagerParameters) Constructs an instance of aCachingBlockManager. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcachePut(int blockNumber, ByteBuffer buffer) voidRequests cancellation of any previously issued prefetch requests.voidclose()protected BlockCachecreateCache(int maxBlocksCount, DurationTrackerFactory trackerFactory) get(int blockNumber) Gets the block having the givenblockNumber.intNumber of ByteBuffers available to be acquired.intNumber of caching operations completed.intNumber of errors encountered when caching.intNumber of errors encountered when reading.voidrelease(BufferData data) Releases resources allocated to the given block.voidrequestCaching(BufferData data) Requests that the given block should be copied to the local cache.voidrequestPrefetch(int blockNumber) Requests optional prefetching of the given block.toString()Methods inherited from class org.apache.hadoop.fs.impl.prefetch.BlockManager
getBlockData, read
-
Constructor Details
-
CachingBlockManager
Constructs an instance of aCachingBlockManager.- Parameters:
blockManagerParameters- params for block manager.- Throws:
IllegalArgumentException- if bufferPoolSize is zero or negative.
-
-
Method Details
-
get
Gets the block having the givenblockNumber.- Overrides:
getin classBlockManager- Parameters:
blockNumber- the number of the block to be read and returned.- Returns:
BufferDatahaving data from the given block.- Throws:
IllegalArgumentException- if blockNumber is negative.IOException- if there an error reading the given block.
-
release
Releases resources allocated to the given block.- Overrides:
releasein classBlockManager- Parameters:
data- theBufferDatato release.- Throws:
IllegalArgumentException- if data is null.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classBlockManager
-
requestPrefetch
public void requestPrefetch(int blockNumber) Requests optional prefetching of the given block. The block is prefetched only if we can acquire a free buffer.- Overrides:
requestPrefetchin classBlockManager- Parameters:
blockNumber- the id of the block to prefetch.- Throws:
IllegalArgumentException- if blockNumber is negative.
-
cancelPrefetches
public void cancelPrefetches()Requests cancellation of any previously issued prefetch requests.- Overrides:
cancelPrefetchesin classBlockManager
-
requestCaching
Requests that the given block should be copied to the local cache. The block must not be accessed by the caller after calling this method because it will released asynchronously relative to the caller.- Overrides:
requestCachingin classBlockManager- Parameters:
data- theBufferDatainstance to optionally cache.- Throws:
IllegalArgumentException- if data is null.
-
createCache
-
cachePut
- Throws:
IOException
-
numAvailable
public int numAvailable()Number of ByteBuffers available to be acquired.- Returns:
- the number of available buffers.
-
numCached
public int numCached()Number of caching operations completed.- Returns:
- the number of cached buffers.
-
numCachingErrors
public int numCachingErrors()Number of errors encountered when caching.- Returns:
- the number of errors encountered when caching.
-
numReadErrors
public int numReadErrors()Number of errors encountered when reading.- Returns:
- the number of errors encountered when reading.
-
toString
-