use of com.codahale.metrics.jmx.ObjectNameFactory in project cxf by apache.
the class CodahaleMetricsProvider method setupJMXReporter.
public static void setupJMXReporter(Bus b, MetricRegistry reg) {
InstrumentationManager im = b.getExtension(InstrumentationManager.class);
if (im != null) {
JmxReporter reporter = JmxReporter.forRegistry(reg).registerWith(im.getMBeanServer()).inDomain("org.apache.cxf").createsObjectNamesWith(new ObjectNameFactory() {
public ObjectName createName(String type, String domain, String name) {
try {
return new ObjectName(name);
} catch (MalformedObjectNameException e) {
throw new RuntimeException(e);
}
}
}).build();
reporter.start();
}
}
use of com.codahale.metrics.jmx.ObjectNameFactory 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.ObjectNameFactory 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.ObjectNameFactory 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