HBASE-20917 MetaTableMetrics#stop references uninitialized requestsMap for non-meta region

with addendum

(cherry picked from commit 654480326b)
(cherry picked from commit 3787c72953)
This commit is contained in:
tedyu 2018-07-22 20:51:58 -07:00 committed by Sean Busbey
parent d89e5270aa
commit 6c18d97357
1 changed files with 10 additions and 10 deletions

View File

@ -197,9 +197,8 @@ public class MetaTableMetrics implements RegionCoprocessor {
} }
private boolean isMetaTableOp(ObserverContext<RegionCoprocessorEnvironment> e) { private boolean isMetaTableOp(ObserverContext<RegionCoprocessorEnvironment> e) {
return TableName.META_TABLE_NAME.toString() return TableName.META_TABLE_NAME
.equals(new String(e.getEnvironment().getRegionInfo().getTable().getName(), .equals(e.getEnvironment().getRegionInfo().getTable());
StandardCharsets.UTF_8));
} }
private void clientMetricRegisterAndMark(ObserverContext<RegionCoprocessorEnvironment> e) { private void clientMetricRegisterAndMark(ObserverContext<RegionCoprocessorEnvironment> e) {
@ -309,9 +308,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,11 +322,13 @@ 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.
for (String meterName : requestsMap.keySet()) { if (requestsMap != null) {
MetricRegistry registry = regionCoprocessorEnv.getMetricRegistryForRegionServer(); for (String meterName : requestsMap.keySet()) {
registry.remove(meterName); MetricRegistry registry = regionCoprocessorEnv.getMetricRegistryForRegionServer();
registry.remove(meterName);
}
} }
} }