use of com.codahale.metrics.jmx.DefaultObjectNameFactory 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.DefaultObjectNameFactory 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.DefaultObjectNameFactory 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