org.apache.hadoop.hbase.io.hfile
Class BlockCacheUtil

java.lang.Object
  extended by org.apache.hadoop.hbase.io.hfile.BlockCacheUtil

@InterfaceAudience.Private
public class BlockCacheUtil
extends Object

Utilty for aggregating counts in CachedBlocks and toString/toJSON CachedBlocks and BlockCaches. No attempt has been made at making this thread safe.


Nested Class Summary
static class BlockCacheUtil.AgeSnapshot
          Snapshot of block cache age in cache.
static class BlockCacheUtil.CachedBlocksByFile
          Use one of these to keep a running account of cached blocks by file.
 
Constructor Summary
BlockCacheUtil()
           
 
Method Summary
static BlockCacheUtil.CachedBlocksByFile getLoadedCachedBlocksByFile(org.apache.hadoop.conf.Configuration conf, BlockCache bc)
          Get a BlockCacheUtil.CachedBlocksByFile instance and load it up by iterating content in BlockCache.
static String toJSON(BlockCache bc)
           
static String toJSON(BlockCacheUtil.CachedBlocksByFile cbsbf)
           
static String toJSON(String filename, NavigableSet<CachedBlock> blocks)
           
static String toString(CachedBlock cb, long now)
           
static String toStringMinusFileName(CachedBlock cb, long now)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockCacheUtil

public BlockCacheUtil()
Method Detail

toString

public static String toString(CachedBlock cb,
                              long now)
Parameters:
cb -
Returns:
The block content as String.

toJSON

public static String toJSON(String filename,
                            NavigableSet<CachedBlock> blocks)
                     throws org.codehaus.jackson.JsonGenerationException,
                            org.codehaus.jackson.map.JsonMappingException,
                            IOException
Parameters:
filename -
blocks -
Returns:
A JSON String of filename and counts of blocks
Throws:
org.codehaus.jackson.JsonGenerationException
org.codehaus.jackson.map.JsonMappingException
IOException

toJSON

public static String toJSON(BlockCacheUtil.CachedBlocksByFile cbsbf)
                     throws org.codehaus.jackson.JsonGenerationException,
                            org.codehaus.jackson.map.JsonMappingException,
                            IOException
Parameters:
cbsbf -
Returns:
JSON string of cbsf aggregated
Throws:
org.codehaus.jackson.JsonGenerationException
org.codehaus.jackson.map.JsonMappingException
IOException

toJSON

public static String toJSON(BlockCache bc)
                     throws org.codehaus.jackson.JsonGenerationException,
                            org.codehaus.jackson.map.JsonMappingException,
                            IOException
Parameters:
bc -
Returns:
JSON string of bc content.
Throws:
org.codehaus.jackson.JsonGenerationException
org.codehaus.jackson.map.JsonMappingException
IOException

toStringMinusFileName

public static String toStringMinusFileName(CachedBlock cb,
                                           long now)
Parameters:
cb -
Returns:
The block content of bc as a String minus the filename.

getLoadedCachedBlocksByFile

public static BlockCacheUtil.CachedBlocksByFile getLoadedCachedBlocksByFile(org.apache.hadoop.conf.Configuration conf,
                                                                            BlockCache bc)
Get a BlockCacheUtil.CachedBlocksByFile instance and load it up by iterating content in BlockCache.

Parameters:
conf - Used to read configurations
bc - Block Cache to iterate.
Returns:
Laoded up instance of CachedBlocksByFile


Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.