HBASE-9650 Per region metrics are not showing up for system tables.
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1526309 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e08500578c
commit
e0768e0814
|
@ -31,6 +31,12 @@ public interface MetricsRegionWrapper {
|
|||
*/
|
||||
String getTableName();
|
||||
|
||||
/**
|
||||
* Get the name of the namespace this table is in.
|
||||
* @return String version of the namespace. Can't be empty.
|
||||
*/
|
||||
String getNamespace();
|
||||
|
||||
/**
|
||||
* Get the name of the region.
|
||||
*
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.hadoop.metrics2.MetricsRecordBuilder;
|
|||
import org.apache.hadoop.metrics2.impl.JmxCacheBuster;
|
||||
import org.apache.hadoop.metrics2.lib.DynamicMetricsRegistry;
|
||||
import org.apache.hadoop.metrics2.lib.MetricMutableCounterLong;
|
||||
import org.apache.hadoop.metrics2.lib.MetricMutableStat;
|
||||
import org.apache.hadoop.metrics2.lib.MetricMutableHistogram;
|
||||
|
||||
public class MetricsRegionSourceImpl implements MetricsRegionSource {
|
||||
|
||||
|
@ -46,8 +46,8 @@ public class MetricsRegionSourceImpl implements MetricsRegionSource {
|
|||
private MetricMutableCounterLong regionIncrement;
|
||||
private MetricMutableCounterLong regionAppend;
|
||||
|
||||
private MetricMutableStat regionGet;
|
||||
private MetricMutableStat regionScanNext;
|
||||
private MetricMutableHistogram regionGet;
|
||||
private MetricMutableHistogram regionScanNext;
|
||||
|
||||
public MetricsRegionSourceImpl(MetricsRegionWrapper regionWrapper,
|
||||
MetricsRegionAggregateSourceImpl aggregate) {
|
||||
|
@ -56,14 +56,14 @@ public class MetricsRegionSourceImpl implements MetricsRegionSource {
|
|||
agg.register(this);
|
||||
|
||||
LOG.debug("Creating new MetricsRegionSourceImpl for table " +
|
||||
regionWrapper.getTableName() +
|
||||
" " +
|
||||
regionWrapper.getRegionName());
|
||||
regionWrapper.getTableName() + " " + regionWrapper.getRegionName());
|
||||
|
||||
registry = agg.getMetricsRegistry();
|
||||
|
||||
regionNamePrefix = "table." + regionWrapper.getTableName() + "."
|
||||
+ "region." + regionWrapper.getRegionName() + ".";
|
||||
regionNamePrefix = "namespace_" + regionWrapper.getNamespace() +
|
||||
"_table_" + regionWrapper.getTableName() +
|
||||
"_region_" + regionWrapper.getRegionName() +
|
||||
"_metric_";
|
||||
|
||||
String suffix = "Count";
|
||||
|
||||
|
@ -81,10 +81,10 @@ public class MetricsRegionSourceImpl implements MetricsRegionSource {
|
|||
regionAppend = registry.getLongCounter(regionAppendKey, 0l);
|
||||
|
||||
regionGetKey = regionNamePrefix + MetricsRegionServerSource.GET_KEY;
|
||||
regionGet = registry.newStat(regionGetKey, "", OPS_SAMPLE_NAME, SIZE_VALUE_NAME);
|
||||
regionGet = registry.newHistogram(regionGetKey);
|
||||
|
||||
regionScanNextKey = regionNamePrefix + MetricsRegionServerSource.SCAN_NEXT_KEY;
|
||||
regionScanNext = registry.newStat(regionScanNextKey, "", OPS_SAMPLE_NAME, SIZE_VALUE_NAME);
|
||||
regionScanNext = registry.newHistogram(regionScanNextKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.thrift;
|
|||
|
||||
import org.apache.hadoop.hbase.metrics.BaseSourceImpl;
|
||||
import org.apache.hadoop.metrics2.lib.MetricMutableGaugeLong;
|
||||
import org.apache.hadoop.metrics2.lib.MetricMutableHistogram;
|
||||
import org.apache.hadoop.metrics2.lib.MetricMutableStat;
|
||||
|
||||
/**
|
||||
|
@ -31,12 +32,12 @@ public class MetricsThriftServerSourceImpl extends BaseSourceImpl implements
|
|||
MetricsThriftServerSource {
|
||||
|
||||
|
||||
private MetricMutableStat batchGetStat;
|
||||
private MetricMutableStat batchMutateStat;
|
||||
private MetricMutableStat queueTimeStat;
|
||||
private MetricMutableHistogram batchGetStat;
|
||||
private MetricMutableHistogram batchMutateStat;
|
||||
private MetricMutableHistogram queueTimeStat;
|
||||
|
||||
private MetricMutableStat thriftCallStat;
|
||||
private MetricMutableStat thriftSlowCallStat;
|
||||
private MetricMutableHistogram thriftCallStat;
|
||||
private MetricMutableHistogram thriftSlowCallStat;
|
||||
|
||||
private MetricMutableGaugeLong callQueueLenGauge;
|
||||
|
||||
|
@ -51,11 +52,11 @@ public class MetricsThriftServerSourceImpl extends BaseSourceImpl implements
|
|||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
batchGetStat = getMetricsRegistry().newStat(BATCH_GET_KEY, "", "Keys", "Ops");
|
||||
batchMutateStat = getMetricsRegistry().newStat(BATCH_MUTATE_KEY, "", "Keys", "Ops");
|
||||
queueTimeStat = getMetricsRegistry().newStat(TIME_IN_QUEUE_KEY);
|
||||
thriftCallStat = getMetricsRegistry().newStat(THRIFT_CALL_KEY);
|
||||
thriftSlowCallStat = getMetricsRegistry().newStat(SLOW_THRIFT_CALL_KEY);
|
||||
batchGetStat = getMetricsRegistry().newHistogram(BATCH_GET_KEY);
|
||||
batchMutateStat = getMetricsRegistry().newHistogram(BATCH_MUTATE_KEY);
|
||||
queueTimeStat = getMetricsRegistry().newHistogram(TIME_IN_QUEUE_KEY);
|
||||
thriftCallStat = getMetricsRegistry().newHistogram(THRIFT_CALL_KEY);
|
||||
thriftSlowCallStat = getMetricsRegistry().newHistogram(SLOW_THRIFT_CALL_KEY);
|
||||
callQueueLenGauge = getMetricsRegistry().getLongGauge(CALL_QUEUE_LEN_KEY, 0);
|
||||
}
|
||||
|
||||
|
@ -81,7 +82,7 @@ public class MetricsThriftServerSourceImpl extends BaseSourceImpl implements
|
|||
|
||||
@Override
|
||||
public void incMethodTime(String name, long time) {
|
||||
MetricMutableStat s = getMetricsRegistry().newStat(name);
|
||||
MetricMutableHistogram s = getMetricsRegistry().getHistogram(name);
|
||||
s.add(time);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,12 @@ public class TestMetricsRegionSourceImpl {
|
|||
|
||||
@Override
|
||||
public String getTableName() {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,32 +75,32 @@ public class TestMetricsRegionSourceImpl {
|
|||
|
||||
@Override
|
||||
public long getNumStores() {
|
||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNumStoreFiles() {
|
||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMemstoreSize() {
|
||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStoreFileSize() {
|
||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getReadRequestCount() {
|
||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getWriteRequestCount() {
|
||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.hadoop.metrics2.impl.JmxCacheBuster;
|
|||
import org.apache.hadoop.metrics2.lib.DynamicMetricsRegistry;
|
||||
import org.apache.hadoop.metrics2.lib.Interns;
|
||||
import org.apache.hadoop.metrics2.lib.MutableCounterLong;
|
||||
import org.apache.hadoop.metrics2.lib.MutableStat;
|
||||
import org.apache.hadoop.metrics2.lib.MutableHistogram;
|
||||
|
||||
@InterfaceAudience.Private
|
||||
public class MetricsRegionSourceImpl implements MetricsRegionSource {
|
||||
|
@ -52,8 +52,8 @@ public class MetricsRegionSourceImpl implements MetricsRegionSource {
|
|||
private MutableCounterLong regionIncrement;
|
||||
private MutableCounterLong regionAppend;
|
||||
|
||||
private MutableStat regionGet;
|
||||
private MutableStat regionScanNext;
|
||||
private MutableHistogram regionGet;
|
||||
private MutableHistogram regionScanNext;
|
||||
|
||||
public MetricsRegionSourceImpl(MetricsRegionWrapper regionWrapper,
|
||||
MetricsRegionAggregateSourceImpl aggregate) {
|
||||
|
@ -62,14 +62,14 @@ public class MetricsRegionSourceImpl implements MetricsRegionSource {
|
|||
agg.register(this);
|
||||
|
||||
LOG.debug("Creating new MetricsRegionSourceImpl for table " +
|
||||
regionWrapper.getTableName() +
|
||||
" " +
|
||||
regionWrapper.getRegionName());
|
||||
regionWrapper.getTableName() + " " + regionWrapper.getRegionName());
|
||||
|
||||
registry = agg.getMetricsRegistry();
|
||||
|
||||
regionNamePrefix = "table." + regionWrapper.getTableName() + "."
|
||||
+ "region." + regionWrapper.getRegionName() + ".";
|
||||
regionNamePrefix = "namespace_" + regionWrapper.getNamespace() +
|
||||
"_table_" + regionWrapper.getTableName() +
|
||||
"_region_" + regionWrapper.getRegionName() +
|
||||
"_metric_";
|
||||
|
||||
String suffix = "Count";
|
||||
|
||||
|
@ -86,10 +86,10 @@ public class MetricsRegionSourceImpl implements MetricsRegionSource {
|
|||
regionAppend = registry.getLongCounter(regionAppendKey, 0l);
|
||||
|
||||
regionGetKey = regionNamePrefix + MetricsRegionServerSource.GET_KEY;
|
||||
regionGet = registry.newStat(regionGetKey, "", OPS_SAMPLE_NAME, SIZE_VALUE_NAME);
|
||||
regionGet = registry.newHistogram(regionGetKey);
|
||||
|
||||
regionScanNextKey = regionNamePrefix + MetricsRegionServerSource.SCAN_NEXT_KEY;
|
||||
regionScanNext = registry.newStat(regionScanNextKey, "", OPS_SAMPLE_NAME, SIZE_VALUE_NAME);
|
||||
regionScanNext = registry.newHistogram(regionScanNextKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.hadoop.hbase.thrift;
|
|||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.metrics.BaseSourceImpl;
|
||||
import org.apache.hadoop.metrics2.lib.MutableGaugeLong;
|
||||
import org.apache.hadoop.metrics2.lib.MutableStat;
|
||||
import org.apache.hadoop.metrics2.lib.MutableHistogram;
|
||||
|
||||
/**
|
||||
* Hadoop 2 version of MetricsThriftServerSource{@link org.apache.hadoop.hbase.thrift.MetricsThriftServerSource}
|
||||
|
@ -32,12 +32,12 @@ import org.apache.hadoop.metrics2.lib.MutableStat;
|
|||
public class MetricsThriftServerSourceImpl extends BaseSourceImpl implements
|
||||
MetricsThriftServerSource {
|
||||
|
||||
private MutableStat batchGetStat;
|
||||
private MutableStat batchMutateStat;
|
||||
private MutableStat queueTimeStat;
|
||||
private MutableHistogram batchGetStat;
|
||||
private MutableHistogram batchMutateStat;
|
||||
private MutableHistogram queueTimeStat;
|
||||
|
||||
private MutableStat thriftCallStat;
|
||||
private MutableStat thriftSlowCallStat;
|
||||
private MutableHistogram thriftCallStat;
|
||||
private MutableHistogram thriftSlowCallStat;
|
||||
|
||||
private MutableGaugeLong callQueueLenGauge;
|
||||
|
||||
|
@ -51,13 +51,11 @@ public class MetricsThriftServerSourceImpl extends BaseSourceImpl implements
|
|||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
batchGetStat = getMetricsRegistry().newStat(BATCH_GET_KEY, "", "Keys", "Ops");
|
||||
batchMutateStat = getMetricsRegistry().newStat(BATCH_MUTATE_KEY, "", "Keys", "Ops");
|
||||
queueTimeStat = getMetricsRegistry().newRate(TIME_IN_QUEUE_KEY);
|
||||
|
||||
thriftCallStat = getMetricsRegistry().newRate(THRIFT_CALL_KEY);
|
||||
thriftSlowCallStat = getMetricsRegistry().newRate(SLOW_THRIFT_CALL_KEY);
|
||||
|
||||
batchGetStat = getMetricsRegistry().newHistogram(BATCH_GET_KEY);
|
||||
batchMutateStat = getMetricsRegistry().newHistogram(BATCH_MUTATE_KEY);
|
||||
queueTimeStat = getMetricsRegistry().newHistogram(TIME_IN_QUEUE_KEY);
|
||||
thriftCallStat = getMetricsRegistry().newHistogram(THRIFT_CALL_KEY);
|
||||
thriftSlowCallStat = getMetricsRegistry().newHistogram(SLOW_THRIFT_CALL_KEY);
|
||||
callQueueLenGauge = getMetricsRegistry().getLongGauge(CALL_QUEUE_LEN_KEY, 0);
|
||||
|
||||
}
|
||||
|
@ -84,7 +82,7 @@ public class MetricsThriftServerSourceImpl extends BaseSourceImpl implements
|
|||
|
||||
@Override
|
||||
public void incMethodTime(String name, long time) {
|
||||
MutableStat s = getMetricsRegistry().newRate(name);
|
||||
MutableHistogram s = getMetricsRegistry().getHistogram(name);
|
||||
s.add(time);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,12 @@ public class TestMetricsRegionSourceImpl {
|
|||
|
||||
@Override
|
||||
public String getTableName() {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,32 +75,32 @@ public class TestMetricsRegionSourceImpl {
|
|||
|
||||
@Override
|
||||
public long getNumStores() {
|
||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNumStoreFiles() {
|
||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMemstoreSize() {
|
||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStoreFileSize() {
|
||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getReadRequestCount() {
|
||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getWriteRequestCount() {
|
||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import java.util.concurrent.TimeUnit;
|
|||
public class MetricsRegionWrapperImpl implements MetricsRegionWrapper, Closeable {
|
||||
|
||||
public static final int PERIOD = 45;
|
||||
public static final String UNKNOWN = "unknown";
|
||||
|
||||
private final HRegion region;
|
||||
private ScheduledExecutorService executor;
|
||||
|
@ -55,16 +56,26 @@ public class MetricsRegionWrapperImpl implements MetricsRegionWrapper, Closeable
|
|||
public String getTableName() {
|
||||
HTableDescriptor tableDesc = this.region.getTableDesc();
|
||||
if (tableDesc == null) {
|
||||
return "";
|
||||
return UNKNOWN;
|
||||
}
|
||||
return tableDesc.getTableName().getNameAsString();
|
||||
return tableDesc.getTableName().getQualifierAsString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
HTableDescriptor tableDesc = this.region.getTableDesc();
|
||||
if (tableDesc == null) {
|
||||
return UNKNOWN;
|
||||
}
|
||||
return tableDesc.getTableName().getNamespaceAsString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getRegionName() {
|
||||
HRegionInfo regionInfo = this.region.getRegionInfo();
|
||||
if (regionInfo == null) {
|
||||
return "";
|
||||
return UNKNOWN;
|
||||
}
|
||||
return regionInfo.getEncodedName();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,11 @@ public class MetricsRegionWrapperStub implements MetricsRegionWrapper {
|
|||
return "MetricsRegionWrapperStub";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return "TestNS";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegionName() {
|
||||
return "DEADBEEF001";
|
||||
|
|
|
@ -35,9 +35,9 @@ public class TestMetricsRegion {
|
|||
MetricsRegion mr = new MetricsRegion(new MetricsRegionWrapperStub());
|
||||
MetricsRegionAggregateSource agg = mr.getSource().getAggregateSource();
|
||||
|
||||
HELPER.assertGauge("table.MetricsRegionWrapperStub.region.DEADBEEF001.storeCount", 101, agg);
|
||||
HELPER.assertGauge("table.MetricsRegionWrapperStub.region.DEADBEEF001.storeFileCount", 102, agg);
|
||||
HELPER.assertGauge("table.MetricsRegionWrapperStub.region.DEADBEEF001.memstoreSize", 103, agg);
|
||||
HELPER.assertGauge("namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_storeCount", 101, agg);
|
||||
HELPER.assertGauge("namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_storeFileCount", 102, agg);
|
||||
HELPER.assertGauge("namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_memstoreSize", 103, agg);
|
||||
mr.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,9 +141,12 @@ public class TestRegionServerMetrics {
|
|||
.getMetrics()
|
||||
.getSource()
|
||||
.getAggregateSource();
|
||||
String prefix = "table."+tableNameString + ".region." + i.getEncodedName();
|
||||
metricsHelper.assertCounter(prefix + ".getNumOps", 10, agg);
|
||||
metricsHelper.assertCounter(prefix + ".mutateCount", 30, agg);
|
||||
String prefix = "namespace_"+NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR+
|
||||
"_table_"+tableNameString +
|
||||
"_region_" + i.getEncodedName()+
|
||||
"_metric";
|
||||
metricsHelper.assertCounter(prefix + "_getNumOps", 10, agg);
|
||||
metricsHelper.assertCounter(prefix + "_mutateCount", 30, agg);
|
||||
}
|
||||
|
||||
|
||||
|
@ -347,8 +350,11 @@ public class TestRegionServerMetrics {
|
|||
.getMetrics()
|
||||
.getSource()
|
||||
.getAggregateSource();
|
||||
String prefix = "table."+tableNameString + ".region." + i.getEncodedName();
|
||||
metricsHelper.assertCounter(prefix + ".scanNextNumOps", 30, agg);
|
||||
String prefix = "namespace_"+NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR+
|
||||
"_table_"+tableNameString +
|
||||
"_region_" + i.getEncodedName()+
|
||||
"_metric";
|
||||
metricsHelper.assertCounter(prefix + "_scanNextNumOps", 30, agg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue