use of org.apache.helix.ConfigAccessor in project helix by apache.
the class TestResourceThreadpoolSize method setResourceThreadPoolSize.
private void setResourceThreadPoolSize(String resourceName, int threadPoolSize) {
HelixManager manager = _participants[0];
ConfigAccessor accessor = manager.getConfigAccessor();
HelixConfigScope scope = new HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.RESOURCE).forCluster(manager.getClusterName()).forResource(resourceName).build();
accessor.set(scope, HelixTaskExecutor.MAX_THREADS, "" + threadPoolSize);
}
use of org.apache.helix.ConfigAccessor in project helix by apache.
the class DefaultMessagingService method registerMessageHandlerFactoryInternal.
void registerMessageHandlerFactoryInternal(String type, MessageHandlerFactory factory) {
_logger.info("registering msg factory for type " + type);
int threadpoolSize = HelixTaskExecutor.DEFAULT_PARALLEL_TASKS;
String threadpoolSizeStr = null;
String key = type + "." + HelixTaskExecutor.MAX_THREADS;
ConfigAccessor configAccessor = _manager.getConfigAccessor();
if (configAccessor != null) {
ConfigScope scope = null;
if (_manager.getInstanceType() == InstanceType.PARTICIPANT || _manager.getInstanceType() == InstanceType.CONTROLLER_PARTICIPANT) {
scope = new ConfigScopeBuilder().forCluster(_manager.getClusterName()).forParticipant(_manager.getInstanceName()).build();
threadpoolSizeStr = configAccessor.get(scope, key);
}
if (threadpoolSizeStr == null) {
scope = new ConfigScopeBuilder().forCluster(_manager.getClusterName()).build();
threadpoolSizeStr = configAccessor.get(scope, key);
}
}
if (threadpoolSizeStr != null) {
try {
threadpoolSize = Integer.parseInt(threadpoolSizeStr);
if (threadpoolSize <= 0) {
threadpoolSize = 1;
}
} catch (Exception e) {
_logger.error("", e);
}
}
_taskExecutor.registerMessageHandlerFactory(type, factory, threadpoolSize);
// Self-send a no-op message, so that the onMessage() call will be invoked
// again, and
// we have a chance to process the message that we received with the new
// added MessageHandlerFactory
// before the factory is added.
sendNopMessageInternal();
}
use of org.apache.helix.ConfigAccessor in project helix by apache.
the class TestPartitionMovementThrottle 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(_gZkClient);
// 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);
}
// add dummy participants
for (int i = 0; i < NODE_NR; i++) {
String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
MockParticipantManager participant = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instanceName);
participant.setTransition(new DelayedTransition());
_participants[i] = participant;
}
_configAccessor = new ConfigAccessor(_gZkClient);
// start controller
String controllerName = CONTROLLER_PREFIX + "_0";
_controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
_controller.syncStart();
setupThrottleConfig();
}
use of org.apache.helix.ConfigAccessor in project helix by apache.
the class TestStateTransitionCancellation method beforeClass.
@BeforeClass
public void beforeClass() throws Exception {
_participants = new MockParticipantManager[_numNodes];
_numDbs = 1;
_numParitions = 20;
_numNodes = 2;
_numReplicas = 2;
String namespace = "/" + CLUSTER_NAME;
if (_gZkClient.exists(namespace)) {
_gZkClient.deleteRecursively(namespace);
}
_setupTool = new ClusterSetup(ZK_ADDR);
_setupTool.addCluster(CLUSTER_NAME, true);
setupParticipants();
setupDBs();
registerParticipants(_participants, _numNodes, _startPort, 0, -3000000L);
// start controller
String controllerName = CONTROLLER_PREFIX + "_0";
_controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
_controller.syncStart();
createManagers();
_configAccessor = new ConfigAccessor(_gZkClient);
}
use of org.apache.helix.ConfigAccessor 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);
}
Aggregations