Search in sources :

Example 21 with ClusterConfig

use of org.apache.helix.model.ClusterConfig in project helix by apache.

the class TestAlertingRebalancerFailure method testWithDomainId.

@Test(enabled = false)
public void testWithDomainId() throws InterruptedException {
    int replicas = 2;
    ConfigAccessor configAccessor = new ConfigAccessor(_gZkClient);
    // 1. disable all participants except one node, then set domain Id
    for (int i = NODE_NR - 1; i >= 0; i--) {
        if (i < replicas) {
            setDomainId(_participants[i].getInstanceName(), configAccessor);
        } else {
            setInstanceEnable(_participants[i].getInstanceName(), false, configAccessor);
        }
    }
    // enable topology aware
    ClusterConfig clusterConfig = configAccessor.getClusterConfig(CLUSTER_NAME);
    clusterConfig.setTopologyAwareEnabled(true);
    clusterConfig.setTopology("/Rack/Instance");
    clusterConfig.setFaultZoneType("Rack");
    configAccessor.setClusterConfig(CLUSTER_NAME, clusterConfig);
    // Ensure error caused by node config changes has been removed.
    // Error may be recorded unexpectedly when a resource from other tests is not cleaned up.
    accessor.removeProperty(errorNodeKey);
    _setupTool.addResourceToCluster(CLUSTER_NAME, testDb, 5, BuiltInStateModelDefinitions.MasterSlave.name(), RebalanceMode.FULL_AUTO.name(), CrushRebalanceStrategy.class.getName());
    _setupTool.rebalanceStorageCluster(CLUSTER_NAME, testDb, replicas);
    HelixClusterVerifier verifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).setResources(new HashSet<>(Collections.singleton(testDb))).build();
    Assert.assertTrue(verifier.verify());
    // Verify there is no rebalance error logged
    Assert.assertNull(accessor.getProperty(errorNodeKey));
    checkRebalanceFailureGauge(false);
    // 2. enable the rest nodes with no domain Id
    for (int i = replicas; i < NODE_NR; i++) {
        setInstanceEnable(_participants[i].getInstanceName(), true, configAccessor);
    }
    // Verify there is rebalance error logged
    Assert.assertNotNull(pollForError(accessor, errorNodeKey));
    checkRebalanceFailureGauge(true);
    // 3. reset all nodes domain Id to be correct setting
    for (int i = replicas; i < NODE_NR; i++) {
        setDomainId(_participants[i].getInstanceName(), configAccessor);
    }
    _setupTool.rebalanceStorageCluster(CLUSTER_NAME, testDb, replicas);
    Thread.sleep(1000);
    // Verify that rebalance error state is removed
    checkRebalanceFailureGauge(false);
    // clean up
    _setupTool.getClusterManagementTool().dropResource(CLUSTER_NAME, testDb);
    clusterConfig.setTopologyAwareEnabled(false);
}
Also used : HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) BestPossibleExternalViewVerifier(org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier) CrushRebalanceStrategy(org.apache.helix.controller.rebalancer.strategy.CrushRebalanceStrategy) ConfigAccessor(org.apache.helix.ConfigAccessor) ClusterConfig(org.apache.helix.model.ClusterConfig) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 22 with ClusterConfig

use of org.apache.helix.model.ClusterConfig in project helix by apache.

the class TestStateTransitionTimeoutWithResource method testStateTransitionTimeoutByClusterLevel.

@Test
public void testStateTransitionTimeoutByClusterLevel() throws InterruptedException {
    _setupTool.addResourceToCluster(CLUSTER_NAME, TEST_DB + 1, _PARTITIONS, STATE_MODEL);
    _setupTool.getClusterManagementTool().enableResource(CLUSTER_NAME, TEST_DB + 1, false);
    _setupTool.rebalanceStorageCluster(CLUSTER_NAME, TEST_DB + 1, 3);
    StateTransitionTimeoutConfig stateTransitionTimeoutConfig = new StateTransitionTimeoutConfig(new ZNRecord(TEST_DB + 1));
    stateTransitionTimeoutConfig.setStateTransitionTimeout("SLAVE", "MASTER", 300);
    ClusterConfig clusterConfig = _configAccessor.getClusterConfig(CLUSTER_NAME);
    clusterConfig.setStateTransitionTimeoutConfig(stateTransitionTimeoutConfig);
    _configAccessor.setClusterConfig(CLUSTER_NAME, clusterConfig);
    setParticipants(TEST_DB + 1);
    _setupTool.getClusterManagementTool().enableResource(CLUSTER_NAME, TEST_DB + 1, true);
    boolean result = ClusterStateVerifier.verifyByZkCallback(new MasterNbInExtViewVerifier(ZK_ADDR, CLUSTER_NAME));
    Assert.assertTrue(result);
    verify(TEST_DB + 1);
}
Also used : MasterNbInExtViewVerifier(org.apache.helix.tools.ClusterStateVerifier.MasterNbInExtViewVerifier) StateTransitionTimeoutConfig(org.apache.helix.api.config.StateTransitionTimeoutConfig) ZNRecord(org.apache.helix.ZNRecord) ClusterConfig(org.apache.helix.model.ClusterConfig) Test(org.testng.annotations.Test)

Example 23 with ClusterConfig

use of org.apache.helix.model.ClusterConfig 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);
}
Also used : ClusterControllerManager(org.apache.helix.integration.manager.ClusterControllerManager) MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) ConfigAccessor(org.apache.helix.ConfigAccessor) ClusterSetup(org.apache.helix.tools.ClusterSetup) ClusterConfig(org.apache.helix.model.ClusterConfig) BeforeClass(org.testng.annotations.BeforeClass)

Example 24 with ClusterConfig

use of org.apache.helix.model.ClusterConfig in project helix by apache.

the class ZkIntegrationTestBase method enablePersistIntermediateAssignment.

protected void enablePersistIntermediateAssignment(ZkClient zkClient, String clusterName, Boolean enabled) {
    ConfigAccessor configAccessor = new ConfigAccessor(zkClient);
    ClusterConfig clusterConfig = configAccessor.getClusterConfig(clusterName);
    clusterConfig.setPersistIntermediateAssignment(enabled);
    configAccessor.setClusterConfig(clusterName, clusterConfig);
}
Also used : ConfigAccessor(org.apache.helix.ConfigAccessor) ClusterConfig(org.apache.helix.model.ClusterConfig)

Example 25 with ClusterConfig

use of org.apache.helix.model.ClusterConfig in project helix by apache.

the class ZkIntegrationTestBase method setDelayTimeInCluster.

protected void setDelayTimeInCluster(ZkClient zkClient, String clusterName, long delay) {
    ConfigAccessor configAccessor = new ConfigAccessor(zkClient);
    ClusterConfig clusterConfig = configAccessor.getClusterConfig(clusterName);
    clusterConfig.setRebalanceDelayTime(delay);
    configAccessor.setClusterConfig(clusterName, clusterConfig);
}
Also used : ConfigAccessor(org.apache.helix.ConfigAccessor) ClusterConfig(org.apache.helix.model.ClusterConfig)

Aggregations

ClusterConfig (org.apache.helix.model.ClusterConfig)61 Test (org.testng.annotations.Test)23 ConfigAccessor (org.apache.helix.ConfigAccessor)17 ZNRecord (org.apache.helix.ZNRecord)13 IdealState (org.apache.helix.model.IdealState)10 InstanceConfig (org.apache.helix.model.InstanceConfig)9 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8 Resource (org.apache.helix.model.Resource)7 HelixDataAccessor (org.apache.helix.HelixDataAccessor)6 HelixException (org.apache.helix.HelixException)6 StateTransitionThrottleConfig (org.apache.helix.api.config.StateTransitionThrottleConfig)6 ClusterControllerManager (org.apache.helix.integration.manager.ClusterControllerManager)6 List (java.util.List)5 ZKHelixDataAccessor (org.apache.helix.manager.zk.ZKHelixDataAccessor)5 BeforeClass (org.testng.annotations.BeforeClass)5 HelixManager (org.apache.helix.HelixManager)4 MockParticipantManager (org.apache.helix.integration.manager.MockParticipantManager)4 ExternalView (org.apache.helix.model.ExternalView)4