use of org.apache.helix.integration.manager.MockParticipantManager in project helix by apache.
the class TestRoutingTableProviderFromCurrentStates method beforeClass.
@BeforeClass
public void beforeClass() throws Exception {
String namespace = "/" + CLUSTER_NAME;
_participants = new MockParticipantManager[NUM_NODES];
if (_gZkClient.exists(namespace)) {
_gZkClient.deleteRecursively(namespace);
}
_setupTool = new ClusterSetup(ZK_ADDR);
_setupTool.addCluster(CLUSTER_NAME, true);
_participants = new MockParticipantManager[NUM_NODES];
for (int i = 0; i < NUM_NODES; i++) {
String storageNodeName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
_setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
}
for (int i = 0; i < NUM_NODES; i++) {
String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
_participants[i] = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instanceName);
_participants[i].syncStart();
}
_manager = HelixManagerFactory.getZKHelixManager(CLUSTER_NAME, "Admin", InstanceType.ADMINISTRATOR, ZK_ADDR);
_manager.connect();
String controllerName = CONTROLLER_PREFIX + "_0";
_controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
_controller.syncStart();
ConfigAccessor _configAccessor = _manager.getConfigAccessor();
ClusterConfig clusterConfig = _configAccessor.getClusterConfig(CLUSTER_NAME);
clusterConfig.enableTargetExternalView(true);
_configAccessor.setClusterConfig(CLUSTER_NAME, clusterConfig);
}
use of org.apache.helix.integration.manager.MockParticipantManager in project helix by apache.
the class TestRoutingTableProviderFromTargetEV method beforeClass.
@BeforeClass
public void beforeClass() throws Exception {
String namespace = "/" + CLUSTER_NAME;
_participants = new MockParticipantManager[NUM_NODES];
if (_gZkClient.exists(namespace)) {
_gZkClient.deleteRecursively(namespace);
}
_setupTool = new ClusterSetup(ZK_ADDR);
_setupTool.addCluster(CLUSTER_NAME, true);
_participants = new MockParticipantManager[NUM_NODES];
for (int i = 0; i < NUM_NODES; i++) {
String storageNodeName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
_setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
}
_setupTool.addResourceToCluster(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB, NUM_PARTITIONS, MASTER_SLAVE_STATE_MODEL, IdealState.RebalanceMode.FULL_AUTO.name());
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB, NUM_REPLICAS);
for (int i = 0; i < NUM_NODES; i++) {
String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
_participants[i] = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instanceName);
// add a delayed state model
StateMachineEngine stateMachine = _participants[i].getStateMachineEngine();
MockDelayMSStateModelFactory delayFactory = new MockDelayMSStateModelFactory().setDelay(-300000L);
stateMachine.registerStateModelFactory(MASTER_SLAVE_STATE_MODEL, delayFactory);
_participants[i].syncStart();
}
_manager = HelixManagerFactory.getZKHelixManager(CLUSTER_NAME, "Admin", InstanceType.ADMINISTRATOR, ZK_ADDR);
_manager.connect();
String controllerName = CONTROLLER_PREFIX + "_0";
_controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
_controller.syncStart();
_configAccessor = new ConfigAccessor(_gZkClient);
}
use of org.apache.helix.integration.manager.MockParticipantManager in project helix by apache.
the class TestRoutingTableSnapshot method beforeClass.
@BeforeClass
public void beforeClass() throws Exception {
String namespace = "/" + CLUSTER_NAME;
_participants = new MockParticipantManager[NUM_NODES];
if (_gZkClient.exists(namespace)) {
_gZkClient.deleteRecursively(namespace);
}
_setupTool = new ClusterSetup(ZK_ADDR);
_setupTool.addCluster(CLUSTER_NAME, true);
_participants = new MockParticipantManager[NUM_NODES];
for (int i = 0; i < NUM_NODES; i++) {
String storageNodeName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
_setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
}
for (int i = 0; i < NUM_NODES; i++) {
String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
_participants[i] = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instanceName);
_participants[i].syncStart();
}
_manager = HelixManagerFactory.getZKHelixManager(CLUSTER_NAME, "Admin", InstanceType.ADMINISTRATOR, ZK_ADDR);
_manager.connect();
String controllerName = CONTROLLER_PREFIX + "_0";
_controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
_controller.syncStart();
}
use of org.apache.helix.integration.manager.MockParticipantManager in project helix by apache.
the class TestClusterMaintenanceMode method testMaintenanceModeAddNewInstance.
@Test
public void testMaintenanceModeAddNewInstance() throws InterruptedException {
_gSetupTool.getClusterManagementTool().enableMaintenanceMode(CLUSTER_NAME, true, "Test");
Thread.sleep(2000);
ExternalView prevExternalView = _gSetupTool.getClusterManagementTool().getResourceExternalView(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB);
String instanceName = PARTICIPANT_PREFIX + "_" + (_startPort + 10);
_setupTool.addInstanceToCluster(CLUSTER_NAME, instanceName);
MockParticipantManager newInstance = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instanceName);
newInstance.syncStart();
_gSetupTool.getClusterManagementTool().rebalance(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB, 3);
Thread.sleep(3000);
ExternalView newExternalView = _gSetupTool.getClusterManagementTool().getResourceExternalView(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB);
Assert.assertEquals(prevExternalView.getRecord().getMapFields(), newExternalView.getRecord().getMapFields());
}
use of org.apache.helix.integration.manager.MockParticipantManager in project helix by apache.
the class TestClusterMaintenanceMode method testMaintenanceModeInstanceBack.
@Test(dependsOnMethods = "testMaintenanceModeInstanceDown")
public void testMaintenanceModeInstanceBack() throws InterruptedException {
_participants[0] = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, _participants[0].getInstanceName());
_participants[0].syncStart();
Thread.sleep(2000);
ExternalView externalView = _gSetupTool.getClusterManagementTool().getResourceExternalView(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB);
for (Map<String, String> stateMap : externalView.getRecord().getMapFields().values()) {
if (stateMap.containsKey(_participants[0].getInstanceName())) {
Assert.assertTrue(stateMap.get(_participants[0].getInstanceName()).equals("SLAVE"));
}
}
}
Aggregations