Index: src/java/org/apache/hadoop/hbase/regionserver/HStore.java =================================================================== --- src/java/org/apache/hadoop/hbase/regionserver/HStore.java (revision 720105) +++ src/java/org/apache/hadoop/hbase/regionserver/HStore.java (working copy) @@ -2137,7 +2137,19 @@ int getStorefilesCount() { return this.storefiles.size(); } - + + /** + * @return The size of the store file indexes, in bytes. + * @throws IOException if there was a problem getting file sizes from the + * filesystem + */ + long getStorefilesIndexSize() throws IOException { + long size = 0; + for (HStoreFile s: storefiles.values()) + size += s.indexLength(); + return size; + } + /* * Datastructure that holds size and key. */ Index: src/java/org/apache/hadoop/hbase/regionserver/HStoreFile.java =================================================================== --- src/java/org/apache/hadoop/hbase/regionserver/HStoreFile.java (revision 720105) +++ src/java/org/apache/hadoop/hbase/regionserver/HStoreFile.java (working copy) @@ -101,6 +101,7 @@ /* If true, this file was product of a major compaction. */ private boolean majorCompaction = false; + private long indexLength; /** * Constructor that fully initializes the object @@ -381,8 +382,18 @@ out.close(); } } - + /** + * Returns the on disk size of the mapfile index. + * @throws IOException + */ + long getIndexLength() throws IOException { + Path p = new Path(getMapFilePath(reference), MapFile.INDEX_FILE_NAME); + indexLength = p.getFileSystem(conf).getFileStatus(p).getLen(); + return indexLength; + } + + /** * Delete store map files. * @throws IOException */ @@ -477,6 +488,16 @@ return (isReference())? l / 2: l; } + /** + * @return Length of the store map file index. + * @throws IOException + */ + public long indexLength() throws IOException { + if (indexLength == 0) + indexLength = getIndexLength(); + return indexLength; + } + @Override public String toString() { return encodedRegionName + "/" + Bytes.toString(colFamily) + "/" + fileId + Index: src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java =================================================================== --- src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (revision 720105) +++ src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (working copy) @@ -654,20 +672,29 @@ // the synchronizations? int storefiles = 0; long memcacheSize = 0; + long storefileIndexSize = 0; synchronized (this.onlineRegions) { for (Map.Entry e: this.onlineRegions.entrySet()) { HRegion r = e.getValue(); memcacheSize += r.memcacheSize.get(); synchronized(r.stores) { for(Map.Entry ee: r.stores.entrySet()) { - storefiles += ee.getValue().getStorefilesCount(); + HStore store = ee.getValue(); + storefiles += store.getStorefilesCount(); + try { + storefileIndexSize += store.getStorefilesIndexSize(); + } catch (IOException ex) { + LOG.error("failed to get store file indexes size for " + store + + ": " + StringUtils.stringifyException(ex)); + } } } } } this.metrics.storefiles.set(storefiles); this.metrics.memcacheSizeMB.set((int)(memcacheSize/(1024*1024))); + this.metrics.storefileIndexSizeMB.set((int)(storefileIndexSize/(1024*1024))); } /** Index: src/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java =================================================================== --- src/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java (revision 720105) +++ src/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java (working copy) @@ -53,8 +53,14 @@ * Count of storefiles open on the regionserver. */ public final MetricsIntValue storefiles = new MetricsIntValue("storefiles"); - + /** + * Sum of all the storefile index sizes in this regionserver in MB + */ + public final MetricsIntValue storefileIndexSizeMB = + new MetricsIntValue("storefileIndexSizeMB"); + + /** * Sum of all the memcache sizes in this regionserver in MB */ public final MetricsIntValue memcacheSizeMB = @@ -81,6 +87,7 @@ public void doUpdates(@SuppressWarnings("unused") MetricsContext unused) { synchronized (this) { this.storefiles.pushMetric(this.metricsRecord); + this.storefileIndexSizeMB.pushMetric(this.metricsRecord); this.memcacheSizeMB.pushMetric(this.metricsRecord); this.regions.pushMetric(this.metricsRecord); synchronized(this.requests) { @@ -126,7 +133,10 @@ sb.append(this.regions.get()); sb.append(", storefiles="); sb.append(this.storefiles.get()); + sb.append(", storefileIndexSize="); + sb.append(this.storefileIndexSizeMB.get()); + sb.append("MB"); sb.append(", memcacheSize="); sb.append(this.memcacheSizeMB.get()); sb.append("MB");