From b01ba5105eaebf4ec4768aa159838900ace0795c Mon Sep 17 00:00:00 2001
From: chenheng
Date: Wed, 17 Aug 2016 10:07:00 +0800
Subject: [PATCH] HBASE-15635 Mean age of Blocks in cache (seconds) on webUI
should be greater than zero
---
.../hadoop/hbase/tmpl/regionserver/BlockCacheTmpl.jamon | 14 +++++++-------
.../org/apache/hadoop/hbase/io/hfile/BlockCacheUtil.java | 3 ++-
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/BlockCacheTmpl.jamon b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/BlockCacheTmpl.jamon
index bd2ce2b..87622a8 100644
--- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/BlockCacheTmpl.jamon
+++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/BlockCacheTmpl.jamon
@@ -257,7 +257,7 @@ are combined counts. Request count is sum of hits and misses.
String name;
%args>
<%java>
- final long nanosPerSecond = 1000000000;
+
String bcUrl = "http://hbase.apache.org/devapidocs/" + bc.getClass().getName().replaceAll("\\.", "/") + ".html";
String bcName = bc.getClass().getSimpleName();
org.apache.hadoop.hbase.io.hfile.BlockCacheUtil.CachedBlocksByFile cbsbf =
@@ -343,32 +343,32 @@ are combined counts. Request count is sum of hits and misses.
<%if !slabCache %>
| Mean |
- <% String.format("%,d", (long)(snapshot.getMean()/nanosPerSecond)) %> |
+ <% String.format("%,d", (long)(snapshot.getMean())) %> |
Mean age of Blocks in cache (seconds) |
| StdDev |
- <% String.format("%,d", (long)(snapshot.getStdDev()/nanosPerSecond)) %> |
+ <% String.format("%,d", (long)(snapshot.getStdDev())) %> |
Age standard deviation of Blocks in cache |
| Min |
- <% String.format("%,d", (long)(snapshot.getMin()/nanosPerSecond)) %> |
+ <% String.format("%,d", (long)(snapshot.getMin())) %> |
Min age of Blocks in cache (seconds) |
| Max |
- <% String.format("%,d", (long)(snapshot.getMax()/nanosPerSecond)) %> |
+ <% String.format("%,d", (long)(snapshot.getMax())) %> |
Max age of Blocks in cache (seconds) |
| 95th Percentile |
- <% String.format("%,d", (long)(snapshot.get95thPercentile()/nanosPerSecond)) %> |
+ <% String.format("%,d", (long)(snapshot.get95thPercentile())) %> |
95th percentile of age of Blocks in cache (seconds) |
| 99th Percentile |
- <% String.format("%,d", (long)(snapshot.get99thPercentile()/nanosPerSecond)) %> |
+ <% String.format("%,d", (long)(snapshot.get99thPercentile())) %> |
99th percentile of age of Blocks in cache (seconds) |
%if>
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheUtil.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheUtil.java
index 07ad8b7..e7f3268 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheUtil.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheUtil.java
@@ -282,7 +282,8 @@ public class BlockCacheUtil {
this.dataBlockCount++;
this.dataSize += cb.getSize();
}
- long age = this.now - cb.getCachedTime();
+ final long nanosPerSecond = 1000000000;
+ long age = (this.now - cb.getCachedTime())/nanosPerSecond;
this.age.update(age);
return false;
}
--
1.9.3 (Apple Git-50)