/** * Convenience method to initialize the metrics system * @param prefix for the metrics system configuration * @return the metrics system instance */ public static MetricsSystem initialize(String prefix) { return INSTANCE.impl.get().init(prefix); }
MetricsSystem init(String prefix) { return impl.get().init(prefix); }
public static MetricsSystem initialize() { // if the jars aren't on the classpath, then we don't start the metrics system if (manager == null) { LOG.warn("Phoenix metrics could not be initialized - no MetricsManager found!"); return null; } // only initialize the metrics system once synchronized (Metrics.class) { if (!initialized) { LOG.info("Initializing metrics system: " + Metrics.METRICS_SYSTEM_NAME); manager.init(Metrics.METRICS_SYSTEM_NAME); initialized = true; } } return manager; }
MetricsSystem init(String prefix) { return impl.get().init(prefix); }
MetricsSystem init(String prefix) { return impl.get().init(prefix); }
MetricsSystem init(String prefix) { return impl.get().init(prefix); }
MetricsSystem init(String prefix) { return impl.get().init(prefix); }
public static MetricsSystem initialize() { // if the jars aren't on the classpath, then we don't start the metrics system if (manager == null) { LOG.warn("Phoenix metrics could not be initialized - no MetricsManager found!"); return null; } // only initialize the metrics system once synchronized (Metrics.class) { if (!initialized) { LOG.info("Initializing metrics system: " + Metrics.METRICS_SYSTEM_NAME); manager.init(Metrics.METRICS_SYSTEM_NAME); initialized = true; } } return manager; }
public static MetricsSystem initialize() { // if the jars aren't on the classpath, then we don't start the metrics system if (manager == null) { LOG.warn("Phoenix metrics could not be initialized - no MetricsManager found!"); return null; } // only initialize the metrics system once synchronized (Metrics.class) { if (!initialized) { LOG.info("Initializing metrics system: " + Metrics.METRICS_SYSTEM_NAME); manager.init(Metrics.METRICS_SYSTEM_NAME); initialized = true; } } return manager; }
@VisibleForTesting public MetricsSystem getMetricsSystem() { synchronized (metricsSystemLock) { if (metricsSystem == null) { metricsSystem = new MetricsSystemImpl(); metricsSystem.init(METRICS_SYSTEM_NAME); } } return metricsSystem; }
@Test public void testRegisterSourceJmxCacheTTL() { MetricsSystem ms = new MetricsSystemImpl(); ms.init("TestMetricsSystem"); TestSource ts = new TestSource("ts"); ms.register(ts); MetricsSourceAdapter sa = ((MetricsSystemImpl) ms) .getSourceAdapter("TestSource"); assertEquals(MetricsConfig.PERIOD_DEFAULT * 1000 + 1, sa.getJmxCacheTTL()); ms.shutdown(); }
@Test public void testRegisterSourceJmxCacheTTL() { MetricsSystem ms = new MetricsSystemImpl(); ms.init("TestMetricsSystem"); TestSource ts = new TestSource("ts"); ms.register(ts); MetricsSourceAdapter sa = ((MetricsSystemImpl) ms) .getSourceAdapter("TestSource"); assertEquals(MetricsConfig.PERIOD_DEFAULT * 1000 + 1, sa.getJmxCacheTTL()); 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(); }
@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(); }