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-2126 Fix build break - ec2 (Kay Kay via JD)
HBASE-2134 Ivy nit regarding checking with latest snapshots (Kay Kay via HBASE-2134 Ivy nit regarding checking with latest snapshots (Kay Kay via
Andrew Purtell) Andrew Purtell)
HBASE-2138 unknown metrics type (Stack via JD)
IMPROVEMENTS IMPROVEMENTS
HBASE-1760 Cleanup TODOs in HTable HBASE-1760 Cleanup TODOs in HTable

View File

@ -20,7 +20,6 @@
package org.apache.hadoop.hbase.metrics; package org.apache.hadoop.hbase.metrics;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -59,12 +58,27 @@ public class MetricsMBeanBase extends MetricsDynamicMBeanBase {
protected MBeanInfo extendedInfo; protected MBeanInfo extendedInfo;
protected MetricsMBeanBase( MetricsRegistry mr, String description ) { protected MetricsMBeanBase( MetricsRegistry mr, String description ) {
super(mr, description); super(copyMinusHBaseMetrics(mr), description);
this.registry = mr; this.registry = mr;
this.description = description; this.description = description;
this.init(); 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() { protected void init() {
List<MBeanAttributeInfo> attributes = new ArrayList<MBeanAttributeInfo>(); List<MBeanAttributeInfo> attributes = new ArrayList<MBeanAttributeInfo>();
MBeanInfo parentInfo = super.getMBeanInfo(); MBeanInfo parentInfo = super.getMBeanInfo();
@ -81,13 +95,12 @@ public class MetricsMBeanBase extends MetricsDynamicMBeanBase {
continue; continue;
// add on custom HBase metric types // 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(), attributes.add( new MBeanAttributeInfo(metric.getName(),
"java.lang.Float", metric.getDescription(), true, false, false) ); "java.lang.Float", metric.getDescription(), true, false, false) );
extendedAttributes.put(metric.getName(), metric); 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(), this.extendedInfo = new MBeanInfo( this.getClass().getName(),

View File

@ -169,13 +169,26 @@ public class RegionServerMetrics implements Updater {
this.blockCacheFree.pushMetric(this.metricsRecord); this.blockCacheFree.pushMetric(this.metricsRecord);
this.blockCacheCount.pushMetric(this.metricsRecord); this.blockCacheCount.pushMetric(this.metricsRecord);
this.blockCacheHitRatio.pushMetric(this.metricsRecord); this.blockCacheHitRatio.pushMetric(this.metricsRecord);
// mix in HFile metrics // Mix in HFile and HLog metrics
this.fsReadLatency.inc((int)HFile.getReadOps(), HFile.getReadTime()); // Be careful. Here is code for MTVR from up in hadoop:
this.fsWriteLatency.inc((int)HFile.getWriteOps(), HFile.getWriteTime()); // 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 // mix in HLog metrics
this.fsWriteLatency.inc((int)HLog.getWriteOps(), HLog.getWriteTime()); ops = (int)HLog.getWriteOps();
this.fsSyncLatency.inc((int)HLog.getSyncOps(), HLog.getSyncTime()); 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 // push the result
this.fsReadLatency.pushMetric(this.metricsRecord); this.fsReadLatency.pushMetric(this.metricsRecord);
this.fsWriteLatency.pushMetric(this.metricsRecord); this.fsWriteLatency.pushMetric(this.metricsRecord);
@ -244,4 +257,4 @@ public class RegionServerMetrics implements Updater {
Long.valueOf(this.blockCacheHitRatio.get())); Long.valueOf(this.blockCacheHitRatio.get()));
return sb.toString(); return sb.toString();
} }
} }