Search in sources :

Example 26 with ConfigAccessor

use of org.apache.helix.ConfigAccessor in project helix by apache.

the class TestJobFailureTaskNotStarted method beforeClass.

@BeforeClass
public void beforeClass() throws Exception {
    _participants = new MockParticipantManager[_numNodes];
    _numDbs = 1;
    _numNodes = 2;
    _numParitions = 2;
    _numReplicas = 1;
    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);
    _configAccessor.setClusterConfig(CLUSTER_NAME, clusterConfig);
}
Also used : ClusterControllerManager(org.apache.helix.integration.manager.ClusterControllerManager) ConfigAccessor(org.apache.helix.ConfigAccessor) ClusterSetup(org.apache.helix.tools.ClusterSetup) ClusterConfig(org.apache.helix.model.ClusterConfig) BeforeClass(org.testng.annotations.BeforeClass)

Example 27 with ConfigAccessor

use of org.apache.helix.ConfigAccessor in project helix by apache.

the class StrictMatchExternalViewVerifier method verifyExternalView.

private boolean verifyExternalView(ClusterDataCache dataCache, ExternalView externalView, IdealState idealState) {
    Map<String, Map<String, String>> mappingInExtview = externalView.getRecord().getMapFields();
    Map<String, Map<String, String>> idealPartitionState;
    switch(idealState.getRebalanceMode()) {
        case FULL_AUTO:
            ClusterConfig clusterConfig = new ConfigAccessor(_zkClient).getClusterConfig(dataCache.getClusterName());
            if (!clusterConfig.isPersistBestPossibleAssignment() && !clusterConfig.isPersistIntermediateAssignment()) {
                throw new HelixException(String.format("Full-Auto IdealState verifier requires " + "ClusterConfig.PERSIST_BEST_POSSIBLE_ASSIGNMENT or ClusterConfig.PERSIST_INTERMEDIATE_ASSIGNMENT " + "is enabled."));
            }
            for (String partition : idealState.getPartitionSet()) {
                if (idealState.getPreferenceList(partition) == null || idealState.getPreferenceList(partition).isEmpty()) {
                    return false;
                }
            }
            idealPartitionState = computeIdealPartitionState(dataCache, idealState);
            break;
        case SEMI_AUTO:
        case USER_DEFINED:
            idealPartitionState = computeIdealPartitionState(dataCache, idealState);
            break;
        case CUSTOMIZED:
            idealPartitionState = idealState.getRecord().getMapFields();
            break;
        case TASK:
        // ignore jobs
        default:
            return true;
    }
    return mappingInExtview.equals(idealPartitionState);
}
Also used : HelixException(org.apache.helix.HelixException) ConfigAccessor(org.apache.helix.ConfigAccessor) HashMap(java.util.HashMap) Map(java.util.Map) ClusterConfig(org.apache.helix.model.ClusterConfig)

Example 28 with ConfigAccessor

use of org.apache.helix.ConfigAccessor in project helix by apache.

the class ZkIntegrationTestBase method enableHealthCheck.

protected void enableHealthCheck(String clusterName) {
    ConfigScope scope = new ConfigScopeBuilder().forCluster(clusterName).build();
    new ConfigAccessor(_gZkClient).set(scope, "healthChange" + ".enabled", "" + true);
}
Also used : ConfigScope(org.apache.helix.model.ConfigScope) ConfigAccessor(org.apache.helix.ConfigAccessor) ConfigScopeBuilder(org.apache.helix.model.builder.ConfigScopeBuilder)

Example 29 with ConfigAccessor

use of org.apache.helix.ConfigAccessor in project helix by apache.

the class ZkIntegrationTestBase method enableDelayRebalanceInCluster.

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

Example 30 with ConfigAccessor

use of org.apache.helix.ConfigAccessor in project helix by apache.

the class ZkIntegrationTestBase method enableDelayRebalanceInInstance.

protected void enableDelayRebalanceInInstance(ZkClient zkClient, String clusterName, String instanceName, boolean enabled) {
    ConfigAccessor configAccessor = new ConfigAccessor(zkClient);
    InstanceConfig instanceConfig = configAccessor.getInstanceConfig(clusterName, instanceName);
    instanceConfig.setDelayRebalanceEnabled(enabled);
    configAccessor.setInstanceConfig(clusterName, instanceName, instanceConfig);
}
Also used : InstanceConfig(org.apache.helix.model.InstanceConfig) ConfigAccessor(org.apache.helix.ConfigAccessor)

Aggregations

ConfigAccessor (org.apache.helix.ConfigAccessor)41 ClusterConfig (org.apache.helix.model.ClusterConfig)15 ClusterControllerManager (org.apache.helix.integration.manager.ClusterControllerManager)14 BeforeClass (org.testng.annotations.BeforeClass)14 MockParticipantManager (org.apache.helix.integration.manager.MockParticipantManager)10 ClusterSetup (org.apache.helix.tools.ClusterSetup)9 Date (java.util.Date)7 HelixConfigScope (org.apache.helix.model.HelixConfigScope)7 HelixConfigScopeBuilder (org.apache.helix.model.builder.HelixConfigScopeBuilder)7 Test (org.testng.annotations.Test)7 HelixException (org.apache.helix.HelixException)6 Path (javax.ws.rs.Path)5 BestPossibleExternalViewVerifier (org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier)4 HelixClusterVerifier (org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier)4 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 GET (javax.ws.rs.GET)3 HelixManager (org.apache.helix.HelixManager)3 ZNRecord (org.apache.helix.ZNRecord)3 ZKHelixDataAccessor (org.apache.helix.manager.zk.ZKHelixDataAccessor)3