Search in sources :

Example 91 with MockParticipantManager

use of org.apache.helix.integration.manager.MockParticipantManager in project helix by apache.

the class TestCrushAutoRebalance method testLackEnoughRacks.

@Test(dependsOnMethods = { "testLackEnoughLiveRacks" })
public void testLackEnoughRacks() 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();
            _setupTool.getClusterManagementTool().enableInstance(CLUSTER_NAME, p.getInstanceName(), false);
            Thread.sleep(50);
            _setupTool.dropInstanceFromCluster(CLUSTER_NAME, p.getInstanceName());
        }
    }
    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);
    }
}
Also used : ExternalView(org.apache.helix.model.ExternalView) HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) BestPossibleExternalViewVerifier(org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier) IdealState(org.apache.helix.model.IdealState) Test(org.testng.annotations.Test)

Example 92 with MockParticipantManager

use of org.apache.helix.integration.manager.MockParticipantManager 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);
}
Also used : ClusterControllerManager(org.apache.helix.integration.manager.ClusterControllerManager) MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) BestPossibleExternalViewVerifier(org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier) ClusterSetup(org.apache.helix.tools.ClusterSetup) Date(java.util.Date) BeforeClass(org.testng.annotations.BeforeClass)

Example 93 with MockParticipantManager

use of org.apache.helix.integration.manager.MockParticipantManager in project helix by apache.

the class TestDelayedAutoRebalance method afterClass.

@AfterClass
public void afterClass() throws Exception {
    /**
     * shutdown order: 1) disconnect the controller 2) disconnect participants
     */
    _controller.syncStop();
    for (MockParticipantManager participant : _participants) {
        participant.syncStop();
    }
    _setupTool.deleteCluster(CLUSTER_NAME);
    System.out.println("END " + CLASS_NAME + " at " + new Date(System.currentTimeMillis()));
}
Also used : MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) Date(java.util.Date) AfterClass(org.testng.annotations.AfterClass)

Example 94 with MockParticipantManager

use of org.apache.helix.integration.manager.MockParticipantManager in project helix by apache.

the class TestDelayedAutoRebalanceWithDisabledInstance 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();
        }
        enableInstance(_participants.get(i).getInstanceName(), true);
    }
}
Also used : MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 95 with MockParticipantManager

use of org.apache.helix.integration.manager.MockParticipantManager 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();
}
Also used : ClusterControllerManager(org.apache.helix.integration.manager.ClusterControllerManager) MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) BestPossibleExternalViewVerifier(org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier) ClusterSetup(org.apache.helix.tools.ClusterSetup) Date(java.util.Date) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

MockParticipantManager (org.apache.helix.integration.manager.MockParticipantManager)167 Test (org.testng.annotations.Test)113 Date (java.util.Date)101 ClusterControllerManager (org.apache.helix.integration.manager.ClusterControllerManager)101 ZKHelixDataAccessor (org.apache.helix.manager.zk.ZKHelixDataAccessor)43 ZNRecord (org.apache.helix.ZNRecord)40 IdealState (org.apache.helix.model.IdealState)35 BestPossAndExtViewZkVerifier (org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier)35 ClusterStateVerifier (org.apache.helix.tools.ClusterStateVerifier)34 HashMap (java.util.HashMap)33 HelixDataAccessor (org.apache.helix.HelixDataAccessor)30 ClusterSetup (org.apache.helix.tools.ClusterSetup)28 BeforeClass (org.testng.annotations.BeforeClass)27 ExternalView (org.apache.helix.model.ExternalView)24 BestPossibleExternalViewVerifier (org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier)20 HelixClusterVerifier (org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier)19 Map (java.util.Map)18 PropertyKey (org.apache.helix.PropertyKey)16 Builder (org.apache.helix.PropertyKey.Builder)15 ClusterDistributedController (org.apache.helix.integration.manager.ClusterDistributedController)15