diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java index c6075e8095b8..5d77147f0fdb 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java @@ -254,6 +254,14 @@ public int getTotalBufferCount() { return maxBufCount; } + public static long getHeapAllocationBytes(ByteBuffAllocator... allocators) { + long heapAllocBytes = 0; + for (ByteBuffAllocator alloc : Sets.newHashSet(allocators)) { + heapAllocBytes += alloc.getHeapAllocationBytes(); + } + return heapAllocBytes; + } + public static double getHeapAllocationRatio(ByteBuffAllocator... allocators) { double heapDelta = 0.0, poolDelta = 0.0; long heapAllocBytes, poolAllocBytes; diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/ServerMetricsTmpl.jamon b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/ServerMetricsTmpl.jamon index 17fbe1ede622..96c7c2a1004e 100644 --- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/ServerMetricsTmpl.jamon +++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/ServerMetricsTmpl.jamon @@ -246,7 +246,7 @@ ByteBuffAllocator bbAllocator; Buffer Size(Bytes) - <% bbAllocator.getHeapAllocationBytes() %> + <% ByteBuffAllocator.getHeapAllocationBytes(bbAllocator, ByteBuffAllocator.HEAP) %> <% bbAllocator.getPoolAllocationBytes() %> <% String.format("%.3f", ByteBuffAllocator.getHeapAllocationRatio(bbAllocator, ByteBuffAllocator.HEAP) * 100) %><% "%" %> <% bbAllocator.getTotalBufferCount() %> diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java index d0071a46624a..7588cdea96e9 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java @@ -1010,7 +1010,7 @@ public long getTrailerHitCount() { @Override public long getByteBuffAllocatorHeapAllocationBytes() { - return this.allocator.getHeapAllocationBytes(); + return ByteBuffAllocator.getHeapAllocationBytes(allocator, ByteBuffAllocator.HEAP); } @Override