Search in sources :

Example 61 with ClusterControllerManager

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

the class TestJobTimeoutTaskNotStarted method beforeClass.

@BeforeClass
public void beforeClass() throws Exception {
    _numDbs = 1;
    _numNodes = 1;
    _numParitions = 50;
    _numReplicas = 1;
    _participants = new MockParticipantManager[_numNodes];
    String namespace = "/" + CLUSTER_NAME;
    if (_gZkClient.exists(namespace)) {
        _gZkClient.deleteRecursively(namespace);
    }
    _setupTool = new ClusterSetup(ZK_ADDR);
    _setupTool.addCluster(CLUSTER_NAME, true);
    setupParticipants();
    setupDBs();
    startParticipantsWithStuckTaskStateModelFactory();
    createManagers();
    _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, CONTROLLER_PREFIX);
    _controller.syncStart();
    // Enable cancellation
    ConfigAccessor _configAccessor = new ConfigAccessor(_gZkClient);
    ClusterConfig clusterConfig = _configAccessor.getClusterConfig(CLUSTER_NAME);
    clusterConfig.stateTransitionCancelEnabled(true);
    clusterConfig.setMaxConcurrentTaskPerInstance(_numParitions);
    _configAccessor.setClusterConfig(CLUSTER_NAME, clusterConfig);
    HelixClusterVerifier clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkClient(_gZkClient).build();
    Assert.assertTrue(clusterVerifier.verify(10000));
}
Also used : ClusterControllerManager(org.apache.helix.integration.manager.ClusterControllerManager) HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) ConfigAccessor(org.apache.helix.ConfigAccessor) ClusterSetup(org.apache.helix.tools.ClusterSetup) ClusterConfig(org.apache.helix.model.ClusterConfig) BeforeClass(org.testng.annotations.BeforeClass)

Example 62 with ClusterControllerManager

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

the class TestRebalanceRunningTask method beforeClass.

@BeforeClass
public void beforeClass() throws Exception {
    _participants = new MockParticipantManager[_numNodes];
    _numNodes = 2;
    _numParitions = 2;
    // only Master, no Slave
    _numReplicas = 1;
    _numDbs = 1;
    String namespace = "/" + CLUSTER_NAME;
    if (_gZkClient.exists(namespace)) {
        _gZkClient.deleteRecursively(namespace);
    }
    _setupTool = new ClusterSetup(ZK_ADDR);
    _setupTool.addCluster(CLUSTER_NAME, true);
    setupParticipants();
    setupDBs();
    createManagers();
    _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, CONTROLLER_PREFIX);
    _controller.syncStart();
}
Also used : ClusterControllerManager(org.apache.helix.integration.manager.ClusterControllerManager) ClusterSetup(org.apache.helix.tools.ClusterSetup) BeforeClass(org.testng.annotations.BeforeClass)

Example 63 with ClusterControllerManager

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

the class TestStateTransitionTimeout method testStateTransitionTimeOut.

@Test
public void testStateTransitionTimeOut() throws Exception {
    Map<String, SleepStateModelFactory> factories = new HashMap<String, SleepStateModelFactory>();
    IdealState idealState = _setupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, TEST_DB);
    for (int i = 0; i < NODE_NR; i++) {
        String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
        SleepStateModelFactory factory = new SleepStateModelFactory(1000);
        factories.put(instanceName, factory);
        for (String p : idealState.getPartitionSet()) {
            if (idealState.getPreferenceList(p).get(0).equals(instanceName)) {
                factory.addPartition(p);
            }
        }
        _participants[i] = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instanceName);
        _participants[i].getStateMachineEngine().registerStateModelFactory("MasterSlave", factory);
        _participants[i].syncStart();
    }
    String controllerName = CONTROLLER_PREFIX + "_0";
    _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
    _controller.syncStart();
    boolean result = ClusterStateVerifier.verifyByZkCallback(new MasterNbInExtViewVerifier(ZK_ADDR, CLUSTER_NAME));
    Assert.assertTrue(result);
    HelixDataAccessor accessor = _participants[0].getHelixDataAccessor();
    Builder kb = accessor.keyBuilder();
    ExternalView ev = accessor.getProperty(kb.externalView(TEST_DB));
    for (String p : idealState.getPartitionSet()) {
        String idealMaster = idealState.getPreferenceList(p).get(0);
        Assert.assertTrue(ev.getStateMap(p).get(idealMaster).equals("ERROR"));
        TimeOutStateModel model = factories.get(idealMaster).getStateModel(TEST_DB, p);
        Assert.assertEquals(model._errorCallcount, 1);
        Assert.assertEquals(model._error.getCode(), ErrorCode.TIMEOUT);
    }
}
Also used : ExternalView(org.apache.helix.model.ExternalView) MasterNbInExtViewVerifier(org.apache.helix.tools.ClusterStateVerifier.MasterNbInExtViewVerifier) MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) HashMap(java.util.HashMap) Builder(org.apache.helix.PropertyKey.Builder) IdealState(org.apache.helix.model.IdealState) ClusterControllerManager(org.apache.helix.integration.manager.ClusterControllerManager) HelixDataAccessor(org.apache.helix.HelixDataAccessor) Test(org.testng.annotations.Test)

Example 64 with ClusterControllerManager

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

the class TestStateTransitionTimeoutWithResource method beforeClass.

@Override
@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(ZK_ADDR);
    // setup storage cluster
    _setupTool.addCluster(CLUSTER_NAME, true);
    for (int i = 0; i < NODE_NR; i++) {
        String storageNodeName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
        _setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
    }
    _manager = HelixManagerFactory.getZKHelixManager(CLUSTER_NAME, "Admin", InstanceType.ADMINISTRATOR, ZK_ADDR);
    _manager.connect();
    _configAccessor = new ConfigAccessor(_gZkClient);
    String controllerName = CONTROLLER_PREFIX + "_0";
    _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
    _controller.syncStart();
    boolean result = ClusterStateVerifier.verifyByZkCallback(new MasterNbInExtViewVerifier(ZK_ADDR, CLUSTER_NAME));
    Assert.assertTrue(result);
}
Also used : ClusterControllerManager(org.apache.helix.integration.manager.ClusterControllerManager) MasterNbInExtViewVerifier(org.apache.helix.tools.ClusterStateVerifier.MasterNbInExtViewVerifier) ConfigAccessor(org.apache.helix.ConfigAccessor) ClusterSetup(org.apache.helix.tools.ClusterSetup) Date(java.util.Date) BeforeClass(org.testng.annotations.BeforeClass)

Example 65 with ClusterControllerManager

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

the class TestCrushAutoRebalance 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;
        String tag = "tag-" + i % 2;
        _setupTool.getClusterManagementTool().setInstanceZoneId(CLUSTER_NAME, storageNodeName, zone);
        _setupTool.getClusterManagementTool().addInstanceTag(CLUSTER_NAME, storageNodeName, tag);
        _nodeToZoneMap.put(storageNodeName, zone);
        _nodeToTagMap.put(storageNodeName, tag);
        _nodes.add(storageNodeName);
    }
    // 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);
}
Also used : ClusterControllerManager(org.apache.helix.integration.manager.ClusterControllerManager) MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) ClusterSetup(org.apache.helix.tools.ClusterSetup) Date(java.util.Date) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

ClusterControllerManager (org.apache.helix.integration.manager.ClusterControllerManager)125 MockParticipantManager (org.apache.helix.integration.manager.MockParticipantManager)101 Date (java.util.Date)88 Test (org.testng.annotations.Test)78 ZKHelixDataAccessor (org.apache.helix.manager.zk.ZKHelixDataAccessor)38 BeforeClass (org.testng.annotations.BeforeClass)37 ZNRecord (org.apache.helix.ZNRecord)33 ClusterSetup (org.apache.helix.tools.ClusterSetup)33 ClusterStateVerifier (org.apache.helix.tools.ClusterStateVerifier)30 BestPossAndExtViewZkVerifier (org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier)28 HashMap (java.util.HashMap)26 IdealState (org.apache.helix.model.IdealState)24 HelixDataAccessor (org.apache.helix.HelixDataAccessor)19 PropertyKey (org.apache.helix.PropertyKey)19 Map (java.util.Map)18 HelixClusterVerifier (org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier)17 ZKHelixAdmin (org.apache.helix.manager.zk.ZKHelixAdmin)15 BestPossibleExternalViewVerifier (org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier)15 Set (java.util.Set)14 ConfigAccessor (org.apache.helix.ConfigAccessor)14