HBASE-1022 Add storefile index size to hbase metrics

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@720294 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Kyle Purtell 2008-11-24 21:17:43 +00:00
parent c370e1cab2
commit 2826eeeeef
4 changed files with 41 additions and 5 deletions

View File

@ -137,7 +137,8 @@ Release 0.19.0 - Unreleased
HBASE-927 We don't recover if HRS hosting -ROOT-/.META. goes down
HBASE-1013 Add debugging around commit log cleanup
HBASE-972 Update hbase trunk to use released hadoop 0.19.0
HBASE-1022 Add storefile index size to hbase metrics
NEW FEATURES
HBASE-875 Use MurmurHash instead of JenkinsHash [in bloomfilters]
(Andrzej Bialecki via Stack)

View File

@ -2137,7 +2137,19 @@ public class HStore implements HConstants {
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.
*/

View File

@ -52,7 +52,7 @@ import org.apache.hadoop.io.SequenceFile;
* <p>An HStoreFile usually tracks 4 things: its parent dir, the region
* identifier, the column family, and the file identifier. If you know those
* four things, you know how to obtain the right HStoreFile. HStoreFiles may
* also refernce store files in another region serving either from
* also reference store files in another region serving either from
* the top-half of the remote file or from the bottom-half. Such references
* are made fast splitting regions.
*
@ -101,6 +101,7 @@ public class HStoreFile implements HConstants {
/* If true, this file was product of a major compaction.
*/
private boolean majorCompaction = false;
private long indexLength;
/**
* Constructor that fully initializes the object
@ -381,7 +382,7 @@ public class HStoreFile implements HConstants {
out.close();
}
}
/**
* Delete store map files.
* @throws IOException
@ -477,6 +478,18 @@ public class HStoreFile implements HConstants {
return (isReference())? l / 2: l;
}
/**
* @return Length of the store map file index.
* @throws IOException
*/
public synchronized long indexLength() throws IOException {
if (indexLength == 0) {
Path p = new Path(getMapFilePath(reference), MapFile.INDEX_FILE_NAME);
indexLength = p.getFileSystem(conf).getFileStatus(p).getLen();
}
return indexLength;
}
@Override
public String toString() {
return encodedRegionName + "/" + Bytes.toString(colFamily) + "/" + fileId +

View File

@ -53,7 +53,13 @@ public class RegionServerMetrics implements Updater {
* 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
*/
@ -81,6 +87,7 @@ public class RegionServerMetrics implements Updater {
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,6 +133,9 @@ public class RegionServerMetrics implements Updater {
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");