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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations