HBASE-3223 Get VersionInfo for Running HBase Process

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1040279 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2010-11-29 20:45:43 +00:00
parent 4b5dcb3b31
commit c799c5cc83
3 changed files with 14 additions and 1 deletions

View File

@ -21,6 +21,7 @@ import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.metrics.HBaseInfo;
import org.apache.hadoop.hbase.metrics.MetricsRate;
import org.apache.hadoop.hbase.metrics.PersistentMetricsTimeVaryingRate;
import org.apache.hadoop.metrics.ContextFactory;
@ -69,6 +70,7 @@ public class MasterMetrics implements Updater {
metricsRecord.setTag("Master", name);
context.registerUpdater(this);
JvmMetrics.init("Master", name);
HBaseInfo.init();
// expose the MBean for metrics
masterStatistics = new MasterStatistics(this.registry);

View File

@ -95,14 +95,20 @@ public class MetricsMBeanBase extends MetricsDynamicMBeanBase {
continue;
// add on custom HBase metric types
if (metric instanceof org.apache.hadoop.hbase.metrics.MetricsRate) {
if (metric instanceof MetricsRate) {
attributes.add( new MBeanAttributeInfo(metric.getName(),
"java.lang.Float", metric.getDescription(), true, false, false) );
extendedAttributes.put(metric.getName(), metric);
} else if (metric instanceof MetricsString) {
attributes.add( new MBeanAttributeInfo(metric.getName(),
"java.lang.String", metric.getDescription(), true, false, false) );
extendedAttributes.put(metric.getName(), metric);
LOG.info("MetricsString added: " + metric.getName());
}
// else, its probably a hadoop metric already registered. Skip it.
}
LOG.info("new MBeanInfo");
this.extendedInfo = new MBeanInfo( this.getClass().getName(),
this.description, attributes.toArray( new MBeanAttributeInfo[0] ),
parentInfo.getConstructors(), parentInfo.getOperations(),
@ -140,6 +146,8 @@ public class MetricsMBeanBase extends MetricsDynamicMBeanBase {
if (metric != null) {
if (metric instanceof MetricsRate) {
return ((MetricsRate) metric).getPreviousIntervalValue();
} else if (metric instanceof MetricsString) {
return ((MetricsString)metric).getValue();
} else {
LOG.warn( String.format("unknown metrics type %s for attribute %s",
metric.getClass().getName(), name) );

View File

@ -22,6 +22,7 @@ package org.apache.hadoop.hbase.regionserver.metrics;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.io.hfile.HFile;
import org.apache.hadoop.hbase.metrics.HBaseInfo;
import org.apache.hadoop.hbase.metrics.MetricsRate;
import org.apache.hadoop.hbase.metrics.PersistentMetricsTimeVaryingRate;
import org.apache.hadoop.hbase.regionserver.wal.HLog;
@ -173,6 +174,8 @@ public class RegionServerMetrics implements Updater {
context.registerUpdater(this);
// Add jvmmetrics.
JvmMetrics.init("RegionServer", name);
// Add Hbase Info metrics
HBaseInfo.init();
// export for JMX
statistics = new RegionServerStatistics(this.registry, name);