HBASE-20917 MetaTableMetrics#stop references uninitialized requestsMap for non-meta region
This commit is contained in:
parent
4613f3e8c7
commit
37de961f20
|
@ -309,9 +309,8 @@ public class MetaTableMetrics implements RegionCoprocessor {
|
||||||
public void start(CoprocessorEnvironment env) throws IOException {
|
public void start(CoprocessorEnvironment env) throws IOException {
|
||||||
if (env instanceof RegionCoprocessorEnvironment
|
if (env instanceof RegionCoprocessorEnvironment
|
||||||
&& ((RegionCoprocessorEnvironment) env).getRegionInfo().getTable() != null
|
&& ((RegionCoprocessorEnvironment) env).getRegionInfo().getTable() != null
|
||||||
&& ((RegionCoprocessorEnvironment) env).getRegionInfo().getTable().getName() != null
|
&& ((RegionCoprocessorEnvironment) env).getRegionInfo().getTable()
|
||||||
&& new String(((RegionCoprocessorEnvironment) env).getRegionInfo().getTable().getName(),
|
.equals(TableName.META_TABLE_NAME)) {
|
||||||
StandardCharsets.UTF_8).equals(TableName.META_TABLE_NAME.toString())) {
|
|
||||||
regionCoprocessorEnv = (RegionCoprocessorEnvironment) env;
|
regionCoprocessorEnv = (RegionCoprocessorEnvironment) env;
|
||||||
observer = new ExampleRegionObserverMeta();
|
observer = new ExampleRegionObserverMeta();
|
||||||
requestsMap = new ConcurrentHashMap<>();
|
requestsMap = new ConcurrentHashMap<>();
|
||||||
|
@ -324,12 +323,14 @@ public class MetaTableMetrics implements RegionCoprocessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop(CoprocessorEnvironment e) throws IOException {
|
public void stop(CoprocessorEnvironment env) throws IOException {
|
||||||
// since meta region can move around, clear stale metrics when stop.
|
// since meta region can move around, clear stale metrics when stop.
|
||||||
|
if (requestsMap != null) {
|
||||||
for (String meterName : requestsMap.keySet()) {
|
for (String meterName : requestsMap.keySet()) {
|
||||||
MetricRegistry registry = regionCoprocessorEnv.getMetricRegistryForRegionServer();
|
MetricRegistry registry = regionCoprocessorEnv.getMetricRegistryForRegionServer();
|
||||||
registry.remove(meterName);
|
registry.remove(meterName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue