use of org.apache.helix.integration.manager.MockParticipantManager in project helix by apache.
the class TestDelayedAutoRebalance method beforeTest.
@BeforeMethod
public void beforeTest() {
// restart any participant that has been disconnected from last test.
for (int i = 0; i < _participants.size(); i++) {
if (!_participants.get(i).isConnected()) {
_participants.set(i, new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, _participants.get(i).getInstanceName()));
_participants.get(i).syncStart();
}
}
}
use of org.apache.helix.integration.manager.MockParticipantManager in project helix by apache.
the class TestSemiAutoRebalance method testAddParticipant.
@Test
public void testAddParticipant() throws InterruptedException {
String newInstance = PARTICIPANT_PREFIX + "_" + (PARTICIPANT_START_PORT + _participants.size());
_gSetupTool.addInstanceToCluster(CLUSTER_NAME, newInstance);
MockParticipantManager newParticipant = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, newInstance);
newParticipant.syncStart();
Thread.sleep(1000);
List<String> instances = _accessor.getChildNames(_keyBuilder.instanceConfigs());
Assert.assertEquals(instances.size(), _participants.size() + 1);
Assert.assertTrue(instances.contains(newInstance));
List<String> liveInstances = _accessor.getChildNames(_keyBuilder.liveInstances());
Assert.assertEquals(liveInstances.size(), _participants.size() + 1);
Assert.assertTrue(liveInstances.contains(newInstance));
// nothing for new participant
ExternalView externalView = _accessor.getProperty(_keyBuilder.externalView(DB_NAME));
Assert.assertNotNull(externalView);
for (String partition : externalView.getPartitionSet()) {
Map<String, String> stateMap = externalView.getStateMap(partition);
Assert.assertFalse(stateMap.containsKey(newInstance));
}
// clear
newParticipant.syncStop();
_gSetupTool.getClusterManagementTool().enableInstance(CLUSTER_NAME, newInstance, false);
_gSetupTool.dropInstanceFromCluster(CLUSTER_NAME, newInstance);
instances = _accessor.getChildNames(_keyBuilder.instanceConfigs());
Assert.assertEquals(instances.size(), _participants.size());
liveInstances = _accessor.getChildNames(_keyBuilder.liveInstances());
Assert.assertEquals(liveInstances.size(), _participants.size());
}
use of org.apache.helix.integration.manager.MockParticipantManager in project helix by apache.
the class TestZeroReplicaAvoidance method beforeClass.
@BeforeClass
public void beforeClass() throws Exception {
System.out.println("START " + CLASS_NAME + " at " + new Date(System.currentTimeMillis()));
String namespace = "/" + CLUSTER_NAME;
if (_gZkClient.exists(namespace)) {
_gZkClient.deleteRecursively(namespace);
}
_setupTool = new ClusterSetup(_gZkClient);
_setupTool.addCluster(CLUSTER_NAME, true);
for (int i = 0; i < NUM_NODE; i++) {
String storageNodeName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
_setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
MockParticipantManager participant = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, storageNodeName);
participant.setTransition(new DelayedTransition());
_participants.add(participant);
}
// start controller
String controllerName = CONTROLLER_PREFIX + "_0";
ClusterControllerManager controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
controller.syncStart();
_clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).build();
}
use of org.apache.helix.integration.manager.MockParticipantManager in project helix by apache.
the class TestRoutingTableProvider method afterClass.
@AfterClass
public void afterClass() {
// stop participants
for (MockParticipantManager p : _participants) {
p.syncStop();
}
_controller.syncStop();
_spectator.disconnect();
_gSetupTool.deleteCluster(CLUSTER_NAME);
}
use of org.apache.helix.integration.manager.MockParticipantManager in project helix by apache.
the class TestRoutingTableProvider method beforeClass.
@BeforeClass
public void beforeClass() throws Exception {
System.out.println("START " + getShortClassName() + " at " + new Date(System.currentTimeMillis()));
// setup storage cluster
_gSetupTool.addCluster(CLUSTER_NAME, true);
for (int i = 0; i < PARTICIPANT_NUMBER; i++) {
String instance = PARTICIPANT_PREFIX + "_" + (PARTICIPANT_START_PORT + i);
_gSetupTool.addInstanceToCluster(CLUSTER_NAME, instance);
_instances.add(instance);
}
// start dummy participants
for (int i = 0; i < PARTICIPANT_NUMBER; i++) {
MockParticipantManager participant = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, _instances.get(i));
participant.syncStart();
_participants.add(participant);
}
createDBInSemiAuto(_gSetupTool, CLUSTER_NAME, TEST_DB, _instances, STATE_MODEL, PARTITION_NUMBER, REPLICA_NUMBER);
// start controller
String controllerName = CONTROLLER_PREFIX + "_0";
_controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
_controller.syncStart();
// start speculator
_routingTableProvider = new RoutingTableProvider();
_spectator = HelixManagerFactory.getZKHelixManager(CLUSTER_NAME, "spectator", InstanceType.SPECTATOR, ZK_ADDR);
_spectator.connect();
_spectator.addExternalViewChangeListener(_routingTableProvider);
_spectator.addLiveInstanceChangeListener(_routingTableProvider);
_spectator.addInstanceConfigChangeListener(_routingTableProvider);
_routingTableProvider2 = new RoutingTableProvider(_spectator);
_clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkClient(_gZkClient).build();
Assert.assertTrue(_clusterVerifier.verify());
}
Aggregations