use of com.codahale.metrics.jmx.JmxReporter in project wikidata-query-rdf by wikimedia.
the class StreamingUpdate method main.
public static void main(String[] args) {
log.info("Starting StreamingUpdater");
StreamingUpdateOptions options = OptionsUtils.handleOptions(StreamingUpdateOptions.class, args);
MetricRegistry metrics = new MetricRegistry();
JmxReporter reporter = JmxReporter.forRegistry(metrics).inDomain(options.metricDomain()).build();
StreamingUpdaterConsumer updater = build(options, metrics);
Thread streamingUpdaterThread = Thread.currentThread();
streamingUpdaterThread.setUncaughtExceptionHandler((t, e) -> log.error("Uncaught exception in the updater thread: ", e));
addShutdownHook(updater, streamingUpdaterThread, reporter);
reporter.start();
updater.run();
}
use of com.codahale.metrics.jmx.JmxReporter in project wikidata-query-rdf by wikimedia.
the class WikibaseContextListener method createMetricRegistry.
private MetricRegistry createMetricRegistry() {
MetricRegistry registry = new MetricRegistry();
JmxReporter jmxReporter = JmxReporter.forRegistry(registry).inDomain(METRICS_DOMAIN).build();
jmxReporter.start();
shutdownHooks.add(jmxReporter::stop);
return registry;
}
use of com.codahale.metrics.jmx.JmxReporter in project ambry by linkedin.
the class VcrServerTest method testVCRServerWithReporterFactory.
/**
* Bring up the VCR server and then shut it down with {@link StaticVcrClusterParticipant} and a custom {@link JmxReporter}
* factory.
* @throws Exception
*/
@Test
public void testVCRServerWithReporterFactory() throws Exception {
VerifiableProperties verifiableProperties = getStaticClusterVcrProps();
ObjectNameFactory spyObjectNameFactory = spy(new DefaultObjectNameFactory());
Function<MetricRegistry, JmxReporter> reporterFactory = reporter -> JmxReporter.forRegistry(reporter).createsObjectNamesWith(spyObjectNameFactory).build();
VcrServer vcrServer = new VcrServer(verifiableProperties, mockClusterAgentsFactory, notificationSystem, reporterFactory);
vcrServer.startup();
// check that the custom ObjectNameFactory specified in reporterFactory was used.
verify(spyObjectNameFactory, atLeastOnce()).createName(anyString(), anyString(), anyString());
vcrServer.shutdown();
}
use of com.codahale.metrics.jmx.JmxReporter in project ambry by linkedin.
the class RestServerTest method startShutdownTestWithReporterFactory.
/**
* Tests {@link RestServer#start()} and {@link RestServer#shutdown()} with a custom {@link JmxReporter} factory.
* @throws Exception
*/
@Test
public void startShutdownTestWithReporterFactory() throws Exception {
Properties properties = new Properties();
VerifiableProperties verifiableProperties = getVProps(properties);
ClusterMap clusterMap = new MockClusterMap();
NotificationSystem notificationSystem = new LoggingNotificationSystem();
ObjectNameFactory spyObjectNameFactory = spy(new DefaultObjectNameFactory());
Function<MetricRegistry, JmxReporter> reporterFactory = reporter -> JmxReporter.forRegistry(reporter).createsObjectNamesWith(spyObjectNameFactory).build();
RestServer server = new RestServer(verifiableProperties, clusterMap, notificationSystem, SSL_FACTORY, Collections.emptyList(), reporterFactory);
server.start();
// check that the custom ObjectNameFactory specified in reporterFactory was used.
verify(spyObjectNameFactory, atLeastOnce()).createName(anyString(), anyString(), anyString());
server.shutdown();
server.awaitShutdown();
}
use of com.codahale.metrics.jmx.JmxReporter in project ambry by linkedin.
the class AmbryServerTest method testAmbryServerWithReporterFactory.
/**
* Test starting and shutting down the server with a custom {@link JmxReporter} factory.
* @throws Exception
*/
@Test
public void testAmbryServerWithReporterFactory() throws Exception {
ClusterAgentsFactory clusterAgentsFactory = new MockClusterAgentsFactory(false, false, 1, 1, 1);
ObjectNameFactory spyObjectNameFactory = spy(new DefaultObjectNameFactory());
Function<MetricRegistry, JmxReporter> reporterFactory = reporter -> JmxReporter.forRegistry(reporter).createsObjectNamesWith(spyObjectNameFactory).build();
DataNodeId dataNodeId = clusterAgentsFactory.getClusterMap().getDataNodeIds().get(0);
Properties props = new Properties();
props.setProperty("host.name", dataNodeId.getHostname());
props.setProperty("port", Integer.toString(dataNodeId.getPort()));
props.setProperty("clustermap.cluster.name", "test");
props.setProperty("clustermap.datacenter.name", "DC1");
props.setProperty("clustermap.host.name", dataNodeId.getHostname());
AmbryServer ambryServer = new AmbryServer(new VerifiableProperties(props), clusterAgentsFactory, null, new LoggingNotificationSystem(), SystemTime.getInstance(), reporterFactory);
ambryServer.startup();
verify(spyObjectNameFactory, atLeastOnce()).createName(anyString(), anyString(), anyString());
ambryServer.shutdown();
}
Aggregations