use of org.apache.helix.integration.manager.ClusterControllerManager in project helix by apache.
the class TestDelayedAutoRebalance 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);
// start dummy participants
MockParticipantManager participant = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, storageNodeName);
participant.syncStart();
_participants.add(participant);
}
// start controller
String controllerName = CONTROLLER_PREFIX + "_0";
_controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
_controller.syncStart();
_clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).build();
enablePersistBestPossibleAssignment(_gZkClient, CLUSTER_NAME, true);
}
use of org.apache.helix.integration.manager.ClusterControllerManager in project helix by apache.
the class TestDelayedAutoRebalanceWithRackaware 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);
String zone = "zone-" + i % 3;
_setupTool.getClusterManagementTool().setInstanceZoneId(CLUSTER_NAME, storageNodeName, zone);
// start dummy participants
MockParticipantManager participant = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, storageNodeName);
participant.syncStart();
_participants.add(participant);
}
enableTopologyAwareRebalance(_gZkClient, CLUSTER_NAME, true);
enablePersistBestPossibleAssignment(_gZkClient, CLUSTER_NAME, true);
// start controller
String controllerName = CONTROLLER_PREFIX + "_0";
_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.ClusterControllerManager in project helix by apache.
the class TestSemiAutoRebalance method beforeClass.
@BeforeClass
public void beforeClass() throws InterruptedException {
System.out.println("START " + getShortClassName() + " at " + new Date(System.currentTimeMillis()));
String namespace = "/" + CLUSTER_NAME;
if (_gZkClient.exists(namespace)) {
_gZkClient.deleteRecursively(namespace);
}
// setup storage cluster
_gSetupTool.addCluster(CLUSTER_NAME, true);
_gSetupTool.addResourceToCluster(CLUSTER_NAME, DB_NAME, PARTITION_NUMBER, STATE_MODEL, IdealState.RebalanceMode.SEMI_AUTO.toString());
_accessor = new ZKHelixDataAccessor(CLUSTER_NAME, _baseAccessor);
_keyBuilder = _accessor.keyBuilder();
List<String> instances = new ArrayList<String>();
for (int i = 0; i < PARTICIPANT_NUMBER; i++) {
String instance = PARTICIPANT_PREFIX + "_" + (PARTICIPANT_START_PORT + i);
_gSetupTool.addInstanceToCluster(CLUSTER_NAME, instance);
instances.add(instance);
}
_gSetupTool.rebalanceStorageCluster(CLUSTER_NAME, DB_NAME, REPLICA_NUMBER);
// 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);
}
// start controller
String controllerName = CONTROLLER_PREFIX + "_0";
_controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
_controller.syncStart();
Thread.sleep(1000);
// verify ideal state and external view
IdealState idealState = _accessor.getProperty(_keyBuilder.idealStates(DB_NAME));
Assert.assertNotNull(idealState);
Assert.assertEquals(idealState.getNumPartitions(), PARTITION_NUMBER);
for (String partition : idealState.getPartitionSet()) {
List<String> preferenceList = idealState.getPreferenceList(partition);
Assert.assertNotNull(preferenceList);
Assert.assertEquals(preferenceList.size(), REPLICA_NUMBER);
}
ExternalView externalView = _accessor.getProperty(_keyBuilder.externalView(DB_NAME));
Assert.assertNotNull(externalView);
Assert.assertEquals(externalView.getPartitionSet().size(), PARTITION_NUMBER);
for (String partition : externalView.getPartitionSet()) {
Map<String, String> stateMap = externalView.getStateMap(partition);
Assert.assertEquals(stateMap.size(), REPLICA_NUMBER);
int masters = 0;
for (String state : stateMap.values()) {
if (state.equals(MasterSlaveSMD.States.MASTER.name())) {
++masters;
}
}
Assert.assertEquals(masters, 1);
}
}
use of org.apache.helix.integration.manager.ClusterControllerManager in project helix by apache.
the class TaskTestBase method beforeClass.
@BeforeClass
public void beforeClass() throws Exception {
super.beforeClass();
// start controller
String controllerName = CONTROLLER_PREFIX + "_0";
_controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
_controller.syncStart();
boolean result = ClusterStateVerifier.verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR, CLUSTER_NAME));
Assert.assertTrue(result);
}
use of org.apache.helix.integration.manager.ClusterControllerManager in project helix by apache.
the class TestAutoIsWithEmptyMap method testAutoIsWithEmptyMap.
@Test
public void testAutoIsWithEmptyMap() throws Exception {
String className = TestHelper.getTestClassName();
String methodName = TestHelper.getTestMethodName();
String clusterName = className + "_" + methodName;
System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
// participant port
TestHelper.setupCluster(// participant port
clusterName, // participant port
ZK_ADDR, // participant port
12918, // participant name prefix
"localhost", // resource name prefix
"TestDB", // resources
1, // partitions per resource
10, // number of nodes
5, // replicas
3, "LeaderStandby", // do not rebalance
false);
// calculate and set custom ideal state
String idealPath = PropertyPathBuilder.idealState(clusterName, "TestDB0");
ZNRecord curIdealState = _gZkClient.readData(idealPath);
List<String> instanceNames = new ArrayList<String>(5);
for (int i = 0; i < 5; i++) {
int port = 12918 + i;
instanceNames.add("localhost_" + port);
}
ZNRecord idealState = DefaultIdealStateCalculator.calculateIdealState(instanceNames, 10, 2, "TestDB0", "LEADER", "STANDBY");
// System.out.println(idealState);
// curIdealState.setSimpleField(IdealState.IdealStateProperty.IDEAL_STATE_MODE.toString(),
// "CUSTOMIZED");
curIdealState.setSimpleField(IdealState.IdealStateProperty.REPLICAS.toString(), "3");
curIdealState.setListFields(idealState.getListFields());
_gZkClient.writeData(idealPath, curIdealState);
// start controller
ClusterControllerManager controller = new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
controller.syncStart();
// start participants
MockParticipantManager[] participants = new MockParticipantManager[5];
for (int i = 0; i < 5; i++) {
String instanceName = "localhost_" + (12918 + i);
participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
participants[i].syncStart();
}
boolean result = ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR, clusterName));
Assert.assertTrue(result);
// clean up
controller.syncStop();
for (int i = 0; i < 5; i++) {
participants[i].syncStop();
}
System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
Aggregations