Index: src/main/java/org/apache/hadoop/hbase/HServerLoad.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/HServerLoad.java (revision 1067865) +++ src/main/java/org/apache/hadoop/hbase/HServerLoad.java (working copy) @@ -65,6 +65,8 @@ private int memstoreSizeMB; /** the current total size of storefile indexes for the region, in MB */ private int storefileIndexSizeMB; + /** the current total request made to region */ + private long requestsCount; /** * Constructor, for Writable @@ -80,16 +82,18 @@ * @param storefileSizeMB * @param memstoreSizeMB * @param storefileIndexSizeMB + * @param requestsCount */ public RegionLoad(final byte[] name, final int stores, final int storefiles, final int storefileSizeMB, - final int memstoreSizeMB, final int storefileIndexSizeMB) { + final int memstoreSizeMB, final int storefileIndexSizeMB,final long requestsCount) { this.name = name; this.stores = stores; this.storefiles = storefiles; this.storefileSizeMB = storefileSizeMB; this.memstoreSizeMB = memstoreSizeMB; this.storefileIndexSizeMB = storefileIndexSizeMB; + this.requestsCount = requestsCount; } // Getters @@ -142,6 +146,13 @@ public int getStorefileIndexSizeMB() { return storefileIndexSizeMB; } + + /** + * @return the number of requests made to region + */ + public long getRequestsCount() { + return requestsCount; + } // Setters @@ -181,6 +192,13 @@ this.storefileIndexSizeMB = storefileIndexSizeMB; } + /** + * @param requestsCount the number of requests to region + */ + public void setRequestsCount(long requestsCount) { + this.requestsCount = requestsCount; + } + // Writable public void readFields(DataInput in) throws IOException { int namelen = in.readInt(); @@ -191,6 +209,7 @@ this.storefileSizeMB = in.readInt(); this.memstoreSizeMB = in.readInt(); this.storefileIndexSizeMB = in.readInt(); + this.requestsCount = in.readLong(); } public void write(DataOutput out) throws IOException { @@ -201,6 +220,7 @@ out.writeInt(storefileSizeMB); out.writeInt(memstoreSizeMB); out.writeInt(storefileIndexSizeMB); + out.writeLong(requestsCount); } /** @@ -218,6 +238,8 @@ Integer.valueOf(this.memstoreSizeMB)); sb = Strings.appendKeyValue(sb, "storefileIndexSizeMB", Integer.valueOf(this.storefileIndexSizeMB)); + sb = Strings.appendKeyValue(sb, "requestsCount", + Long.valueOf(this.requestsCount)); return sb.toString(); } } @@ -452,14 +474,16 @@ * @param storefiles * @param memstoreSizeMB * @param storefileIndexSizeMB + * @param requestsCount * @deprecated Use {@link #addRegionInfo(RegionLoad)} */ @Deprecated public void addRegionInfo(final byte[] name, final int stores, final int storefiles, final int storefileSizeMB, - final int memstoreSizeMB, final int storefileIndexSizeMB) { + final int memstoreSizeMB, final int storefileIndexSizeMB, + final long requestsCount) { this.regionLoad.add(new HServerLoad.RegionLoad(name, stores, storefiles, - storefileSizeMB, memstoreSizeMB, storefileIndexSizeMB)); + storefileSizeMB, memstoreSizeMB, storefileIndexSizeMB, requestsCount)); } // Writable Index: src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (revision 1067865) +++ src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (working copy) @@ -43,6 +43,7 @@ import java.util.TreeSet; import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.locks.ReentrantReadWriteLock; @@ -172,7 +173,7 @@ // private byte [] name = null; final AtomicLong memstoreSize = new AtomicLong(0); - + final AtomicLong requestsCount = new AtomicLong(0); /** * The directory for the table this region is part of. * This directory contains the directory for this region. @@ -3599,6 +3600,7 @@ throw new NotServingRegionException(regionInfo.getRegionNameAsString() + " is closed"); } + this.requestsCount.incrementAndGet(); } /** Index: src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java (revision 1067865) +++ src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java (working copy) @@ -128,6 +128,11 @@ public final MetricsIntValue storefiles = new MetricsIntValue("storefiles", registry); /** + * Count of storefiles open on the regionserver. + */ + public final MetricsLongValue requestsCount = new MetricsLongValue("requestsCount", registry); + + /** * Sum of all the storefile index sizes in this regionserver in MB */ public final MetricsIntValue storefileIndexSizeMB = @@ -237,6 +242,7 @@ this.storefiles.pushMetric(this.metricsRecord); this.storefileIndexSizeMB.pushMetric(this.metricsRecord); this.memstoreSizeMB.pushMetric(this.metricsRecord); + this.requestsCount.pushMetric(this.metricsRecord); this.regions.pushMetric(this.metricsRecord); this.requests.pushMetric(this.metricsRecord); this.compactionQueueSize.pushMetric(this.metricsRecord); @@ -338,6 +344,8 @@ Integer.valueOf(this.storefileIndexSizeMB.get())); sb = Strings.appendKeyValue(sb, "memstoreSize", Integer.valueOf(this.memstoreSizeMB.get())); + sb = Strings.appendKeyValue(sb, "requestsCount", + Long.valueOf(this.requestsCount.get())); sb = Strings.appendKeyValue(sb, "compactionQueueSize", Integer.valueOf(this.compactionQueueSize.get())); // Duplicate from jvmmetrics because metrics are private there so Index: src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (revision 1067865) +++ src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (working copy) @@ -907,6 +907,7 @@ int storefileSizeMB = 0; int memstoreSizeMB = (int) (r.memstoreSize.get() / 1024 / 1024); int storefileIndexSizeMB = 0; + long requestsCount = r.requestsCount.get(); synchronized (r.stores) { stores += r.stores.size(); for (Store store : r.stores.values()) { @@ -915,8 +916,8 @@ storefileIndexSizeMB += (int) (store.getStorefilesIndexSize() / 1024 / 1024); } } - return new HServerLoad.RegionLoad(name, stores, storefiles, - storefileSizeMB, memstoreSizeMB, storefileIndexSizeMB); + return new HServerLoad.RegionLoad(name,stores, storefiles, + storefileSizeMB, memstoreSizeMB, storefileIndexSizeMB, requestsCount); } /** @@ -1155,11 +1156,13 @@ int stores = 0; int storefiles = 0; long memstoreSize = 0; + long requestsCount = 0; long storefileIndexSize = 0; synchronized (this.onlineRegions) { for (Map.Entry e : this.onlineRegions.entrySet()) { HRegion r = e.getValue(); memstoreSize += r.memstoreSize.get(); + requestsCount+= r.requestsCount.get(); synchronized (r.stores) { stores += r.stores.size(); for (Map.Entry ee : r.stores.entrySet()) { @@ -1173,6 +1176,7 @@ this.metrics.stores.set(stores); this.metrics.storefiles.set(storefiles); this.metrics.memstoreSizeMB.set((int) (memstoreSize / (1024 * 1024))); + this.metrics.requestsCount.set(requestsCount); this.metrics.storefileIndexSizeMB .set((int) (storefileIndexSize / (1024 * 1024))); this.metrics.compactionQueueSize.set(compactSplitThread