|
29 | 29 |
|
30 | 30 | import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; |
31 | 31 | import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator; |
| 32 | +import org.apache.cloudstack.framework.config.ConfigKey; |
| 33 | +import org.apache.cloudstack.framework.config.Configurable; |
32 | 34 | import org.apache.cloudstack.framework.config.dao.ConfigurationDao; |
33 | 35 | import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; |
34 | 36 |
|
|
83 | 85 | import com.cloud.vm.dao.VMInstanceDao; |
84 | 86 |
|
85 | 87 | @Local(value=DeploymentPlanner.class) |
86 | | -public class FirstFitPlanner extends PlannerBase implements DeploymentClusterPlanner { |
| 88 | +public class FirstFitPlanner extends PlannerBase implements DeploymentClusterPlanner, Configurable{ |
87 | 89 | private static final Logger s_logger = Logger.getLogger(FirstFitPlanner.class); |
88 | 90 | @Inject protected HostDao _hostDao; |
89 | 91 | @Inject protected DataCenterDao _dcDao; |
@@ -246,11 +248,11 @@ private Map<Short, Float> getCapacityThresholdMap() { |
246 | 248 | // if he changes these values |
247 | 249 | Map<Short, Float> disableThresholdMap = new HashMap<Short, Float>(); |
248 | 250 |
|
249 | | - String cpuDisableThresholdString = _configDao.getValue(Config.CPUCapacityDisableThreshold.key()); |
| 251 | + String cpuDisableThresholdString = ClusterCPUCapacityDisableThreshold.value().toString(); |
250 | 252 | float cpuDisableThreshold = NumbersUtil.parseFloat(cpuDisableThresholdString, 0.85F); |
251 | 253 | disableThresholdMap.put(Capacity.CAPACITY_TYPE_CPU, cpuDisableThreshold); |
252 | 254 |
|
253 | | - String memoryDisableThresholdString = _configDao.getValue(Config.MemoryCapacityDisableThreshold.key()); |
| 255 | + String memoryDisableThresholdString = ClusterMemoryCapacityDisableThreshold.value().toString(); |
254 | 256 | float memoryDisableThreshold = NumbersUtil.parseFloat(memoryDisableThresholdString, 0.85F); |
255 | 257 | disableThresholdMap.put(Capacity.CAPACITY_TYPE_MEMORY, memoryDisableThreshold); |
256 | 258 |
|
@@ -283,10 +285,10 @@ private void removeClustersCrossingThreshold(List<Long> clusterListForVmAllocati |
283 | 285 | } |
284 | 286 | if (capacity == Capacity.CAPACITY_TYPE_CPU) { |
285 | 287 | clustersCrossingThreshold = _capacityDao.listClustersCrossingThreshold(capacity, |
286 | | - plan.getDataCenterId(), Config.CPUCapacityDisableThreshold.key(), cpu_requested); |
| 288 | + plan.getDataCenterId(), ClusterCPUCapacityDisableThreshold.key(), cpu_requested); |
287 | 289 | } else if (capacity == Capacity.CAPACITY_TYPE_MEMORY) { |
288 | 290 | clustersCrossingThreshold = _capacityDao.listClustersCrossingThreshold(capacity, |
289 | | - plan.getDataCenterId(), Config.MemoryCapacityDisableThreshold.key(), ram_requested); |
| 291 | + plan.getDataCenterId(), ClusterMemoryCapacityDisableThreshold.key(), ram_requested); |
290 | 292 | } |
291 | 293 |
|
292 | 294 | if (clustersCrossingThreshold != null && clustersCrossingThreshold.size() != 0) { |
@@ -522,4 +524,14 @@ public PlannerResourceUsage getResourceUsage(VirtualMachineProfile vmProfile, |
522 | 524 | DeploymentPlan plan, ExcludeList avoid) throws InsufficientServerCapacityException { |
523 | 525 | return PlannerResourceUsage.Shared; |
524 | 526 | } |
| 527 | + |
| 528 | + @Override |
| 529 | + public String getConfigComponentName() { |
| 530 | + return DeploymentClusterPlanner.class.getSimpleName(); |
| 531 | + } |
| 532 | + |
| 533 | + @Override |
| 534 | + public ConfigKey<?>[] getConfigKeys() { |
| 535 | + return new ConfigKey<?>[] {ClusterCPUCapacityDisableThreshold, ClusterMemoryCapacityDisableThreshold}; |
| 536 | + } |
525 | 537 | } |
0 commit comments