use of org.apache.helix.model.ResourceConfig in project helix by apache.
the class TestMixedModeAutoRebalance method removePartitionFromUserDefinedList.
private void removePartitionFromUserDefinedList(String db, List<String> userDefinedPartitions) {
ResourceConfig resourceConfig = _configAccessor.getResourceConfig(CLUSTER_NAME, db);
Map<String, List<String>> lists = resourceConfig.getPreferenceLists();
lists.remove(userDefinedPartitions.get(0));
resourceConfig.setPreferenceLists(lists);
userDefinedPartitions.remove(0);
_configAccessor.setResourceConfig(CLUSTER_NAME, db, resourceConfig);
// TODO: Touch IS, remove this once Helix controller is listening on resource config changes.
RebalanceScheduler.invokeRebalance(_dataAccessor, db);
}
use of org.apache.helix.model.ResourceConfig in project helix by apache.
the class TestP2PMessageSemiAuto method enableP2PInResource.
private void enableP2PInResource(String dbName, boolean enable) {
if (enable) {
ResourceConfig resourceConfig = new ResourceConfig.Builder(dbName).setP2PMessageEnabled(true).build();
_configAccessor.setResourceConfig(CLUSTER_NAME, dbName, resourceConfig);
} else {
// remove P2P Message in resource config
ResourceConfig resourceConfig = _configAccessor.getResourceConfig(CLUSTER_NAME, dbName);
if (resourceConfig != null) {
resourceConfig.getRecord().getSimpleFields().remove(HelixConfigProperty.P2P_MESSAGE_ENABLED.name());
_configAccessor.setResourceConfig(CLUSTER_NAME, dbName, resourceConfig);
}
}
}
use of org.apache.helix.model.ResourceConfig in project helix by apache.
the class TestStateTransitionTimeoutWithResource method testStateTransitionTimeOut.
@Test
public void testStateTransitionTimeOut() throws Exception {
_setupTool.addResourceToCluster(CLUSTER_NAME, TEST_DB, _PARTITIONS, STATE_MODEL);
_setupTool.getClusterManagementTool().enableResource(CLUSTER_NAME, TEST_DB, false);
_setupTool.rebalanceStorageCluster(CLUSTER_NAME, TEST_DB, 3);
// Set the timeout values
StateTransitionTimeoutConfig stateTransitionTimeoutConfig = new StateTransitionTimeoutConfig(new ZNRecord(TEST_DB));
stateTransitionTimeoutConfig.setStateTransitionTimeout("SLAVE", "MASTER", 300);
ResourceConfig resourceConfig = new ResourceConfig.Builder(TEST_DB).setStateTransitionTimeoutConfig(stateTransitionTimeoutConfig).setRebalanceConfig(new RebalanceConfig(new ZNRecord(TEST_DB))).setNumPartitions(_PARTITIONS).setHelixEnabled(false).build();
_configAccessor.setResourceConfig(CLUSTER_NAME, TEST_DB, resourceConfig);
setParticipants(TEST_DB);
_setupTool.getClusterManagementTool().enableResource(CLUSTER_NAME, TEST_DB, true);
boolean result = ClusterStateVerifier.verifyByZkCallback(new MasterNbInExtViewVerifier(ZK_ADDR, CLUSTER_NAME));
Assert.assertTrue(result);
verify(TEST_DB);
}
use of org.apache.helix.model.ResourceConfig in project helix by apache.
the class TestMixedModeAutoRebalance method testUserDefinedPreferenceListsInFullAuto.
@Test(dataProvider = "stateModels")
public void testUserDefinedPreferenceListsInFullAuto(String stateModel, boolean delayEnabled) throws Exception {
String db = "Test-DB-" + stateModel;
if (delayEnabled) {
createResourceWithDelayedRebalance(CLUSTER_NAME, db, stateModel, _PARTITIONS, _replica, _replica - 1, 200, CrushRebalanceStrategy.class.getName());
} else {
createResourceWithDelayedRebalance(CLUSTER_NAME, db, stateModel, _PARTITIONS, _replica, _replica, 0, CrushRebalanceStrategy.class.getName());
}
IdealState idealState = _gSetupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, db);
Map<String, List<String>> userDefinedPreferenceLists = idealState.getPreferenceLists();
List<String> userDefinedPartitions = new ArrayList<>();
for (String partition : userDefinedPreferenceLists.keySet()) {
List<String> preferenceList = new ArrayList<>();
for (int k = _replica; k >= 0; k--) {
String instance = _participants.get(k).getInstanceName();
preferenceList.add(instance);
}
userDefinedPreferenceLists.put(partition, preferenceList);
userDefinedPartitions.add(partition);
}
ResourceConfig resourceConfig = new ResourceConfig.Builder(db).setPreferenceLists(userDefinedPreferenceLists).build();
_configAccessor.setResourceConfig(CLUSTER_NAME, db, resourceConfig);
// TODO: Trigger rebalancer, remove this once Helix controller is listening on resource config changes.
RebalanceScheduler.invokeRebalance(_dataAccessor, db);
while (userDefinedPartitions.size() > 0) {
Thread.sleep(100);
Assert.assertTrue(_clusterVerifier.verify());
verifyUserDefinedPreferenceLists(db, userDefinedPreferenceLists, userDefinedPartitions);
removePartitionFromUserDefinedList(db, userDefinedPartitions);
}
}
use of org.apache.helix.model.ResourceConfig in project helix by apache.
the class TestMixedModeAutoRebalance method testUserDefinedPreferenceListsInFullAutoWithErrors.
@Test
public void testUserDefinedPreferenceListsInFullAutoWithErrors() throws Exception {
String db = "Test-DB-1";
createResourceWithDelayedRebalance(CLUSTER_NAME, db, BuiltInStateModelDefinitions.MasterSlave.name(), 5, _replica, _replica, 0, CrushRebalanceStrategy.class.getName());
IdealState idealState = _gSetupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, db);
Map<String, List<String>> userDefinedPreferenceLists = idealState.getPreferenceLists();
List<String> newNodes = new ArrayList<>();
for (int i = NUM_NODE; i < NUM_NODE + _replica; i++) {
String instance = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
_gSetupTool.addInstanceToCluster(CLUSTER_NAME, instance);
// start dummy participants
MockParticipantManager participant = new TestMockParticipantManager(ZK_ADDR, CLUSTER_NAME, instance);
participant.syncStart();
_participants.add(participant);
newNodes.add(instance);
}
List<String> userDefinedPartitions = new ArrayList<>();
for (String partition : userDefinedPreferenceLists.keySet()) {
userDefinedPreferenceLists.put(partition, newNodes);
userDefinedPartitions.add(partition);
}
ResourceConfig resourceConfig = new ResourceConfig.Builder(db).setPreferenceLists(userDefinedPreferenceLists).build();
_configAccessor.setResourceConfig(CLUSTER_NAME, db, resourceConfig);
// TODO: Trigger rebalancer, remove this once Helix controller is listening on resource config changes.
RebalanceScheduler.invokeRebalance(_dataAccessor, db);
Thread.sleep(1000);
ExternalView ev = _gSetupTool.getClusterManagementTool().getResourceExternalView(CLUSTER_NAME, db);
IdealState is = _gSetupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, db);
validateMinActiveAndTopStateReplica(is, ev, _replica, NUM_NODE);
}
Aggregations