@Test(expected=MetricsException.class) public void testRegisterDupError() { MetricsSystem ms = new MetricsSystemImpl("test"); TestSource ts = new TestSource("ts"); ms.register(ts); ms.register(ts); }
@Override public synchronized <T> T register(String name, String desc, T source) { MetricsSourceBuilder sb = MetricsAnnotations.newSourceBuilder(source); final MetricsSource s = sb.build(); MetricsInfo si = sb.info(); String name2 = name == null ? si.name() : name; final String finalDesc = desc == null ? si.description() : desc; final String finalName = DefaultMetricsSystem.sourceName(name2, !monitoring); allSources.put(finalName, s); LOG.debug(finalName +", "+ finalDesc); if (monitoring) { registerSource(finalName, finalDesc, s); } register(finalName, new AbstractCallback() { @Override public void postStart() { registerSource(finalName, finalDesc, s); } }); return source; }
MetricsSystemImpl extends MetricsSystem implements MetricsSource { @Override public synchronized <T> T register(String name, String desc, T source) { MetricsSourceBuilder sb = MetricsAnnotations.newSourceBuilder(source); final MetricsSource s = sb.build(); MetricsInfo si = sb.info(); String name2 = name == null ? si.name() : name; final String finalDesc = desc == null ? si.description() : desc; final String finalName = DefaultMetricsSystem.sourceName(name2, !monitoring); allSources.put(finalName, s); LOG.debug(finalName +", "+ finalDesc); if (monitoring) { registerSource(finalName, finalDesc, s); } register(finalName, new AbstractCallback() { @Override public void postStart() { registerSource(finalName, finalDesc, s); } }); return source; } }
MetricsSystemImpl extends MetricsSystem implements MetricsSource { @Override public synchronized <T> T register(String name, String desc, T source) { MetricsSourceBuilder sb = MetricsAnnotations.newSourceBuilder(source); final MetricsSource s = sb.build(); MetricsInfo si = sb.info(); String name2 = name == null ? si.name() : name; final String finalDesc = desc == null ? si.description() : desc; final String finalName = DefaultMetricsSystem.sourceName(name2, !monitoring); allSources.put(finalName, s); LOG.debug(finalName +", "+ finalDesc); if (monitoring) { registerSource(finalName, finalDesc, s); } register(finalName, new AbstractCallback() { @Override public void postStart() { registerSource(finalName, finalDesc, s); } }); return source; } MetricsSystemImpl(String prefix);  MetricsSystemImpl(); }
MetricsSystemImpl extends MetricsSystem implements MetricsSource { @Override public synchronized <T> T register(String name, String desc, T source) { MetricsSourceBuilder sb = MetricsAnnotations.newSourceBuilder(source); final MetricsSource s = sb.build(); MetricsInfo si = sb.info(); String name2 = name == null ? si.name() : name; final String finalDesc = desc == null ? si.description() : desc; final String finalName = DefaultMetricsSystem.sourceName(name2, !monitoring); allSources.put(finalName, s); LOG.debug(finalName +", "+ finalDesc); if (monitoring) { registerSource(finalName, finalDesc, s); } register(finalName, new AbstractCallback() { @Override public void postStart() { registerSource(finalName, finalDesc, s); } }); return source; } MetricsSystemImpl(String prefix);  MetricsSystemImpl(); @Override synchronized MetricsSystem init(String prefix); @Override synchronized void start(); @Override synchronized void stop(); @Override synchronized T register(String name, String desc, T source); @Override synchronized void unregisterSource(String name); @Override synchronized T register(final String name, final String description, final T sink); @Override synchronized void register(final Callback callback); @Override synchronized void startMetricsMBeans(); @Override synchronized void stopMetricsMBeans(); @Override synchronized String currentConfig(); @Override void publishMetricsNow(); @Override synchronized void getMetrics(MetricsCollector builder, boolean all); @Override synchronized boolean shutdown(); MetricsSource getSource(String name); }
MetricsSystemImpl extends MetricsSystem implements MetricsSource { @Override public synchronized <T> T register(String name, String desc, T source) { MetricsSourceBuilder sb = MetricsAnnotations.newSourceBuilder(source); final MetricsSource s = sb.build(); MetricsInfo si = sb.info(); String name2 = name == null ? si.name() : name; final String finalDesc = desc == null ? si.description() : desc; final String finalName = DefaultMetricsSystem.sourceName(name2, !monitoring); allSources.put(finalName, s); LOG.debug(finalName +", "+ finalDesc); if (monitoring) { registerSource(finalName, finalDesc, s); } register(finalName, new AbstractCallback() { @Override public void postStart() { registerSource(finalName, finalDesc, s); } }); return source; } MetricsSystemImpl(String prefix);  MetricsSystemImpl(); @Override synchronized MetricsSystem init(String prefix); @Override synchronized void start(); @Override synchronized void stop(); @Override synchronized T register(String name, String desc, T source); @Override synchronized void unregisterSource(String name); @Override synchronized T register(final String name, final String description, final T sink); @Override synchronized void register(final Callback callback); @Override synchronized void startMetricsMBeans(); @Override synchronized void stopMetricsMBeans(); @Override synchronized String currentConfig(); @Override void publishMetricsNow(); @Override synchronized void getMetrics(MetricsCollector builder, boolean all); @Override synchronized boolean shutdown(); MetricsSource getSource(String name);  }