Index: src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (revision 1128408) +++ src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (working copy) @@ -907,6 +907,7 @@ byte[] name = r.getRegionName(); int stores = 0; int storefiles = 0; + int storeUncompressedSizeMB = 0; int storefileSizeMB = 0; int memstoreSizeMB = (int) (r.memstoreSize.get() / 1024 / 1024); int storefileIndexSizeMB = 0; @@ -914,11 +915,14 @@ stores += r.stores.size(); for (Store store : r.stores.values()) { storefiles += store.getStorefilesCount(); + storeUncompressedSizeMB += (int) (store.getStoreSizeUncompressed() + / 1024 / 1024); storefileSizeMB += (int) (store.getStorefilesSize() / 1024 / 1024); storefileIndexSizeMB += (int) (store.getStorefilesIndexSize() / 1024 / 1024); } } return new HServerLoad.RegionLoad(name,stores, storefiles, + storeUncompressedSizeMB, storefileSizeMB, memstoreSizeMB, storefileIndexSizeMB, (int) r.readRequestsCount.get(), (int) r.writeRequestsCount.get()); } =================================================================== --- src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java (revision 1128408) +++ src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java (working copy) @@ -1092,6 +1092,10 @@ return reader.length(); } + public long getTotalUncompressedBytes() { + return reader.getTotalUncompressedBytes(); + } + public int getEntries() { return reader.getEntries(); } Index: src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java (revision 1128408) +++ src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java (working copy) @@ -841,6 +841,10 @@ return this.fileSize; } + public long getTotalUncompressedBytes() { + return this.trailer.totalUncompressedBytes; + } + public boolean inMemory() { return this.inMemory; } Index: src/main/java/org/apache/hadoop/hbase/regionserver/Store.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/regionserver/Store.java (revision 1128490) +++ src/main/java/org/apache/hadoop/hbase/regionserver/Store.java (working copy) @@ -114,6 +114,7 @@ private final long desiredMaxFileSize; private final int blockingStoreFileCount; private volatile long storeSize = 0L; + private volatile long totalUncompressedBytes = 0L; private final Object flushLock = new Object(); final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); private final String storeNameStr; @@ -286,6 +287,7 @@ } long length = curfile.getReader().length(); this.storeSize += length; + this.totalUncompressedBytes += curfile.getReader().getTotalUncompressedBytes(); if (LOG.isDebugEnabled()) { LOG.debug("loaded " + curfile.toStringDetailed()); } @@ -523,6 +525,7 @@ this.conf, this.family.getBloomFilterType(), this.inMemory); StoreFile.Reader r = sf.createReader(); this.storeSize += r.length(); + this.totalUncompressedBytes += r.getTotalUncompressedBytes(); if(LOG.isInfoEnabled()) { LOG.info("Added " + sf + ", entries=" + r.getEntries() + ", sequenceid=" + logCacheFlushId + @@ -1206,6 +1209,7 @@ } // 4. Compute new store size this.storeSize = 0L; + this.totalUncompressedBytes = 0L; for (StoreFile hsf : this.storefiles) { StoreFile.Reader r = hsf.getReader(); if (r == null) { @@ -1213,6 +1217,7 @@ continue; } this.storeSize += r.length(); + this.totalUncompressedBytes += r.getTotalUncompressedBytes(); } } finally { this.lock.writeLock().unlock(); @@ -1529,6 +1534,13 @@ } /** + * @return The size of the store files, in bytes, uncompressed. + */ + long getStoreSizeUncompressed() { + return this.totalUncompressedBytes; + } + + /** * @return The size of the store files, in bytes. */ long getStorefilesSize() { @@ -1682,7 +1694,7 @@ public static final long FIXED_OVERHEAD = ClassSize.align( ClassSize.OBJECT + (15 * ClassSize.REFERENCE) + - (7 * Bytes.SIZEOF_LONG) + (1 * Bytes.SIZEOF_DOUBLE) + + (8 * Bytes.SIZEOF_LONG) + (1 * Bytes.SIZEOF_DOUBLE) + (4 * Bytes.SIZEOF_INT) + (3 * Bytes.SIZEOF_BOOLEAN)); public static final long DEEP_OVERHEAD = ClassSize.align(FIXED_OVERHEAD + Index: src/main/java/org/apache/hadoop/hbase/HServerLoad.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/HServerLoad.java (revision 1129767) +++ src/main/java/org/apache/hadoop/hbase/HServerLoad.java (working copy) @@ -36,7 +36,7 @@ */ public class HServerLoad extends VersionedWritable implements WritableComparable { - private static final byte VERSION = 1; + private static final byte VERSION = 2; // Empty load instance. public static final HServerLoad EMPTY_HSERVERLOAD = new HServerLoad(); @@ -64,7 +64,7 @@ * Encapsulates per-region loading metrics. */ public static class RegionLoad extends VersionedWritable { - private static final byte VERSION = 0; + private static final byte VERSION = 1; /** @return the object version number */ public byte getVersion() { @@ -77,6 +77,8 @@ private int stores; /** the number of storefiles for the region */ private int storefiles; + /** the total size of the store files for the region, uncompressed, in MB */ + private int storeUncompressedSizeMB; /** the current total size of the store files for the region, in MB */ private int storefileSizeMB; /** the current size of the memstore for the region, in MB */ @@ -106,12 +108,14 @@ * @param writeRequestsCount */ public RegionLoad(final byte[] name, final int stores, - final int storefiles, final int storefileSizeMB, + final int storefiles, final int storeUncompressedSizeMB, + final int storefileSizeMB, final int memstoreSizeMB, final int storefileIndexSizeMB, final int readRequestsCount, final int writeRequestsCount) { this.name = name; this.stores = stores; this.storefiles = storefiles; + this.storeUncompressedSizeMB = storeUncompressedSizeMB; this.storefileSizeMB = storefileSizeMB; this.memstoreSizeMB = memstoreSizeMB; this.storefileIndexSizeMB = storefileIndexSizeMB; @@ -246,13 +250,14 @@ // Writable public void readFields(DataInput in) throws IOException { super.readFields(in); - int version = getVersion(); - if (version != VERSION) throw new IOException("Version mismatch; " + version); + int version = in.readByte(); + if (version > VERSION) throw new IOException("Version mismatch; " + version); int namelen = in.readInt(); this.name = new byte[namelen]; in.readFully(this.name); this.stores = in.readInt(); this.storefiles = in.readInt(); + this.storeUncompressedSizeMB = in.readInt(); this.storefileSizeMB = in.readInt(); this.memstoreSizeMB = in.readInt(); this.storefileIndexSizeMB = in.readInt(); @@ -262,10 +267,12 @@ public void write(DataOutput out) throws IOException { super.write(out); + out.writeByte(VERSION); out.writeInt(name.length); out.write(name); out.writeInt(stores); out.writeInt(storefiles); + out.writeInt(storeUncompressedSizeMB); out.writeInt(storefileSizeMB); out.writeInt(memstoreSizeMB); out.writeInt(storefileIndexSizeMB); @@ -282,8 +289,15 @@ Integer.valueOf(this.stores)); sb = Strings.appendKeyValue(sb, "storefiles", Integer.valueOf(this.storefiles)); + sb = Strings.appendKeyValue(sb, "storefileUncompressedSizeMB", + Integer.valueOf(this.storeUncompressedSizeMB)); sb = Strings.appendKeyValue(sb, "storefileSizeMB", Integer.valueOf(this.storefileSizeMB)); + if (this.storeUncompressedSizeMB != 0) { + sb = Strings.appendKeyValue(sb, "compressionRatio", + String.format("%.4f", (float)this.storefileSizeMB/ + (float)this.storeUncompressedSizeMB)); + } sb = Strings.appendKeyValue(sb, "memstoreSizeMB", Integer.valueOf(this.memstoreSizeMB)); sb = Strings.appendKeyValue(sb, "storefileIndexSizeMB", @@ -480,8 +494,8 @@ public void readFields(DataInput in) throws IOException { super.readFields(in); - int version = getVersion(); - if (version != VERSION) throw new IOException("Version mismatch; " + version); + int version = in.readByte(); + if (version > VERSION) throw new IOException("Version mismatch; " + version); numberOfRequests = in.readInt(); usedHeapMB = in.readInt(); maxHeapMB = in.readInt(); @@ -495,6 +509,7 @@ public void write(DataOutput out) throws IOException { super.write(out); + out.writeByte(VERSION); out.writeInt(numberOfRequests); out.writeInt(usedHeapMB); out.writeInt(maxHeapMB);