[ 
https://issues.apache.org/jira/browse/HBASE-18156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16040788#comment-16040788
 ] 

Chia-Ping Tsai commented on HBASE-18156:
----------------------------------------

{code}
+  @Override
+  public int compareTo(BlockCacheColumnFamilySummary o) {
+    int i = table.compareTo(o.getTable());
+    if (i != 0) {
+      return i;
+    }
+    return columnFamily.compareTo(o.getColumnFamily());
+  }
{code}
The _table_ and _columnFamily_ can be null so maybe we shouldn't overlook the 
null check.
{code}
+    Map<BlockCacheColumnFamilySummary, BlockCacheColumnFamilySummary> bcs = 
new HashMap<BlockCacheColumnFamilySummary, BlockCacheColumnFamilySummary>();
+    for (Map.Entry<BlockCacheKey, RAMQueueEntry> ramEntry : 
ramCache.entrySet()) {
+      addBlockCacheColumnFamilySummaries(fileToCfMap, ramEntry.getKey(), bcs,
+          ramEntry.getValue().heapSize());
+    }
+    for (Map.Entry<BlockCacheKey, BucketEntry> bucketEntry : backingMap
+        .entrySet()) {
+      long blockUsedSize = bucketAllocator.roundUpToBucketSizeInfo(
+          bucketEntry.getValue().getLength()).blockSize();
+      addBlockCacheColumnFamilySummaries(fileToCfMap, bucketEntry.getKey(),
+          bcs, blockUsedSize);
+    }
+    List<BlockCacheColumnFamilySummary> list = new 
ArrayList<BlockCacheColumnFamilySummary>(
+        bcs.values());
+    Collections.sort(list);
{code}
Consider making the return type of getBlockCacheColumnFamilySummaries() to be 
_Collection_ so that we can declare _bcs_ as _TreeSet_ and return _bcs_ 
directly for reducing memory allocation.
{code}
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj) return true;
+    if (obj == null) return false;
+    if (getClass() != obj.getClass()) return false;
+    BlockCacheColumnFamilySummary other = (BlockCacheColumnFamilySummary) obj;
+    if (columnFamily == null) {
+      if (other.columnFamily != null) return false;
+    } else if (!columnFamily.equals(other.columnFamily)) return false;
+    if (table == null) {
+      if (other.table != null) return false;
+    } else if (!table.equals(other.table)) return false;
+    return true;
+  }
{code}
org.apache.commons.lang.StringUtils#equals is a nice helper method to compare 
the string with null check.

It will be a valuable tool. +1

> Provide a tool to show block cache summary
> ------------------------------------------
>
>                 Key: HBASE-18156
>                 URL: https://issues.apache.org/jira/browse/HBASE-18156
>             Project: HBase
>          Issue Type: New Feature
>    Affects Versions: 2.0.0, 1.4.0
>            Reporter: Allan Yang
>            Assignee: Allan Yang
>         Attachments: HBASE-18156.patch, HBASE-18156.v2.patch
>
>
> HBASE-17757 is already committed. But since there is no easy way to show the 
> size distribution of cached blocks, it is hard to decide the unified size 
> should be used. 
> Here I provide a tool to show the details of size distribution of cached 
> blocks. This tool is well used in our production environment. It is a jsp 
> page summaries the cache details like this 
> {code}
> BlockCache type:org.apache.hadoop.hbase.io.hfile.LruBlockCache
> LruBlockCache
> Total size:28.40 GB
> Current size:22.49 GB
> MetaBlock size:1.56 GB
> Free size:5.91 GB
> Block count:152684
> Size distribution summary:
> BlockCacheSizeDistributionSummary [0 B<=blocksize<4 KB, blocks=833, 
> heapSize=1.19 MB]
> BlockCacheSizeDistributionSummary [4 KB<=blocksize<8 KB, blocks=65, 
> heapSize=310.83 KB]
> BlockCacheSizeDistributionSummary [8 KB<=blocksize<12 KB, blocks=175, 
> heapSize=1.46 MB]
> BlockCacheSizeDistributionSummary [12 KB<=blocksize<16 KB, blocks=18, 
> heapSize=267.43 KB]
> BlockCacheSizeDistributionSummary [16 KB<=blocksize<20 KB, blocks=512, 
> heapSize=8.30 MB]
> BlockCacheSizeDistributionSummary [20 KB<=blocksize<24 KB, blocks=22, 
> heapSize=499.66 KB]
> BlockCacheSizeDistributionSummary [24 KB<=blocksize<28 KB, blocks=24, 
> heapSize=632.59 KB]
> BlockCacheSizeDistributionSummary [28 KB<=blocksize<32 KB, blocks=34, 
> heapSize=1.02 MB]
> BlockCacheSizeDistributionSummary [32 KB<=blocksize<36 KB, blocks=31, 
> heapSize=1.02 MB]
> BlockCacheSizeDistributionSummary [36 KB<=blocksize<40 KB, blocks=22, 
> heapSize=838.58 KB]
> BlockCacheSizeDistributionSummary [40 KB<=blocksize<44 KB, blocks=28, 
> heapSize=1.15 MB]
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to