本文整理汇总了Java中org.apache.helix.model.IdealState.setRebalanceStrategy方法的典型用法代码示例。如果您正苦于以下问题:Java IdealState.setRebalanceStrategy方法的具体用法?Java IdealState.setRebalanceStrategy怎么用?Java IdealState.setRebalanceStrategy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.helix.model.IdealState
的用法示例。
在下文中一共展示了IdealState.setRebalanceStrategy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addResource
import org.apache.helix.model.IdealState; //导入方法依赖的package包/类
@Override
public void addResource(String clusterName, String resourceName, int partitions,
String stateModelRef, String rebalancerMode, String rebalanceStrategy, int bucketSize,
int maxPartitionsPerInstance) {
if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
throw new HelixException("cluster " + clusterName + " is not setup yet");
}
IdealState idealState = new IdealState(resourceName);
idealState.setNumPartitions(partitions);
idealState.setStateModelDefRef(stateModelRef);
RebalanceMode mode =
idealState.rebalanceModeFromString(rebalancerMode, RebalanceMode.SEMI_AUTO);
idealState.setRebalanceMode(mode);
idealState.setRebalanceStrategy(rebalanceStrategy);
idealState.setReplicas("" + 0);
idealState.setStateModelFactoryName(HelixConstants.DEFAULT_STATE_MODEL_FACTORY);
if (maxPartitionsPerInstance > 0 && maxPartitionsPerInstance < Integer.MAX_VALUE) {
idealState.setMaxPartitionsPerInstance(maxPartitionsPerInstance);
}
if (bucketSize > 0) {
idealState.setBucketSize(bucketSize);
}
addResource(clusterName, resourceName, idealState);
}
示例2: setupIdealState
import org.apache.helix.model.IdealState; //导入方法依赖的package包/类
protected List<IdealState> setupIdealState(int nodes, String[] resources, int partitions,
int replicas, RebalanceMode rebalanceMode, String stateModelName, String rebalanceClassName,
String rebalanceStrategyName) {
List<IdealState> idealStates = new ArrayList<IdealState>();
for (int i = 0; i < resources.length; i++) {
String resourceName = resources[i];
ZNRecord record = new ZNRecord(resourceName);
for (int p = 0; p < partitions; p++) {
List<String> value = new ArrayList<String>();
for (int r = 0; r < replicas; r++) {
value.add(HOSTNAME_PREFIX + (p + r + 1) % nodes);
}
record.setListField(resourceName + "_" + p, value);
}
IdealState idealState = new IdealState(record);
idealState.setStateModelDefRef(stateModelName);
if (rebalanceClassName != null) {
idealState.setRebalancerClassName(rebalanceClassName);
}
if (rebalanceStrategyName != null) {
idealState.setRebalanceStrategy(rebalanceStrategyName);
}
idealState.setRebalanceMode(rebalanceMode);
idealState.setNumPartitions(partitions);
idealStates.add(idealState);
idealState.setReplicas(String.valueOf(replicas));
Builder keyBuilder = accessor.keyBuilder();
accessor.setProperty(keyBuilder.idealStates(resourceName), idealState);
}
return idealStates;
}
示例3: build
import org.apache.helix.model.IdealState; //导入方法依赖的package包/类
/**
* @return
*/
public IdealState build() {
IdealState idealstate = new IdealState(_record);
idealstate.setNumPartitions(numPartitions);
idealstate.setStateModelDefRef(stateModel);
idealstate.setStateModelFactoryName(stateModelFactoryName);
idealstate.setRebalanceMode(rebalancerMode);
idealstate.setReplicas("" + numReplica);
if (minActiveReplica >= 0) {
idealstate.setMinActiveReplicas(minActiveReplica);
}
if (rebalancerClassName != null) {
idealstate.setRebalancerClassName(rebalancerClassName);
}
if (rebalanceStrategy != null) {
idealstate.setRebalanceStrategy(rebalanceStrategy);
}
if (maxPartitionsPerNode > 0) {
idealstate.setMaxPartitionsPerInstance(maxPartitionsPerNode);
}
if (disableExternalView != null) {
idealstate.setDisableExternalView(disableExternalView);
}
if (enableGroupRouting != null) {
idealstate.enableGroupRouting(enableGroupRouting);
}
if (resourceGroupName != null) {
idealstate.setResourceGroupName(resourceGroupName);
}
if (resourceType != null) {
idealstate.setResourceType(resourceType);
}
if (rebalanceDelayInMs >= 0) {
idealstate.setRebalanceDelay(rebalanceDelayInMs);
}
if (delayRebalanceEnabled != null) {
idealstate.setDelayRebalanceEnabled(delayRebalanceEnabled);
}
if (!idealstate.isValid()) {
throw new HelixException("invalid ideal-state: " + idealstate);
}
return idealstate;
}