From 8090a75a5d91eb5c6d286ceabfe935f7a16dce69 Mon Sep 17 00:00:00 2001 From: anoopsamjohn Date: Tue, 12 Mar 2013 15:26:26 +0000 Subject: [PATCH] HBASE-8057 RegionLoad needs a toString implementation(jmspaggiari) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1455583 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/hadoop/hbase/RegionLoad.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLoad.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLoad.java index 791a82284b2..6cabccdde9a 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLoad.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLoad.java @@ -23,6 +23,7 @@ package org.apache.hadoop.hbase; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos; import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.hbase.util.Strings; /** * Encapsulates per-region load metrics. @@ -149,4 +150,57 @@ public class RegionLoad { public long getCompleteSequenceId() { return regionLoadPB.getCompleteSequenceId(); } + + /** + * @return the uncompressed size of the storefiles in MB. + */ + public int getStoreUncompressedSizeMB() { + return regionLoadPB.getStoreUncompressedSizeMB(); + } + + /** + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = Strings.appendKeyValue(new StringBuilder(), "numberOfStores", + Integer.valueOf(this.getStores())); + sb = Strings.appendKeyValue(sb, "numberOfStorefiles", + Integer.valueOf(this.getStorefiles())); + sb = Strings.appendKeyValue(sb, "storefileUncompressedSizeMB", + Integer.valueOf(this.getStoreUncompressedSizeMB())); + sb = Strings.appendKeyValue(sb, "storefileSizeMB", + Integer.valueOf(this.getStorefileSizeMB())); + if (this.getStoreUncompressedSizeMB() != 0) { + sb = Strings.appendKeyValue(sb, "compressionRatio", + String.format("%.4f", (float)this.getStorefileSizeMB()/ + (float)this.getStoreUncompressedSizeMB())); + } + sb = Strings.appendKeyValue(sb, "memstoreSizeMB", + Integer.valueOf(this.getMemStoreSizeMB())); + sb = Strings.appendKeyValue(sb, "storefileIndexSizeMB", + Integer.valueOf(this.getStorefileIndexSizeMB())); + sb = Strings.appendKeyValue(sb, "readRequestsCount", + Long.valueOf(this.getReadRequestsCount())); + sb = Strings.appendKeyValue(sb, "writeRequestsCount", + Long.valueOf(this.getWriteRequestsCount())); + sb = Strings.appendKeyValue(sb, "rootIndexSizeKB", + Integer.valueOf(this.getRootIndexSizeKB())); + sb = Strings.appendKeyValue(sb, "totalStaticIndexSizeKB", + Integer.valueOf(this.getTotalStaticIndexSizeKB())); + sb = Strings.appendKeyValue(sb, "totalStaticBloomSizeKB", + Integer.valueOf(this.getTotalStaticBloomSizeKB())); + sb = Strings.appendKeyValue(sb, "totalCompactingKVs", + Long.valueOf(this.getTotalCompactingKVs())); + sb = Strings.appendKeyValue(sb, "currentCompactedKVs", + Long.valueOf(this.getCurrentCompactedKVs())); + float compactionProgressPct = Float.NaN; + if( this.getTotalCompactingKVs() > 0 ) { + compactionProgressPct = Float.valueOf( + this.getCurrentCompactedKVs() / this.getTotalCompactingKVs()); + } + sb = Strings.appendKeyValue(sb, "compactionProgressPct", + compactionProgressPct); + return sb.toString(); + } }