HBASE-3565 Add metrics to keep track of slow HLog appends (Mubarak)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1230188 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2012-01-11 19:02:28 +00:00
parent 97579d4019
commit 39a1e07ce4
2 changed files with 25 additions and 0 deletions

View File

@ -232,6 +232,12 @@ public class RegionServerMetrics implements Updater {
protected final PersistentMetricsTimeVaryingRate flushSize =
new PersistentMetricsTimeVaryingRate("flushSize", registry);
public final MetricsLongValue slowHLogAppendCount =
new MetricsLongValue("slowHLogAppendCount", registry);
public final MetricsTimeVaryingRate slowHLogAppendTime =
new MetricsTimeVaryingRate("slowHLogAppendTime", registry);
public RegionServerMetrics() {
MetricsContext context = MetricsUtil.getContext("hbase");
@ -323,6 +329,8 @@ public class RegionServerMetrics implements Updater {
addHLogMetric(HLog.getWriteTime(), this.fsWriteLatency);
addHLogMetric(HLog.getWriteSize(), this.fsWriteSize);
addHLogMetric(HLog.getSyncTime(), this.fsSyncLatency);
addHLogMetric(HLog.getSlowAppendTime(), this.slowHLogAppendTime);
this.slowHLogAppendCount.set(HLog.getSlowAppendCount());
// HFile metrics, sequential reads
int ops = HFile.getReadOps();
if (ops != 0) this.fsReadLatency.inc(ops, HFile.getReadTimeMs());
@ -345,6 +353,7 @@ public class RegionServerMetrics implements Updater {
this.compactionSize.pushMetric(this.metricsRecord);
this.flushTime.pushMetric(this.metricsRecord);
this.flushSize.pushMetric(this.metricsRecord);
this.slowHLogAppendCount.pushMetric(this.metricsRecord);
}
this.metricsRecord.update();
}
@ -367,6 +376,7 @@ public class RegionServerMetrics implements Updater {
this.fsWriteLatency.resetMinMax();
this.fsWriteSize.resetMinMax();
this.fsSyncLatency.resetMinMax();
this.slowHLogAppendTime.resetMinMax();
}
/**
@ -457,6 +467,8 @@ public class RegionServerMetrics implements Updater {
Long.valueOf(this.blockCacheHitCachingRatio.get())+"%");
sb = Strings.appendKeyValue(sb, this.hdfsBlocksLocalityIndex.getName(),
Long.valueOf(this.hdfsBlocksLocalityIndex.get()));
sb = Strings.appendKeyValue(sb, "slowHLogAppendCount",
Long.valueOf(this.slowHLogAppendCount.get()));
return sb.toString();
}
}

View File

@ -296,6 +296,9 @@ public class HLog implements Syncable {
// For measuring latency of syncs
private static Metric syncTime = new Metric();
private static AtomicLong syncBatchSize = new AtomicLong();
//For measuring slow HLog appends
private static AtomicLong slowHLogAppendCount = new AtomicLong();
private static Metric slowHLogAppendTime = new Metric();
public static Metric getWriteTime() {
return writeTime.get();
@ -312,6 +315,14 @@ public class HLog implements Syncable {
public static long getSyncBatchSize() {
return syncBatchSize.getAndSet(0);
}
public static long getSlowAppendCount() {
return slowHLogAppendCount.get();
}
public static Metric getSlowAppendTime() {
return slowHLogAppendTime.get();
}
/**
* Constructor.
@ -1407,6 +1418,8 @@ public class HLog implements Syncable {
"%s took %d ms appending an edit to hlog; editcount=%d, len~=%s",
Thread.currentThread().getName(), took, this.numEntries.get(),
StringUtils.humanReadableInt(len)));
slowHLogAppendCount.incrementAndGet();
slowHLogAppendTime.inc(took);
}
} catch (IOException e) {
LOG.fatal("Could not append. Requesting close of hlog", e);