Search in sources :

Example 1 with MockClusterAgentsFactory

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

the class HelixVcrClusterParticipantTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    mockClusterAgentsFactory = new MockClusterAgentsFactory(false, true, 1, 1, NUM_PARTITIONS);
    mockClusterMap = mockClusterAgentsFactory.getClusterMap();
    zkInfo = new TestUtils.ZkInfo(TestUtils.getTempDir("helixVcr"), "DC1", (byte) 1, ZK_SERVER_PORT, true);
    helixControllerManager = VcrTestUtil.populateZkInfoAndStartController(ZK_CONNECT_STRING, VCR_CLUSTER_NAME, mockClusterMap);
}
Also used : TestUtils(com.github.ambry.utils.TestUtils) MockClusterAgentsFactory(com.github.ambry.clustermap.MockClusterAgentsFactory) BeforeClass(org.junit.BeforeClass)

Example 2 with MockClusterAgentsFactory

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

the class VcrServerTest method setup.

@BeforeClass
public static void setup() throws Exception {
    mockClusterAgentsFactory = new MockClusterAgentsFactory(false, true, 1, 1, 2);
    mockClusterMap = mockClusterAgentsFactory.getClusterMap();
    notificationSystem = mock(NotificationSystem.class);
}
Also used : MockClusterAgentsFactory(com.github.ambry.clustermap.MockClusterAgentsFactory) NotificationSystem(com.github.ambry.notification.NotificationSystem) BeforeClass(org.junit.BeforeClass)

Example 3 with MockClusterAgentsFactory

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

the class CloudAndStoreReplicationTest method setup.

/**
 * Create a cluster with one vcr node and two ambry server data nodes.
 * @throws Exception on {@link Exception}
 */
@Before
public void setup() throws Exception {
    String vcrMountPath = ClusterMapSnapshotConstants.CLOUD_REPLICA_MOUNT + "/1";
    recoveryProperties = new Properties();
    recoveryProperties.setProperty("replication.metadata.request.version", "2");
    recoveryProperties.setProperty("replication.enabled.with.vcr.cluster", "true");
    recoveryProperties.setProperty("clustermap.vcr.datacenter.name", cloudDc);
    if (!vcrRecoveryPartitionConfig.isEmpty()) {
        recoveryProperties.setProperty("vcr.recovery.partitions", vcrRecoveryPartitionConfig);
    }
    TestSSLUtils.addHttp2Properties(recoveryProperties, SSLFactory.Mode.SERVER, true);
    // create vcr node
    List<Port> vcrPortList = Arrays.asList(new Port(12310, PortType.PLAINTEXT), new Port(12410, PortType.SSL));
    MockDataNodeId vcrNode = new MockDataNodeId("localhost", vcrPortList, Collections.singletonList(vcrMountPath), cloudDc);
    // create ambry server recovery cluster
    MockClusterMap serverClusterMap = new MockClusterMap(false, true, 2, 1, 1, true, false, null);
    recoveryCluster = new MockCluster(serverClusterMap, Collections.singletonList(vcrNode), recoveryProperties);
    partitionId = recoveryCluster.getClusterMap().getWritablePartitionIds(null).get(0);
    allRecoveryNodes = serverClusterMap.getDataNodes();
    // record ambry server node which will get partition leadership notification.
    partitionLeaderRecoveryNode = allRecoveryNodes.get(0);
    MockClusterAgentsFactory leaderMockClusterAgentsFactory = new MockClusterAgentsFactory(serverClusterMap, serverClusterMap.getAllPartitionIds(null).stream().map(PartitionId::toPathString).collect(Collectors.toList()));
    // Start Helix Controller and ZK Server.
    if (!zkInfo.isZkServerStarted()) {
        zkInfo.startZkServer();
    }
    helixControllerManager = VcrTestUtil.populateZkInfoAndStartController(zkConnectString, vcrClusterName, recoveryCluster.getClusterMap());
    Properties vcrProperties = VcrTestUtil.createVcrProperties(vcrNode.getDatacenterName(), vcrClusterName, zkConnectString, 12310, 12410, 12510, null);
    vcrProperties.putAll(recoveryProperties);
    MockNotificationSystem notificationSystem = new MockNotificationSystem(recoveryCluster.getClusterMap());
    // Create blobs and data for upload to vcr.
    int blobCount = 10;
    cloudBlobIds = ServerTestUtil.createBlobIds(blobCount, recoveryCluster.getClusterMap(), accountId, containerId, partitionId);
    serverBlobIds = ServerTestUtil.createBlobIds(blobCount, recoveryCluster.getClusterMap(), accountId, containerId, partitionId);
    // Create cloud destination and start vcr server.
    latchBasedInMemoryCloudDestination = new LatchBasedInMemoryCloudDestination(cloudBlobIds, recoveryCluster.getClusterMap());
    CloudDestinationFactory cloudDestinationFactory = new LatchBasedInMemoryCloudDestinationFactory(latchBasedInMemoryCloudDestination);
    vcrServer = VcrTestUtil.createVcrServer(new VerifiableProperties(vcrProperties), recoveryCluster.getClusterAgentsFactory(), notificationSystem, cloudDestinationFactory);
    vcrServer.startup();
    // initialize and start ambry servers
    for (MockDataNodeId serverNode : allRecoveryNodes) {
        AmbryServer server = recoveryCluster.initializeServer(serverNode, recoveryProperties, false, notificationSystem, SystemTime.getInstance(), serverNode.equals(partitionLeaderRecoveryNode) ? leaderMockClusterAgentsFactory : null);
        recoveryCluster.addServer(server);
    }
    recoveryCluster.startServers();
}
Also used : VerifiableProperties(com.github.ambry.config.VerifiableProperties) Port(com.github.ambry.network.Port) CloudDestinationFactory(com.github.ambry.cloud.CloudDestinationFactory) LatchBasedInMemoryCloudDestinationFactory(com.github.ambry.cloud.LatchBasedInMemoryCloudDestinationFactory) BlobProperties(com.github.ambry.messageformat.BlobProperties) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) PartitionId(com.github.ambry.clustermap.PartitionId) LatchBasedInMemoryCloudDestination(com.github.ambry.cloud.LatchBasedInMemoryCloudDestination) MockClusterAgentsFactory(com.github.ambry.clustermap.MockClusterAgentsFactory) LatchBasedInMemoryCloudDestinationFactory(com.github.ambry.cloud.LatchBasedInMemoryCloudDestinationFactory) MockDataNodeId(com.github.ambry.clustermap.MockDataNodeId) MockClusterMap(com.github.ambry.clustermap.MockClusterMap) Before(org.junit.Before)

Example 4 with MockClusterAgentsFactory

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

the class StaticVcrClusterParticipantTest method setup.

@Before
public void setup() throws Exception {
    mockClusterAgentsFactory = new MockClusterAgentsFactory(false, true, 1, 1, 2);
    mockClusterMap = mockClusterAgentsFactory.getClusterMap();
}
Also used : MockClusterAgentsFactory(com.github.ambry.clustermap.MockClusterAgentsFactory) Before(org.junit.Before)

Example 5 with MockClusterAgentsFactory

use of com.github.ambry.clustermap.MockClusterAgentsFactory 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();
}
Also used : DefaultObjectNameFactory(com.codahale.metrics.jmx.DefaultObjectNameFactory) AfterClass(org.junit.AfterClass) MetricRegistry(com.codahale.metrics.MetricRegistry) Properties(java.util.Properties) SSLFactory(com.github.ambry.commons.SSLFactory) BeforeClass(org.junit.BeforeClass) VerifiableProperties(com.github.ambry.config.VerifiableProperties) TestSSLUtils(com.github.ambry.commons.TestSSLUtils) ObjectNameFactory(com.codahale.metrics.jmx.ObjectNameFactory) IOException(java.io.IOException) Test(org.junit.Test) Function(java.util.function.Function) File(java.io.File) CloudConfig(com.github.ambry.config.CloudConfig) JmxReporter(com.codahale.metrics.jmx.JmxReporter) Mockito(org.mockito.Mockito) TestUtils(com.github.ambry.utils.TestUtils) HelixControllerManager(com.github.ambry.utils.HelixControllerManager) MockClusterAgentsFactory(com.github.ambry.clustermap.MockClusterAgentsFactory) Assert(org.junit.Assert) Collections(java.util.Collections) MockClusterMap(com.github.ambry.clustermap.MockClusterMap) NotificationSystem(com.github.ambry.notification.NotificationSystem) VerifiableProperties(com.github.ambry.config.VerifiableProperties) DefaultObjectNameFactory(com.codahale.metrics.jmx.DefaultObjectNameFactory) ObjectNameFactory(com.codahale.metrics.jmx.ObjectNameFactory) MetricRegistry(com.codahale.metrics.MetricRegistry) DefaultObjectNameFactory(com.codahale.metrics.jmx.DefaultObjectNameFactory) JmxReporter(com.codahale.metrics.jmx.JmxReporter) 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