HBASE-20917 MetaTableMetrics#stop references uninitialized requestsMap for non-meta region
with addendum (cherry picked from commit654480326b
) (cherry picked from commit3787c72953
)
This commit is contained in:
parent
d89e5270aa
commit
6c18d97357
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue