use of org.apache.helix.integration.manager.MockParticipantManager in project helix by apache.
the class TestRestartParticipant method testRestartParticipant.
@Test()
public void testRestartParticipant() throws Exception {
// Logger.getRootLogger().setLevel(Level.INFO);
System.out.println("START testRestartParticipant at " + new Date(System.currentTimeMillis()));
String clusterName = getShortClassName();
MockParticipantManager[] participants = new MockParticipantManager[5];
// 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, "MasterSlave", // do rebalance
true);
ClusterControllerManager controller = new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
controller.syncStart();
// start participants
for (int i = 0; i < 5; i++) {
String instanceName = "localhost_" + (12918 + i);
if (i == 4) {
participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
participants[i].setTransition(new KillOtherTransition(participants[0]));
} else {
participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
}
participants[i].syncStart();
}
boolean result = ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR, clusterName));
Assert.assertTrue(result);
// restart
Thread.sleep(500);
MockParticipantManager participant = new MockParticipantManager(ZK_ADDR, participants[0].getClusterName(), participants[0].getInstanceName());
System.err.println("Restart " + participant.getInstanceName());
participant.syncStart();
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();
}
participant.syncStop();
System.out.println("START testRestartParticipant at " + new Date(System.currentTimeMillis()));
}
use of org.apache.helix.integration.manager.MockParticipantManager in project helix by apache.
the class TestCrushAutoRebalance method testLackEnoughLiveRacks.
@Test(dependsOnMethods = { "testZoneIsolation", "testZoneIsolationWithInstanceTag" })
public void testLackEnoughLiveRacks() throws Exception {
System.out.println("TestLackEnoughInstances");
enablePersistBestPossibleAssignment(_gZkClient, CLUSTER_NAME, true);
// shutdown participants within one zone
String zone = _nodeToZoneMap.values().iterator().next();
for (int i = 0; i < _participants.size(); i++) {
MockParticipantManager p = _participants.get(i);
if (_nodeToZoneMap.get(p.getInstanceName()).equals(zone)) {
p.syncStop();
}
}
int i = 0;
for (String stateModel : _testModels) {
String db = "Test-DB-CrushRebalanceStrategy-" + i++;
_setupTool.addResourceToCluster(CLUSTER_NAME, db, _PARTITIONS, stateModel, RebalanceMode.FULL_AUTO + "", CrushRebalanceStrategy.class.getName());
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, db, _replica);
_allDBs.add(db);
}
Thread.sleep(300);
HelixClusterVerifier _clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).setResources(_allDBs).build();
Assert.assertTrue(_clusterVerifier.verify());
for (String db : _allDBs) {
IdealState is = _setupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, db);
ExternalView ev = _setupTool.getClusterManagementTool().getResourceExternalView(CLUSTER_NAME, db);
validateZoneAndTagIsolation(is, ev, 2);
}
}
use of org.apache.helix.integration.manager.MockParticipantManager in project helix by apache.
the class TestCrushAutoRebalanceNonRack 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);
ConfigAccessor configAccessor = new ConfigAccessor(_gZkClient);
ClusterConfig clusterConfig = configAccessor.getClusterConfig(CLUSTER_NAME);
clusterConfig.setTopology("/instance");
clusterConfig.setFaultZoneType("instance");
configAccessor.setClusterConfig(CLUSTER_NAME, clusterConfig);
for (int i = 0; i < NUM_NODE; i++) {
String storageNodeName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
_setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
_nodes.add(storageNodeName);
String tag = "tag-" + i % 2;
_setupTool.getClusterManagementTool().addInstanceTag(CLUSTER_NAME, storageNodeName, tag);
_nodeToTagMap.put(storageNodeName, tag);
InstanceConfig instanceConfig = configAccessor.getInstanceConfig(CLUSTER_NAME, storageNodeName);
instanceConfig.setDomain("instance=" + storageNodeName);
configAccessor.setInstanceConfig(CLUSTER_NAME, storageNodeName, instanceConfig);
}
// start dummy participants
for (String node : _nodes) {
MockParticipantManager participant = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, node);
participant.syncStart();
_participants.add(participant);
}
// start controller
String controllerName = CONTROLLER_PREFIX + "_0";
_controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
_controller.syncStart();
enablePersistBestPossibleAssignment(_gZkClient, CLUSTER_NAME, true);
// enableTopologyAwareRebalance(_gZkClient, CLUSTER_NAME, true);
}
use of org.apache.helix.integration.manager.MockParticipantManager in project helix by apache.
the class TestCrushAutoRebalanceNonRack method testLackEnoughInstances.
@Test(dataProvider = "rebalanceStrategies", enabled = true, dependsOnMethods = { "testLackEnoughLiveInstances" })
public void testLackEnoughInstances(String rebalanceStrategyName, String rebalanceStrategyClass) throws Exception {
System.out.println("TestLackEnoughInstances " + rebalanceStrategyName);
enablePersistBestPossibleAssignment(_gZkClient, CLUSTER_NAME, true);
// shutdown participants, keep only two left
for (int i = 2; i < _participants.size(); i++) {
MockParticipantManager p = _participants.get(i);
p.syncStop();
_setupTool.getClusterManagementTool().enableInstance(CLUSTER_NAME, p.getInstanceName(), false);
Thread.sleep(50);
_setupTool.dropInstanceFromCluster(CLUSTER_NAME, p.getInstanceName());
}
int j = 0;
for (String stateModel : _testModels) {
String db = "Test-DB-" + rebalanceStrategyName + "-" + j++;
_setupTool.addResourceToCluster(CLUSTER_NAME, db, _PARTITIONS, stateModel, RebalanceMode.FULL_AUTO + "", rebalanceStrategyClass);
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, db, _replica);
_allDBs.add(db);
}
Thread.sleep(300);
HelixClusterVerifier _clusterVerifier = new StrictMatchExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).setResources(_allDBs).build();
Assert.assertTrue(_clusterVerifier.verify());
for (String db : _allDBs) {
IdealState is = _setupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, db);
ExternalView ev = _setupTool.getClusterManagementTool().getResourceExternalView(CLUSTER_NAME, db);
validateIsolation(is, ev, 2);
}
// recover test environment
ConfigAccessor configAccessor = new ConfigAccessor(_gZkClient);
for (int i = 2; i < _participants.size(); i++) {
String storageNodeName = _participants.get(i).getInstanceName();
_setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
InstanceConfig instanceConfig = configAccessor.getInstanceConfig(CLUSTER_NAME, storageNodeName);
instanceConfig.setDomain("instance=" + storageNodeName);
configAccessor.setInstanceConfig(CLUSTER_NAME, storageNodeName, instanceConfig);
MockParticipantManager participant = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, storageNodeName);
participant.syncStart();
_participants.set(i, participant);
}
}
use of org.apache.helix.integration.manager.MockParticipantManager in project helix by apache.
the class TestCrushAutoRebalanceTopoplogyAwareDisabled method beforeClass.
@BeforeClass
public void beforeClass() throws Exception {
System.out.println("START " + CLASS_NAME + " at " + new Date(System.currentTimeMillis()));
String namespace = "/" + CLUSTER_NAME;
if (ZkIntegrationTestBase._gZkClient.exists(namespace)) {
ZkIntegrationTestBase._gZkClient.deleteRecursively(namespace);
}
_setupTool = new ClusterSetup(ZkIntegrationTestBase._gZkClient);
_setupTool.addCluster(CLUSTER_NAME, true);
for (int i = 0; i < NUM_NODE; i++) {
String storageNodeName = PARTICIPANT_PREFIX + "_" + (TestCrushAutoRebalanceNonRack.START_PORT + i);
_setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
_nodes.add(storageNodeName);
String tag = "tag-" + i % 2;
_setupTool.getClusterManagementTool().addInstanceTag(CLUSTER_NAME, storageNodeName, tag);
_nodeToTagMap.put(storageNodeName, tag);
}
// start dummy participants
for (String node : _nodes) {
MockParticipantManager participant = new MockParticipantManager(ZkIntegrationTestBase.ZK_ADDR, CLUSTER_NAME, node);
participant.syncStart();
_participants.add(participant);
}
// start controller
String controllerName = CONTROLLER_PREFIX + "_0";
_controller = new ClusterControllerManager(ZkIntegrationTestBase.ZK_ADDR, CLUSTER_NAME, controllerName);
_controller.syncStart();
enablePersistBestPossibleAssignment(ZkIntegrationTestBase._gZkClient, CLUSTER_NAME, true);
}
Aggregations