Skip to content

Commit fd26016

Browse files
Daan Hooglandclaude
authored andcommitted
replace key lookups with value() calls in DeploymentClusterPlanner
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 2c76fdd commit fd26016

4 files changed

Lines changed: 7 additions & 9 deletions

File tree

plugins/deployment-planners/user-dispersing/src/main/java/com/cloud/deploy/UserDispersingPlanner.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import javax.naming.ConfigurationException;
2727

2828

29-
import com.cloud.utils.NumbersUtil;
3029
import com.cloud.utils.Pair;
3130
import com.cloud.vm.VirtualMachineProfile;
3231

@@ -187,8 +186,7 @@ private List<Long> orderByApplyingWeights(Pair<List<Long>, Map<Long, Double>> ca
187186
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
188187
super.configure(name, params);
189188

190-
String weight = configDao.getValue(VmUserDispersionWeight.key());
191-
_userDispersionWeight = NumbersUtil.parseFloat(weight, 1.0f);
189+
_userDispersionWeight = VmUserDispersionWeight.value();
192190

193191
return true;
194192
}

server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ private Pair<List<Long>, Map<Long, Double>> getOrderedHostsByCapacity(Long zoneI
287287
double cpuToMemoryWeight = ConfigurationManager.HostCapacityTypeCpuMemoryWeight.value();
288288
// Get capacity by which we should reorder
289289
short capacityType = FirstFitPlanner.getHostCapacityTypeToOrderCluster(
290-
_configDao.getValue(DeploymentClusterPlanner.HostCapacityTypeToOrderClusters.key()), cpuToMemoryWeight);
290+
DeploymentClusterPlanner.HostCapacityTypeToOrderClusters.value(), cpuToMemoryWeight);
291291
logger.debug("CapacityType: {} is used for Host ordering", FirstFitPlanner.getCapacityTypeName(capacityType));
292292
if (capacityType >= 0) { // for CPU or RAM
293293
return _capacityDao.orderHostsByFreeCapacity(zoneId, clusterId, capacityType);

server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public DeployDestination planDeployment(VirtualMachineProfile vmProfile, Deploym
376376
} else if (vm.getHypervisorType() == HypervisorType.External) {
377377
plannerName = "ExternalServerPlanner";
378378
} else {
379-
plannerName = _configDao.getValue(VmDeploymentPlanner.key());
379+
plannerName = VmDeploymentPlanner.value();
380380
}
381381
}
382382
planner = getDeploymentPlannerByName(plannerName);

server/src/main/java/com/cloud/deploy/FirstFitPlanner.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public List<Long> orderClusters(VirtualMachineProfile vmProfile, DeploymentPlan
182182
} else {
183183
logger.debug("Searching all possible resources under this Zone: {}", dcDao.findById(plan.getDataCenterId()));
184184

185-
boolean applyAllocationAtPods = Boolean.parseBoolean(configDao.getValue(ApplyAllocationAlgorithmToPods.key()));
185+
boolean applyAllocationAtPods = ApplyAllocationAlgorithmToPods.value();
186186
if (applyAllocationAtPods) {
187187
//start scan at all pods under this zone.
188188
clusterList = scanPodsForDestination(vmProfile, plan, avoid);
@@ -521,7 +521,7 @@ protected Pair<List<Long>, Map<Long, Double>> listPodsByCapacity(long zoneId, in
521521
private Pair<List<Long>, Map<Long, Double>> getOrderedPodsByCapacity(long zoneId) {
522522
double cpuToMemoryWeight = ConfigurationManager.HostCapacityTypeCpuMemoryWeight.value();
523523
short capacityType = getHostCapacityTypeToOrderCluster(
524-
configDao.getValue(HostCapacityTypeToOrderClusters.key()), cpuToMemoryWeight);
524+
HostCapacityTypeToOrderClusters.value(), cpuToMemoryWeight);
525525

526526
logger.debug("CapacityType: {} is used for Pod ordering", getCapacityTypeName(capacityType));
527527
if (capacityType >= 0) { // for capacityType other than COMBINED
@@ -556,7 +556,7 @@ public Map<Long, Double> getPodByCombinedCapacities(List<CapacityVO> capacities,
556556
private Pair<List<Long>, Map<Long, Double>> getOrderedClustersByCapacity(long id, long vmId, boolean isZone) {
557557
double cpuToMemoryWeight = ConfigurationManager.HostCapacityTypeCpuMemoryWeight.value();
558558
short capacityType = getHostCapacityTypeToOrderCluster(
559-
configDao.getValue(HostCapacityTypeToOrderClusters.key()), cpuToMemoryWeight);
559+
HostCapacityTypeToOrderClusters.value(), cpuToMemoryWeight);
560560

561561
logger.debug("CapacityType: {} is used for Cluster ordering", getCapacityTypeName(capacityType));
562562
if (capacityType >= 0) { // for capacityType other than COMBINED
@@ -667,7 +667,7 @@ public boolean canHandle(VirtualMachineProfile vm, DeploymentPlan plan, ExcludeL
667667
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
668668
super.configure(name, params);
669669
allocationAlgorithm = VmAllocationAlgorithm.value();
670-
globalDeploymentPlanner = configDao.getValue(DeploymentPlanningManager.VmDeploymentPlanner.key());
670+
globalDeploymentPlanner = DeploymentPlanningManager.VmDeploymentPlanner.value();
671671
String configValue;
672672
if ((configValue = configDao.getValue(ImplicitHostTags.key())) != null) {
673673
implicitHostTags = configValue.trim().split("\\s*,\\s*");

0 commit comments

Comments
 (0)