本文整理了Java中org.apache.helix.controller.rebalancer.constraint.dataprovider.ZkBasedCapacityProvider
类的一些代码示例,展示了ZkBasedCapacityProvider
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkBasedCapacityProvider
类的具体详情如下:
包路径:org.apache.helix.controller.rebalancer.constraint.dataprovider.ZkBasedCapacityProvider
类名称:ZkBasedCapacityProvider
[英]A capacity provider based on ZK node. This class support persistent through Helix Property Store.
[中]基于ZK节点的容量提供者。此类支持通过Helix属性存储持久化。
代码示例来源:origin: apache/helix
new ZkBasedCapacityProvider(ZK_ADDR, CLUSTER_NAME, "Test");
capacityProvider.updateCapacity(capacity, usage, defaultCapacity);
Assert.assertEquals(capacityProvider.getParticipantCapacity(instance),
capacity.get(instance).intValue());
Assert.assertEquals(capacityProvider.getParticipantUsage(instance),
usage.get(instance).intValue());
capacityProvider.persistCapacity();
capacityProvider = new ZkBasedCapacityProvider(ZK_ADDR, CLUSTER_NAME, "Test");
for (String instance : instanceNames) {
Assert.assertEquals(capacityProvider.getParticipantCapacity(instance),
capacity.get(instance).intValue());
Assert.assertEquals(capacityProvider.getParticipantUsage(instance),
usage.get(instance).intValue());
capacityProvider.updateCapacity(Collections.EMPTY_MAP,
Collections.singletonMap(targetInstanceName, newUsgae), defaultCapacity);
Assert.assertEquals(capacityProvider.getParticipantUsage(targetInstanceName), newUsgae);
capacityProvider = new ZkBasedCapacityProvider(ZK_ADDR, CLUSTER_NAME, "Test");
Assert.assertEquals(capacityProvider.getParticipantUsage(targetInstanceName), 0);
capacityProvider.updateCapacity(Collections.EMPTY_MAP, Collections.EMPTY_MAP, -1);
try {
capacityProvider.persistCapacity();
Assert.fail("Should fail to persist invalid weight information.");
} catch (HelixException hex) {
代码示例来源:origin: org.apache.helix/helix-core
new ZkBasedCapacityProvider(ZK_ADDRESS, CLUSTER_NAME, "QPS");
qpsCapacityProvider.updateCapacity(Collections.EMPTY_MAP, Collections.EMPTY_MAP, defaultCapacity);
new ZkBasedCapacityProvider(ZK_ADDRESS, CLUSTER_NAME, "MEM");
memoryCapacityProvider.updateCapacity(Collections.EMPTY_MAP, Collections.EMPTY_MAP, defaultCapacity);
qpsCapacityProvider.persistCapacity();
qpsWeightProvider.persistWeights();
memoryCapacityProvider.persistCapacity();
memoryWeightProvider.persistWeights();
new ZkBasedPartitionWeightProvider(ZK_ADDRESS, CLUSTER_NAME, "QPS");
qpsCapacityProvider =
new ZkBasedCapacityProvider(ZK_ADDRESS, CLUSTER_NAME, "QPS");
memoryWeightProvider =
new ZkBasedPartitionWeightProvider(ZK_ADDRESS, CLUSTER_NAME, "MEM");
memoryCapacityProvider =
new ZkBasedCapacityProvider(ZK_ADDRESS, CLUSTER_NAME, "MEM");
代码示例来源:origin: apache/helix
@Test
public void testRebalanceUsingZkDataProvider() {
// capacity / weight
Map<String, Integer> capacity = new HashMap<>();
for (String instance : instanceNames) {
capacity.put(instance, defaultCapacity);
}
ZkBasedPartitionWeightProvider weightProvider =
new ZkBasedPartitionWeightProvider(ZK_ADDR, CLUSTER_NAME, "QPS");
weightProvider.updateWeights(Collections.EMPTY_MAP, Collections.EMPTY_MAP, resourceWeight);
ZkBasedCapacityProvider capacityProvider =
new ZkBasedCapacityProvider(ZK_ADDR, CLUSTER_NAME, "QPS");
capacityProvider.updateCapacity(capacity, Collections.EMPTY_MAP, 0);
TotalCapacityConstraint capacityConstraint =
new TotalCapacityConstraint(weightProvider, capacityProvider);
PartitionWeightAwareEvennessConstraint evenConstraint =
new PartitionWeightAwareEvennessConstraint(weightProvider, capacityProvider);
WeightAwareRebalanceUtil util = new WeightAwareRebalanceUtil(clusterConfig, instanceConfigs);
ResourcesStateMap assignment = util.buildIncrementalRebalanceAssignment(resourceConfigs, null,
Collections.<AbstractRebalanceHardConstraint>singletonList(capacityConstraint),
Collections.<AbstractRebalanceSoftConstraint>singletonList(evenConstraint));
Map<String, Integer> weightCount = checkPartitionUsage(assignment, weightProvider);
int max = Collections.max(weightCount.values());
int min = Collections.min(weightCount.values());
// Since the accuracy of Default evenness constraint is 0.01, diff should be 1/100 of participant capacity in max.
Assert.assertTrue((max - min) <= defaultCapacity / 100);
}
代码示例来源:origin: apache/helix
new ZkBasedCapacityProvider(ZK_ADDRESS, CLUSTER_NAME, "QPS");
qpsCapacityProvider.updateCapacity(Collections.EMPTY_MAP, Collections.EMPTY_MAP, defaultCapacity);
new ZkBasedCapacityProvider(ZK_ADDRESS, CLUSTER_NAME, "MEM");
memoryCapacityProvider.updateCapacity(Collections.EMPTY_MAP, Collections.EMPTY_MAP, defaultCapacity);
qpsCapacityProvider.persistCapacity();
qpsWeightProvider.persistWeights();
memoryCapacityProvider.persistCapacity();
memoryWeightProvider.persistWeights();
new ZkBasedPartitionWeightProvider(ZK_ADDRESS, CLUSTER_NAME, "QPS");
qpsCapacityProvider =
new ZkBasedCapacityProvider(ZK_ADDRESS, CLUSTER_NAME, "QPS");
memoryWeightProvider =
new ZkBasedPartitionWeightProvider(ZK_ADDRESS, CLUSTER_NAME, "MEM");
memoryCapacityProvider =
new ZkBasedCapacityProvider(ZK_ADDRESS, CLUSTER_NAME, "MEM");
代码示例来源:origin: apache/helix
new ZkBasedCapacityProvider(ZK_ADDR, CLUSTER_NAME, "QPS");
capacityProvider.updateCapacity(capacity, usage, 0);
代码示例来源:origin: apache/helix
new ZkBasedCapacityProvider(ZK_ADDR, CLUSTER_NAME, "QPS");
capacityProvider.updateCapacity(capacity, Collections.EMPTY_MAP, 0);
代码示例来源:origin: apache/helix
new ZkBasedCapacityProvider(ZK_ADDR, CLUSTER_NAME, "QPS");
capacityProvider.updateCapacity(capacity, Collections.EMPTY_MAP, 0);
内容来源于网络,如有侵权,请联系作者删除!