HADOOP-17081. MetricsSystem doesn't start the sink adapters on restart (#2089)

Contributed by Madhusoodan P
This commit is contained in:
Madhusoodan Pataki 2020-07-06 20:55:42 +05:30 committed by Steve Loughran
parent 20df70a895
commit 0789ae5b78
2 changed files with 26 additions and 1 deletions

View File

@ -273,7 +273,11 @@ void registerSource(String name, String desc, MetricsSource source) {
T register(final String name, final String description, final T sink) {
LOG.debug(name +", "+ description);
if (allSinks.containsKey(name)) {
LOG.warn("Sink "+ name +" already exists!");
if(sinks.get(name) == null) {
registerSink(name, description, sink);
} else {
LOG.warn("Sink "+ name +" already exists!");
}
return sink;
}
allSinks.put(name, sink);

View File

@ -639,4 +639,25 @@ private static class TestSource2 {
private static String getPluginUrlsAsString() {
return "file:metrics2-test-plugin.jar";
}
@Test
public void testMetricSystemRestart() {
MetricsSystemImpl ms = new MetricsSystemImpl("msRestartTestSystem");
TestSink ts = new TestSink();
String sinkName = "restartTestSink";
try {
ms.start();
ms.register(sinkName, "", ts);
assertNotNull("no adapter exists for " + sinkName,
ms.getSinkAdapter(sinkName));
ms.stop();
ms.start();
assertNotNull("no adapter exists for " + sinkName,
ms.getSinkAdapter(sinkName));
} finally {
ms.stop();
}
}
}