HADOOP-13362. DefaultMetricsSystem leaks the source name when a source unregisters. Contributed by Junping Du
This commit is contained in:
parent
830516b8c5
commit
6759cbc56a
@ -12,6 +12,9 @@ Release 2.7.4 - UNRELEASED
|
|||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
||||||
|
HADOOP-13362. DefaultMetricsSystem leaks the source name when a source
|
||||||
|
unregisters (Junping Du via jlowe)
|
||||||
|
|
||||||
Release 2.7.3 - UNRELEASED
|
Release 2.7.3 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -255,6 +255,7 @@ void unregisterSource(String name) {
|
|||||||
if (namedCallbacks.containsKey(name)) {
|
if (namedCallbacks.containsKey(name)) {
|
||||||
namedCallbacks.remove(name);
|
namedCallbacks.remove(name);
|
||||||
}
|
}
|
||||||
|
DefaultMetricsSystem.removeSourceName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized
|
synchronized
|
||||||
|
@ -107,6 +107,11 @@ public static void removeMBeanName(ObjectName name) {
|
|||||||
INSTANCE.removeObjectName(name.toString());
|
INSTANCE.removeObjectName(name.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@InterfaceAudience.Private
|
||||||
|
public static void removeSourceName(String name) {
|
||||||
|
INSTANCE.removeSource(name);
|
||||||
|
}
|
||||||
|
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public static String sourceName(String name, boolean dupOK) {
|
public static String sourceName(String name, boolean dupOK) {
|
||||||
return INSTANCE.newSourceName(name, dupOK);
|
return INSTANCE.newSourceName(name, dupOK);
|
||||||
@ -127,6 +132,10 @@ synchronized void removeObjectName(String name) {
|
|||||||
mBeanNames.map.remove(name);
|
mBeanNames.map.remove(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synchronized void removeSource(String name) {
|
||||||
|
sourceNames.map.remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
synchronized String newSourceName(String name, boolean dupOK) {
|
synchronized String newSourceName(String name, boolean dupOK) {
|
||||||
if (sourceNames.map.containsKey(name)) {
|
if (sourceNames.map.containsKey(name)) {
|
||||||
if (dupOK) {
|
if (dupOK) {
|
||||||
|
@ -136,7 +136,6 @@ public void testContainerMetricsFinished() throws InterruptedException {
|
|||||||
system.sampleMetrics();
|
system.sampleMetrics();
|
||||||
system.sampleMetrics();
|
system.sampleMetrics();
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
system.stop();
|
|
||||||
// verify metrics1 is unregistered
|
// verify metrics1 is unregistered
|
||||||
assertTrue(metrics1 != ContainerMetrics.forContainer(
|
assertTrue(metrics1 != ContainerMetrics.forContainer(
|
||||||
system, containerId1, 1, 0));
|
system, containerId1, 1, 0));
|
||||||
@ -146,6 +145,9 @@ public void testContainerMetricsFinished() throws InterruptedException {
|
|||||||
// verify metrics3 is still registered
|
// verify metrics3 is still registered
|
||||||
assertTrue(metrics3 == ContainerMetrics.forContainer(
|
assertTrue(metrics3 == ContainerMetrics.forContainer(
|
||||||
system, containerId3, 1, 0));
|
system, containerId3, 1, 0));
|
||||||
|
// move stop() to the end to verify registering containerId1 and
|
||||||
|
// containerId2 won't get MetricsException thrown.
|
||||||
|
system.stop();
|
||||||
system.shutdown();
|
system.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user