HBASE-14082 Add replica id to JMX metrics names (Lei Chen)
This commit is contained in:
parent
c1ac4bb860
commit
17bdf9fa8c
|
@ -37,6 +37,8 @@ public interface MetricsRegionSource extends Comparable<MetricsRegionSource> {
|
||||||
"Number of files that were input for finished, successful or aborted, compactions";
|
"Number of files that were input for finished, successful or aborted, compactions";
|
||||||
String COPROCESSOR_EXECUTION_STATISTICS = "coprocessorExecutionStatistics";
|
String COPROCESSOR_EXECUTION_STATISTICS = "coprocessorExecutionStatistics";
|
||||||
String COPROCESSOR_EXECUTION_STATISTICS_DESC = "Statistics for coprocessor execution times";
|
String COPROCESSOR_EXECUTION_STATISTICS_DESC = "Statistics for coprocessor execution times";
|
||||||
|
String REPLICA_ID = "replicaid";
|
||||||
|
String REPLICA_ID_DESC = "The replica ID of a region. 0 is primary, otherwise is secondary";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the region's metrics as this region is closing.
|
* Close the region's metrics as this region is closing.
|
||||||
|
|
|
@ -90,4 +90,9 @@ public interface MetricsRegionWrapper {
|
||||||
* Get the time spent by coprocessors in this region.
|
* Get the time spent by coprocessors in this region.
|
||||||
*/
|
*/
|
||||||
Map<String, DescriptiveStatistics> getCoprocessorExecutionStatistics();
|
Map<String, DescriptiveStatistics> getCoprocessorExecutionStatistics();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the replica id of this region.
|
||||||
|
*/
|
||||||
|
int getReplicaId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,6 +242,9 @@ public class MetricsRegionSourceImpl implements MetricsRegionSource {
|
||||||
regionNamePrefix + MetricsRegionServerSource.WRITE_REQUEST_COUNT,
|
regionNamePrefix + MetricsRegionServerSource.WRITE_REQUEST_COUNT,
|
||||||
MetricsRegionServerSource.WRITE_REQUEST_COUNT_DESC),
|
MetricsRegionServerSource.WRITE_REQUEST_COUNT_DESC),
|
||||||
this.regionWrapper.getWriteRequestCount());
|
this.regionWrapper.getWriteRequestCount());
|
||||||
|
mrb.addCounter(Interns.info(regionNamePrefix + MetricsRegionSource.REPLICA_ID,
|
||||||
|
MetricsRegionSource.REPLICA_ID_DESC),
|
||||||
|
this.regionWrapper.getReplicaId());
|
||||||
|
|
||||||
for (Map.Entry<String, DescriptiveStatistics> entry : this.regionWrapper
|
for (Map.Entry<String, DescriptiveStatistics> entry : this.regionWrapper
|
||||||
.getCoprocessorExecutionStatistics()
|
.getCoprocessorExecutionStatistics()
|
||||||
|
|
|
@ -133,5 +133,13 @@ public class TestMetricsRegionSourceImpl {
|
||||||
public Map<String, DescriptiveStatistics> getCoprocessorExecutionStatistics() {
|
public Map<String, DescriptiveStatistics> getCoprocessorExecutionStatistics() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Always return 0 for testing
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getReplicaId() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,4 +174,12 @@ public class MetricsRegionWrapperImpl implements MetricsRegionWrapper, Closeable
|
||||||
return coprocessorTimes;
|
return coprocessorTimes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the replica id of this region.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getReplicaId() {
|
||||||
|
return region.getRegionInfo().getReplicaId();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,21 @@ import java.util.Map;
|
||||||
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
|
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
|
||||||
|
|
||||||
public class MetricsRegionWrapperStub implements MetricsRegionWrapper {
|
public class MetricsRegionWrapperStub implements MetricsRegionWrapper {
|
||||||
|
int replicaid = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replica ID set to 0
|
||||||
|
*/
|
||||||
|
public MetricsRegionWrapperStub() {
|
||||||
|
this.replicaid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pass in replica ID
|
||||||
|
*/
|
||||||
|
public MetricsRegionWrapperStub(int replicaid) {
|
||||||
|
this.replicaid = replicaid;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTableName() {
|
public String getTableName() {
|
||||||
|
@ -94,4 +109,12 @@ public class MetricsRegionWrapperStub implements MetricsRegionWrapper {
|
||||||
public Map<String, DescriptiveStatistics> getCoprocessorExecutionStatistics() {
|
public Map<String, DescriptiveStatistics> getCoprocessorExecutionStatistics() {
|
||||||
return new HashMap<String, DescriptiveStatistics>();
|
return new HashMap<String, DescriptiveStatistics>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the replica id of this region.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getReplicaId() {
|
||||||
|
return replicaid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,9 +36,35 @@ public class TestMetricsRegion {
|
||||||
MetricsRegion mr = new MetricsRegion(new MetricsRegionWrapperStub());
|
MetricsRegion mr = new MetricsRegion(new MetricsRegionWrapperStub());
|
||||||
MetricsRegionAggregateSource agg = mr.getSource().getAggregateSource();
|
MetricsRegionAggregateSource agg = mr.getSource().getAggregateSource();
|
||||||
|
|
||||||
HELPER.assertGauge("namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_storeCount", 101, agg);
|
HELPER.assertGauge(
|
||||||
HELPER.assertGauge("namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_storeFileCount", 102, agg);
|
"namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_storeCount",
|
||||||
HELPER.assertGauge("namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_memstoreSize", 103, agg);
|
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);
|
||||||
|
HELPER.assertCounter(
|
||||||
|
"namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_replicaid",
|
||||||
|
0, agg);
|
||||||
|
mr.close();
|
||||||
|
|
||||||
|
// test region with replica id > 0
|
||||||
|
mr = new MetricsRegion(new MetricsRegionWrapperStub(1));
|
||||||
|
agg = mr.getSource().getAggregateSource();
|
||||||
|
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);
|
||||||
|
HELPER.assertCounter(
|
||||||
|
"namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_replicaid",
|
||||||
|
1, agg);
|
||||||
mr.close();
|
mr.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue