HBASE-2138 unknown metrics type (Stack via JD)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@900039 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jean-Daniel Cryans 2010-01-17 00:31:13 +00:00
parent 43ef004de3
commit f9b14e8510
3 changed files with 40 additions and 13 deletions

View File

@ -170,6 +170,7 @@ Release 0.21.0 - Unreleased
HBASE-2126 Fix build break - ec2 (Kay Kay via JD)
HBASE-2134 Ivy nit regarding checking with latest snapshots (Kay Kay via
Andrew Purtell)
HBASE-2138 unknown metrics type (Stack via JD)
IMPROVEMENTS
HBASE-1760 Cleanup TODOs in HTable

View File

@ -20,7 +20,6 @@
package org.apache.hadoop.hbase.metrics;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -59,12 +58,27 @@ public class MetricsMBeanBase extends MetricsDynamicMBeanBase {
protected MBeanInfo extendedInfo;
protected MetricsMBeanBase( MetricsRegistry mr, String description ) {
super(mr, description);
super(copyMinusHBaseMetrics(mr), description);
this.registry = mr;
this.description = description;
this.init();
}
/*
* @param mr MetricsRegistry.
* @return A copy of the passed MetricsRegistry minus the hbase metrics
*/
private static MetricsRegistry copyMinusHBaseMetrics(final MetricsRegistry mr) {
MetricsRegistry copy = new MetricsRegistry();
for (MetricsBase metric : mr.getMetricsList()) {
if (metric instanceof org.apache.hadoop.hbase.metrics.MetricsRate) {
continue;
}
copy.add(metric.getName(), metric);
}
return copy;
}
protected void init() {
List<MBeanAttributeInfo> attributes = new ArrayList<MBeanAttributeInfo>();
MBeanInfo parentInfo = super.getMBeanInfo();
@ -81,13 +95,12 @@ public class MetricsMBeanBase extends MetricsDynamicMBeanBase {
continue;
// add on custom HBase metric types
if (metric instanceof MetricsRate) {
if (metric instanceof org.apache.hadoop.hbase.metrics.MetricsRate) {
attributes.add( new MBeanAttributeInfo(metric.getName(),
"java.lang.Float", metric.getDescription(), true, false, false) );
extendedAttributes.put(metric.getName(), metric);
} else {
LOG.error("unknown metrics instance: "+metric.getClass().getName());
}
}
// else, its probably a hadoop metric already registered. Skip it.
}
this.extendedInfo = new MBeanInfo( this.getClass().getName(),

View File

@ -169,13 +169,26 @@ public class RegionServerMetrics implements Updater {
this.blockCacheFree.pushMetric(this.metricsRecord);
this.blockCacheCount.pushMetric(this.metricsRecord);
this.blockCacheHitRatio.pushMetric(this.metricsRecord);
// mix in HFile metrics
this.fsReadLatency.inc((int)HFile.getReadOps(), HFile.getReadTime());
this.fsWriteLatency.inc((int)HFile.getWriteOps(), HFile.getWriteTime());
// Mix in HFile and HLog metrics
// Be careful. Here is code for MTVR from up in hadoop:
// public synchronized void inc(final int numOps, final long time) {
// currentData.numOperations += numOps;
// currentData.time += time;
// long timePerOps = time/numOps;
// minMax.update(timePerOps);
// }
// Means you can't pass a numOps of zero or get a ArithmeticException / by zero.
int ops = (int)HFile.getReadOps();
if (ops != 0) this.fsReadLatency.inc(ops, HFile.getReadTime());
ops = (int)HFile.getWriteOps();
if (ops != 0) this.fsWriteLatency.inc(ops, HFile.getWriteTime());
// mix in HLog metrics
this.fsWriteLatency.inc((int)HLog.getWriteOps(), HLog.getWriteTime());
this.fsSyncLatency.inc((int)HLog.getSyncOps(), HLog.getSyncTime());
ops = (int)HLog.getWriteOps();
if (ops != 0) this.fsWriteLatency.inc(ops, HLog.getWriteTime());
ops = (int)HLog.getSyncOps();
if (ops != 0) this.fsSyncLatency.inc(ops, HLog.getSyncTime());
// push the result
this.fsReadLatency.pushMetric(this.metricsRecord);
this.fsWriteLatency.pushMetric(this.metricsRecord);
@ -244,4 +257,4 @@ public class RegionServerMetrics implements Updater {
Long.valueOf(this.blockCacheHitRatio.get()));
return sb.toString();
}
}
}