/** Shutdown the sub components. */ public synchronized void shutdown() { if (started) { LOGGER.info("Shutting down"); started = false; List<AbstractBaleenComponent> components = Arrays.asList(pipelineManager, jobManager, webApi, logging); for (AbstractBaleenComponent component : components) { if (component != null) { try { component.stop(); } catch (BaleenException e) { LOGGER.error("Failed to stop " + component.getClass().getSimpleName(), e); } } } MetricsFactory metrics = MetricsFactory.getInstance(); if (metrics != null) { metrics.stop(); } LOGGER.info("Shutdown complete"); } }
/** Shutdown the sub components. */ public synchronized void shutdown() { if (started) { LOGGER.info("Shutting down"); started = false; List<AbstractBaleenComponent> components = Arrays.asList(pipelineManager, jobManager, webApi, logging); for (AbstractBaleenComponent component : components) { if (component != null) { try { component.stop(); } catch (BaleenException e) { LOGGER.error("Failed to stop " + component.getClass().getSimpleName(), e); } } } MetricsFactory metrics = MetricsFactory.getInstance(); if (metrics != null) { metrics.stop(); } LOGGER.info("Shutdown complete"); } }
LOGGER.debug("Configuring metrics"); stop(); reporters.clear();
LOGGER.debug("Configuring metrics"); stop(); reporters.clear();
@Test public void testComponents() throws BaleenException, IOException { metrics.configure(new YamlConfiguration()); metrics.start(); metrics.getCounter(MetricsFactoryTest.class, "removeC"); metrics.stop(); assertTrue(metrics.getRegistry().getMetrics().isEmpty()); }
@Test public void testConfiguration() throws Exception { YamlConfiguration configuration = new YamlConfiguration(MetricsFactoryTest.class, "reporters.yaml"); metrics.configure(configuration); metrics.start(); try { metrics.getCounter(MetricsFactoryTest.class, "testConfiguration").inc(); metrics.getCounter(MetricsFactoryTest.class, "testConfiguration").inc(); MetricsFactory.getMetrics("test", MetricsFactoryTest.class) .getCounter("testConfigurationMetric") .inc(); metrics.report(); Thread.sleep(1000); } finally { metrics.stop(); } // Delete the directory of CSV tests TestingUtils.deleteDirectory("test_csvmetrics"); } }