HADOOP-11163. MetricsSystemImpl may miss a registered source. Contributed by Chuan Liu.
(cherry picked from commit69c9af9103
) (cherry picked from commita828ef15b0
)
This commit is contained in:
parent
f567f3c833
commit
29c203585e
|
@ -577,6 +577,8 @@ Release 2.6.0 - UNRELEASED
|
||||||
HADOOP-11117 UGI HadoopLoginModule doesn't catch & wrap all
|
HADOOP-11117 UGI HadoopLoginModule doesn't catch & wrap all
|
||||||
kerberos-related exceptions (stevel)
|
kerberos-related exceptions (stevel)
|
||||||
|
|
||||||
|
HADOOP-11163 MetricsSystemImpl may miss a registered source. (cnauroth)
|
||||||
|
|
||||||
Release 2.5.1 - 2014-09-05
|
Release 2.5.1 - 2014-09-05
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -234,7 +234,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
|
||||||
}
|
}
|
||||||
// We want to re-register the source to pick up new config when the
|
// We want to re-register the source to pick up new config when the
|
||||||
// metrics system restarts.
|
// metrics system restarts.
|
||||||
register(name, new AbstractCallback() {
|
register(finalName, new AbstractCallback() {
|
||||||
@Override public void postStart() {
|
@Override public void postStart() {
|
||||||
registerSource(finalName, finalDesc, s);
|
registerSource(finalName, finalDesc, s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -397,6 +397,24 @@ public class TestMetricsSystemImpl {
|
||||||
ms.shutdown();
|
ms.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test public void testRegisterSourceWithoutName() {
|
||||||
|
MetricsSystem ms = new MetricsSystemImpl();
|
||||||
|
TestSource ts = new TestSource("ts");
|
||||||
|
TestSource2 ts2 = new TestSource2("ts2");
|
||||||
|
ms.register(ts);
|
||||||
|
ms.register(ts2);
|
||||||
|
ms.init("TestMetricsSystem");
|
||||||
|
// if metrics source is registered without name,
|
||||||
|
// the class name will be used as the name
|
||||||
|
MetricsSourceAdapter sa = ((MetricsSystemImpl) ms)
|
||||||
|
.getSourceAdapter("TestSource");
|
||||||
|
assertNotNull(sa);
|
||||||
|
MetricsSourceAdapter sa2 = ((MetricsSystemImpl) ms)
|
||||||
|
.getSourceAdapter("TestSource2");
|
||||||
|
assertNotNull(sa2);
|
||||||
|
ms.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
private void checkMetricsRecords(List<MetricsRecord> recs) {
|
private void checkMetricsRecords(List<MetricsRecord> recs) {
|
||||||
LOG.debug(recs);
|
LOG.debug(recs);
|
||||||
MetricsRecord r = recs.get(0);
|
MetricsRecord r = recs.get(0);
|
||||||
|
@ -430,6 +448,20 @@ public class TestMetricsSystemImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Metrics(context="test")
|
||||||
|
private static class TestSource2 {
|
||||||
|
@Metric("C1 desc") MutableCounterLong c1;
|
||||||
|
@Metric("XXX desc") MutableCounterLong xxx;
|
||||||
|
@Metric("G1 desc") MutableGaugeLong g1;
|
||||||
|
@Metric("YYY desc") MutableGaugeLong yyy;
|
||||||
|
@Metric MutableRate s1;
|
||||||
|
final MetricsRegistry registry;
|
||||||
|
|
||||||
|
TestSource2(String recName) {
|
||||||
|
registry = new MetricsRegistry(recName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static String getPluginUrlsAsString() {
|
private static String getPluginUrlsAsString() {
|
||||||
return "file:metrics2-test-plugin.jar";
|
return "file:metrics2-test-plugin.jar";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue