HBASE-15635 Mean age of Blocks in cache (seconds) on webUI should be greater than zero

Signed-off-by: stack <stack@apache.org>
This commit is contained in:
chenheng 2016-08-17 11:06:34 +08:00 committed by stack
parent 2261c8c31a
commit fb4ef53571
3 changed files with 9 additions and 7 deletions

View File

@ -177,7 +177,6 @@ org.apache.hadoop.util.StringUtils.TraditionalBinaryPrefix;
<%java>
AgeSnapshot ageAtEvictionSnapshot = bc.getStats().getAgeAtEvictionSnapshot();
// Only show if non-zero mean and stddev as is the case in combinedblockcache
double mean = ageAtEvictionSnapshot.getMean();
</%java>
<tr>
<td>Evicted</td>
@ -189,13 +188,11 @@ org.apache.hadoop.util.StringUtils.TraditionalBinaryPrefix;
<td><% String.format("%,d", bc.getStats().getEvictionCount()) %></td>
<td>The total number of times an eviction has occurred</td>
</tr>
<%if mean > 0 %>
<tr>
<td>Mean</td>
<td><% String.format("%,d", (long)(ageAtEvictionSnapshot.getMean()/(1000000 * 1000))) %></td>
<td><% String.format("%,d", (long)ageAtEvictionSnapshot.getMean()) %></td>
<td>Mean age of Blocks at eviction time (seconds)</td>
</tr>
</%if>
</%def>
<%def hits_tmpl>
@ -288,7 +285,6 @@ are combined counts. Request count is sum of hits and misses.</p>
boolean evictions;
</%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 =

View File

@ -39,6 +39,10 @@ import org.codehaus.jackson.map.SerializationConfig;
*/
@InterfaceAudience.Private
public class BlockCacheUtil {
public static final long NANOS_PER_SECOND = 1000000000;
/**
* Needed generating JSON.
*/
@ -224,7 +228,7 @@ public class BlockCacheUtil {
this.dataBlockCount++;
this.dataSize += cb.getSize();
}
long age = this.now - cb.getCachedTime();
long age = (this.now - cb.getCachedTime())/NANOS_PER_SECOND;
this.hist.add(age, 1);
return false;
}

View File

@ -248,7 +248,9 @@ public class CacheStats {
}
public void evicted(final long t, boolean primary) {
if (t > this.startTime) this.ageAtEviction.add(t - this.startTime,1);
if (t > this.startTime) {
this.ageAtEviction.add((t - this.startTime) / BlockCacheUtil.NANOS_PER_SECOND, 1);
}
this.evictedBlockCount.increment();
if (primary) {
primaryEvictedBlockCount.increment();