Search in sources :

Example 6 with MockClusterAgentsFactory

use of com.github.ambry.clustermap.MockClusterAgentsFactory in project ambry by linkedin.

the class ServerHardDeleteTest method initialize.

@Before
public void initialize() throws Exception {
    mockClusterAgentsFactory = new MockClusterAgentsFactory(false, true, 1, 1, 1);
    mockClusterMap = mockClusterAgentsFactory.getClusterMap();
    notificationSystem = new MockNotificationSystem(mockClusterMap);
    time = new MockTime(SystemTime.getInstance().milliseconds());
    Properties props = new Properties();
    props.setProperty("host.name", mockClusterMap.getDataNodes().get(0).getHostname());
    props.setProperty("port", Integer.toString(mockClusterMap.getDataNodes().get(0).getPort()));
    props.setProperty("store.data.flush.interval.seconds", "1");
    props.setProperty("store.enable.hard.delete", "true");
    props.setProperty("store.deleted.message.retention.hours", "168");
    props.setProperty("server.handle.undelete.request.enabled", "true");
    props.setProperty("clustermap.cluster.name", "test");
    props.setProperty("clustermap.datacenter.name", "DC1");
    props.setProperty("clustermap.host.name", "localhost");
    props.setProperty("clustermap.default.partition.class", MockClusterMap.DEFAULT_PARTITION_CLASS);
    TestSSLUtils.addHttp2Properties(props, SSLFactory.Mode.SERVER, true);
    VerifiableProperties propverify = new VerifiableProperties(props);
    server = new AmbryServer(propverify, mockClusterAgentsFactory, notificationSystem, time);
    server.startup();
}
Also used : MockClusterAgentsFactory(com.github.ambry.clustermap.MockClusterAgentsFactory) VerifiableProperties(com.github.ambry.config.VerifiableProperties) BlobProperties(com.github.ambry.messageformat.BlobProperties) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) MockTime(com.github.ambry.utils.MockTime) Before(org.junit.Before)

Example 7 with MockClusterAgentsFactory

use of com.github.ambry.clustermap.MockClusterAgentsFactory 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();
}
Also used : DefaultObjectNameFactory(com.codahale.metrics.jmx.DefaultObjectNameFactory) MetricRegistry(com.codahale.metrics.MetricRegistry) Properties(java.util.Properties) ClusterAgentsFactory(com.github.ambry.clustermap.ClusterAgentsFactory) VerifiableProperties(com.github.ambry.config.VerifiableProperties) DataNodeId(com.github.ambry.clustermap.DataNodeId) ObjectNameFactory(com.codahale.metrics.jmx.ObjectNameFactory) Test(org.junit.Test) Function(java.util.function.Function) JmxReporter(com.codahale.metrics.jmx.JmxReporter) Mockito(org.mockito.Mockito) SystemTime(com.github.ambry.utils.SystemTime) LoggingNotificationSystem(com.github.ambry.commons.LoggingNotificationSystem) MockClusterAgentsFactory(com.github.ambry.clustermap.MockClusterAgentsFactory) VerifiableProperties(com.github.ambry.config.VerifiableProperties) DefaultObjectNameFactory(com.codahale.metrics.jmx.DefaultObjectNameFactory) ObjectNameFactory(com.codahale.metrics.jmx.ObjectNameFactory) MetricRegistry(com.codahale.metrics.MetricRegistry) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) DefaultObjectNameFactory(com.codahale.metrics.jmx.DefaultObjectNameFactory) JmxReporter(com.codahale.metrics.jmx.JmxReporter) MockClusterAgentsFactory(com.github.ambry.clustermap.MockClusterAgentsFactory) LoggingNotificationSystem(com.github.ambry.commons.LoggingNotificationSystem) ClusterAgentsFactory(com.github.ambry.clustermap.ClusterAgentsFactory) MockClusterAgentsFactory(com.github.ambry.clustermap.MockClusterAgentsFactory) DataNodeId(com.github.ambry.clustermap.DataNodeId) Test(org.junit.Test)

Aggregations

MockClusterAgentsFactory (com.github.ambry.clustermap.MockClusterAgentsFactory)7 VerifiableProperties (com.github.ambry.config.VerifiableProperties)4 Properties (java.util.Properties)4 Before (org.junit.Before)3 BeforeClass (org.junit.BeforeClass)3 MetricRegistry (com.codahale.metrics.MetricRegistry)2 DefaultObjectNameFactory (com.codahale.metrics.jmx.DefaultObjectNameFactory)2 JmxReporter (com.codahale.metrics.jmx.JmxReporter)2 ObjectNameFactory (com.codahale.metrics.jmx.ObjectNameFactory)2 MockClusterMap (com.github.ambry.clustermap.MockClusterMap)2 BlobProperties (com.github.ambry.messageformat.BlobProperties)2 NotificationSystem (com.github.ambry.notification.NotificationSystem)2 TestUtils (com.github.ambry.utils.TestUtils)2 Function (java.util.function.Function)2 Test (org.junit.Test)2 Mockito (org.mockito.Mockito)2 CloudDestinationFactory (com.github.ambry.cloud.CloudDestinationFactory)1 LatchBasedInMemoryCloudDestination (com.github.ambry.cloud.LatchBasedInMemoryCloudDestination)1 LatchBasedInMemoryCloudDestinationFactory (com.github.ambry.cloud.LatchBasedInMemoryCloudDestinationFactory)1 ClusterAgentsFactory (com.github.ambry.clustermap.ClusterAgentsFactory)1