use of org.apache.helix.model.ClusterConfig in project helix by apache.
the class TestIdealStateAssignment method testIdealStateAssignment.
@Test(dataProvider = "IdealStateInput")
public void testIdealStateAssignment(String clusterName, List<String> instances, List<String> partitions, String numReplicas, String stateModeDef, String strategyName, Map<String, Map<String, String>> expectedMapping) throws IllegalAccessException, InstantiationException, ClassNotFoundException {
ClusterConfig clusterConfig = new ClusterConfig(clusterName);
List<InstanceConfig> instanceConfigs = new ArrayList<>();
for (String instance : instances) {
instanceConfigs.add(new InstanceConfig(instance));
}
IdealState idealState = new IdealState("TestResource");
idealState.setStateModelDefRef(stateModeDef);
idealState.setNumPartitions(partitions.size());
idealState.setReplicas(numReplicas);
Map<String, Map<String, String>> idealStateMapping = HelixUtil.getIdealAssignmentForFullAuto(clusterConfig, instanceConfigs, instances, idealState, partitions, strategyName);
Assert.assertEquals(idealStateMapping, expectedMapping);
}
use of org.apache.helix.model.ClusterConfig in project helix by apache.
the class TestTopStateHandoffMetrics method testTopStateFailedHandoff.
@Test(dataProvider = "failedCurrentStateInput")
public void testTopStateFailedHandoff(Map<String, Map<String, String>> initialCurrentStates, Map<String, Map<String, String>> handOffCurrentStates, Long expectedDuration) {
preSetup();
ClusterConfig clusterConfig = new ClusterConfig(_clusterName);
clusterConfig.setMissTopStateDurationThreshold(5000L);
setClusterConfig(clusterConfig);
runCurrentStage(initialCurrentStates, handOffCurrentStates);
ClusterStatusMonitor clusterStatusMonitor = event.getAttribute(AttributeName.clusterStatusMonitor.name());
ResourceMonitor monitor = clusterStatusMonitor.getResourceMonitor(TEST_RESOURCE);
// Should have 1 transition failed due to threshold.
Assert.assertEquals(monitor.getFailedTopStateHandoffCounter(), 1);
// No duration updated.
Assert.assertEquals(monitor.getSuccessfulTopStateHandoffDurationCounter(), (long) expectedDuration);
Assert.assertEquals(monitor.getMaxSinglePartitionTopStateHandoffDurationGauge(), (long) expectedDuration);
}
use of org.apache.helix.model.ClusterConfig in project helix by apache.
the class ClusterAccessor method getClusterConfig.
@GET
@Path("{clusterId}/configs")
public Response getClusterConfig(@PathParam("clusterId") String clusterId) {
ConfigAccessor accessor = getConfigAccessor();
ClusterConfig config = null;
try {
config = accessor.getClusterConfig(clusterId);
} catch (HelixException ex) {
// cluster not found.
_logger.info("Failed to get cluster config for cluster " + clusterId + ", cluster not found, Exception: " + ex);
} catch (Exception ex) {
_logger.error("Failed to get cluster config for cluster " + clusterId + " Exception: " + ex);
return serverError(ex);
}
if (config == null) {
return notFound();
}
return JSONRepresentation(config.getRecord());
}
use of org.apache.helix.model.ClusterConfig in project helix by apache.
the class TestP2PStateTransitionMessages method testP2PMessageEnabled.
@Test
public void testP2PMessageEnabled() throws Exception {
preSetup();
ClusterConfig clusterConfig = new ClusterConfig(_clusterName);
clusterConfig.enableP2PMessage(true);
setClusterConfig(clusterConfig);
testP2PMessage(clusterConfig, true);
}
use of org.apache.helix.model.ClusterConfig in project helix by apache.
the class MockHelixAdmin method createZKPaths.
private void createZKPaths(String clusterName) {
String path;
// IDEAL STATE
_baseDataAccessor.create(PropertyPathBuilder.idealState(clusterName), new ZNRecord(clusterName), 0);
// CONFIGURATIONS
path = PropertyPathBuilder.clusterConfig(clusterName);
_baseDataAccessor.create(path, new ClusterConfig(clusterName).getRecord(), 0);
path = PropertyPathBuilder.instanceConfig(clusterName);
_baseDataAccessor.create(path, new ZNRecord(clusterName), 0);
path = PropertyPathBuilder.resourceConfig(clusterName);
_baseDataAccessor.create(path, new ZNRecord(clusterName), 0);
// PROPERTY STORE
path = PropertyPathBuilder.propertyStore(clusterName);
_baseDataAccessor.create(path, new ZNRecord(clusterName), 0);
// LIVE INSTANCES
_baseDataAccessor.create(PropertyPathBuilder.liveInstance(clusterName), new ZNRecord(clusterName), 0);
// MEMBER INSTANCES
_baseDataAccessor.create(PropertyPathBuilder.instance(clusterName), new ZNRecord(clusterName), 0);
// External view
_baseDataAccessor.create(PropertyPathBuilder.externalView(clusterName), new ZNRecord(clusterName), 0);
// State model definition
_baseDataAccessor.create(PropertyPathBuilder.stateModelDef(clusterName), new ZNRecord(clusterName), 0);
// controller
_baseDataAccessor.create(PropertyPathBuilder.controller(clusterName), new ZNRecord(clusterName), 0);
path = PropertyPathBuilder.controllerHistory(clusterName);
final ZNRecord emptyHistory = new ZNRecord(PropertyType.HISTORY.toString());
final List<String> emptyList = new ArrayList<String>();
emptyHistory.setListField(clusterName, emptyList);
_baseDataAccessor.create(path, emptyHistory, 0);
path = PropertyPathBuilder.controllerMessage(clusterName);
_baseDataAccessor.create(path, new ZNRecord(clusterName), 0);
path = PropertyPathBuilder.controllerStatusUpdate(clusterName);
_baseDataAccessor.create(path, new ZNRecord(clusterName), 0);
path = PropertyPathBuilder.controllerError(clusterName);
_baseDataAccessor.create(path, new ZNRecord(clusterName), 0);
}
Aggregations