org.apache.hadoop.hbase.io.hfile.slab
Class SlabCache

java.lang.Object
  extended by org.apache.hadoop.hbase.io.hfile.slab.SlabCache
All Implemented Interfaces:
Iterable<CachedBlock>, HeapSize, BlockCache

Deprecated. As of 1.0, replaced by BucketCache.

@InterfaceAudience.Private
@Deprecated
public class SlabCache
extends Object
implements BlockCache, HeapSize

SlabCache is composed of multiple SingleSizeCaches. It uses a TreeMap in order to determine where a given element fits. Redirects gets and puts to the correct SingleSizeCache.


Constructor Summary
SlabCache(long size, long avgBlockSize)
          Deprecated. Default constructor, creates an empty SlabCache.
 
Method Summary
 void addSlabByConf(org.apache.hadoop.conf.Configuration conf)
          Deprecated. A way of allocating the desired amount of Slabs of each particular size.
 void cacheBlock(BlockCacheKey cacheKey, Cacheable cachedItem)
          Deprecated. Cache the block with the specified key and buffer.
 void cacheBlock(BlockCacheKey cacheKey, Cacheable buf, boolean inMemory)
          Deprecated. We don't care about whether its in memory or not, so we just pass the call through.
 boolean evictBlock(BlockCacheKey cacheKey)
          Deprecated. Evicts a block from the cache.
 int evictBlocksByHfileName(String hfileName)
          Deprecated. Evicts all blocks for the given HFile.
 Cacheable getBlock(BlockCacheKey key, boolean caching, boolean repeat, boolean updateCacheMetrics)
          Deprecated. Get the buffer of the block with the specified name.
 BlockCache[] getBlockCaches()
          Deprecated.  
 long getBlockCount()
          Deprecated. Returns the number of blocks currently cached in the block cache.
 long getCurrentSize()
          Deprecated. Returns the occupied size of the block cache, in bytes.
 long getEvictedCount()
          Deprecated.  
 long getFreeSize()
          Deprecated. Returns the free size of the block cache, in bytes.
 Map<Integer,SingleSizeCache> getSizer()
          Deprecated.  
 CacheStats getStats()
          Deprecated. Get the statistics for this block cache.
 long heapSize()
          Deprecated.  
 Iterator<CachedBlock> iterator()
          Deprecated.  
 void onEviction(BlockCacheKey key, SingleSizeCache notifier)
          Deprecated. This is called as a callback when an item is removed from a SingleSizeCache.
 void onInsertion(BlockCacheKey key, SingleSizeCache notifier)
          Deprecated. This is called as a callback when an item is inserted into a SingleSizeCache.
 void shutdown()
          Deprecated. Sends a shutdown to all SingleSizeCache's contained by this cache.
 long size()
          Deprecated. Returns the total size of the block cache, in bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SlabCache

public SlabCache(long size,
                 long avgBlockSize)
Deprecated. 
Default constructor, creates an empty SlabCache.

Parameters:
size - Total size allocated to the SlabCache. (Bytes)
avgBlockSize - Average size of a block being cached.
Method Detail

getSizer

public Map<Integer,SingleSizeCache> getSizer()
Deprecated. 

addSlabByConf

public void addSlabByConf(org.apache.hadoop.conf.Configuration conf)
Deprecated. 
A way of allocating the desired amount of Slabs of each particular size. This reads two lists from conf, hbase.offheap.slab.proportions and hbase.offheap.slab.sizes. The first list is the percentage of our total space we allocate to the slabs. The second list is blocksize of the slabs in bytes. (E.g. the slab holds blocks of this size).

Parameters:
conf - Configuration file.

cacheBlock

public void cacheBlock(BlockCacheKey cacheKey,
                       Cacheable cachedItem)
Deprecated. 
Cache the block with the specified key and buffer. First finds what size SingleSlabCache it should fit in. If the block doesn't fit in any, it will return without doing anything.

It is assumed this will NEVER be called on an already cached block. If that is done, it is assumed that you are reinserting the same exact block due to a race condition, and will throw a runtime exception.

Specified by:
cacheBlock in interface BlockCache
Parameters:
cacheKey - block cache key
cachedItem - block buffer

cacheBlock

public void cacheBlock(BlockCacheKey cacheKey,
                       Cacheable buf,
                       boolean inMemory)
Deprecated. 
We don't care about whether its in memory or not, so we just pass the call through.

Specified by:
cacheBlock in interface BlockCache
Parameters:
cacheKey - The block's cache key.
buf - The block contents wrapped in a ByteBuffer.
inMemory - Whether block should be treated as in-memory

getStats

public CacheStats getStats()
Deprecated. 
Description copied from interface: BlockCache
Get the statistics for this block cache.

Specified by:
getStats in interface BlockCache
Returns:
Stats

getBlock

public Cacheable getBlock(BlockCacheKey key,
                          boolean caching,
                          boolean repeat,
                          boolean updateCacheMetrics)
Deprecated. 
Get the buffer of the block with the specified name.

Specified by:
getBlock in interface BlockCache
Parameters:
key - Block to fetch.
caching - Whether this request has caching enabled (used for stats)
repeat - Whether this is a repeat lookup for the same block (used to avoid double counting cache misses when doing double-check locking)
updateCacheMetrics - Whether to update cache metrics or not
Returns:
buffer of specified block name, or null if not in cache

evictBlock

public boolean evictBlock(BlockCacheKey cacheKey)
Deprecated. 
Evicts a block from the cache. This is public, and thus contributes to the the evict counter.

Specified by:
evictBlock in interface BlockCache
Parameters:
cacheKey - Block to evict
Returns:
true if block existed and was evicted, false if not

onEviction

public void onEviction(BlockCacheKey key,
                       SingleSizeCache notifier)
Deprecated. 
This is called as a callback when an item is removed from a SingleSizeCache.

Parameters:
key - the key of the item being evicted
notifier - the object notifying the SlabCache of the eviction.

onInsertion

public void onInsertion(BlockCacheKey key,
                        SingleSizeCache notifier)
Deprecated. 
This is called as a callback when an item is inserted into a SingleSizeCache.

Parameters:
key - the key of the item being added
notifier - the object notifying the SlabCache of the insertion..

shutdown

public void shutdown()
Deprecated. 
Sends a shutdown to all SingleSizeCache's contained by this cache. Also terminates the scheduleThreadPool.

Specified by:
shutdown in interface BlockCache

heapSize

public long heapSize()
Deprecated. 
Specified by:
heapSize in interface HeapSize
Returns:
Approximate 'exclusive deep size' of implementing object. Includes count of payload and hosting object sizings.

size

public long size()
Deprecated. 
Description copied from interface: BlockCache
Returns the total size of the block cache, in bytes.

Specified by:
size in interface BlockCache
Returns:
size of cache, in bytes

getFreeSize

public long getFreeSize()
Deprecated. 
Description copied from interface: BlockCache
Returns the free size of the block cache, in bytes.

Specified by:
getFreeSize in interface BlockCache
Returns:
free space in cache, in bytes

getBlockCount

public long getBlockCount()
Deprecated. 
Description copied from interface: BlockCache
Returns the number of blocks currently cached in the block cache.

Specified by:
getBlockCount in interface BlockCache
Returns:
number of blocks in the cache

getCurrentSize

public long getCurrentSize()
Deprecated. 
Description copied from interface: BlockCache
Returns the occupied size of the block cache, in bytes.

Specified by:
getCurrentSize in interface BlockCache
Returns:
occupied space in cache, in bytes

getEvictedCount

public long getEvictedCount()
Deprecated. 

evictBlocksByHfileName

public int evictBlocksByHfileName(String hfileName)
Deprecated. 
Description copied from interface: BlockCache
Evicts all blocks for the given HFile.

Specified by:
evictBlocksByHfileName in interface BlockCache
Returns:
the number of blocks evicted

iterator

public Iterator<CachedBlock> iterator()
Deprecated. 
Specified by:
iterator in interface Iterable<CachedBlock>
Specified by:
iterator in interface BlockCache
Returns:
Iterator over the blocks in the cache.

getBlockCaches

public BlockCache[] getBlockCaches()
Deprecated. 
Specified by:
getBlockCaches in interface BlockCache
Returns:
The list of sub blockcaches that make up this one; returns null if no sub caches.


Copyright © 2007–2016 The Apache Software Foundation. All rights reserved.