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);
}
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);
}
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();
}
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();
}
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();
}
Aggregations