Skip to content

Commit 42c5625

Browse files
Nicole SchmidtGaOrtiga
authored andcommitted
Move configuration to Planner hierarchy
1 parent 9e19ab3 commit 42c5625

6 files changed

Lines changed: 16 additions & 24 deletions

File tree

api/src/main/java/com/cloud/deploy/DeploymentClusterPlanner.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ public interface DeploymentClusterPlanner extends DeploymentPlanner {
6868
ConfigKey.Kind.Select,
6969
"random,firstfit,userdispersing,firstfitleastconsumed");
7070

71+
ConfigKey<Boolean> allowRoutersOnDedicatedResources = new ConfigKey<>(
72+
"Advanced",
73+
Boolean.class,
74+
"allow.routers.on.dedicated.resources",
75+
"false",
76+
"Allow deploying virtual routers on dedicated Hosts, Clusters, Pods, and Zones",
77+
true);
78+
7179
/**
7280
* This is called to determine list of possible clusters where a virtual
7381
* machine can be deployed.

engine/schema/src/main/java/com/cloud/capacity/dao/CapacityDao.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,9 @@
2424
import com.cloud.utils.Pair;
2525
import com.cloud.utils.Ternary;
2626
import com.cloud.utils.db.GenericDao;
27-
import org.apache.cloudstack.framework.config.ConfigKey;
2827

2928
public interface CapacityDao extends GenericDao<CapacityVO, Long> {
3029

31-
ConfigKey<Boolean> allowRoutersOnDedicatedResources = new ConfigKey<>("Advanced", Boolean.class, "allow.routers.on.dedicated.resources", "false",
32-
"Allow deploying virtual routers on dedicated Hosts, Clusters, Pods, and Zones", true);
33-
3430
CapacityVO findByHostIdType(Long hostId, short capacityType);
3531

3632
List<CapacityVO> listByHostIdTypes(Long hostId, List<Short> capacityTypes);
@@ -45,7 +41,7 @@ public interface CapacityDao extends GenericDao<CapacityVO, Long> {
4541

4642
List<SummedCapacity> findNonSharedStorageForClusterPodZone(Long zoneId, Long podId, Long clusterId);
4743

48-
Pair<List<Long>, Map<Long, Double>> orderClustersByAggregateCapacity(long id, long vmId, short capacityType, boolean isVr, boolean isZone);
44+
Pair<List<Long>, Map<Long, Double>> orderClustersByAggregateCapacity(long id, long vmId, short capacityType, boolean isVr, boolean allowRoutersOnDedicatedResources, boolean isZone);
4945

5046
Ternary<Long, Long, Long> findCapacityByZoneAndHostTag(Long zoneId, String hostTag);
5147

engine/schema/src/main/java/com/cloud/capacity/dao/CapacityDaoImpl.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
import javax.inject.Inject;
2828

29-
import org.apache.cloudstack.framework.config.ConfigKey;
30-
import org.apache.cloudstack.framework.config.Configurable;
3129
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
3230
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
3331
import org.apache.commons.collections.CollectionUtils;
@@ -51,7 +49,7 @@
5149
import com.cloud.utils.exception.CloudRuntimeException;
5250

5351
@Component
54-
public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements CapacityDao, Configurable {
52+
public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements CapacityDao {
5553

5654
private static final String ADD_ALLOCATED_SQL = "UPDATE `cloud`.`op_host_capacity` SET used_capacity = used_capacity + ? WHERE host_id = ? AND capacity_type = ?";
5755
private static final String SUBTRACT_ALLOCATED_SQL =
@@ -995,7 +993,7 @@ public boolean removeBy(Short capacityType, Long zoneId, Long podId, Long cluste
995993
}
996994

997995
@Override
998-
public Pair<List<Long>, Map<Long, Double>> orderClustersByAggregateCapacity(long id, long vmId, short capacityTypeForOrdering, boolean isVr, boolean isZone) {
996+
public Pair<List<Long>, Map<Long, Double>> orderClustersByAggregateCapacity(long id, long vmId, short capacityTypeForOrdering, boolean isVr, boolean allowRoutersOnDedicatedResources, boolean isZone) {
999997
TransactionLegacy txn = TransactionLegacy.currentTxn();
1000998
PreparedStatement pstmt = null;
1001999
List<Long> result = new ArrayList<Long>();
@@ -1007,7 +1005,7 @@ public Pair<List<Long>, Map<Long, Double>> orderClustersByAggregateCapacity(long
10071005
sql.append(ORDER_CLUSTERS_BY_AGGREGATE_OVERCOMMIT_CAPACITY_PART1);
10081006
}
10091007

1010-
if (isVr && allowRoutersOnDedicatedResources.value()) {
1008+
if (isVr && allowRoutersOnDedicatedResources) {
10111009
sql.append(ORDER_CLUSTERS_BY_AGGREGATE_CAPACITY_INCLUDE_DEDICATED_TO_DOMAIN_JOIN_1);
10121010
} else {
10131011
sql.append(ORDER_CLUSTERS_BY_AGGREGATE_CAPACITY_JOIN_1);
@@ -1304,14 +1302,4 @@ public float findClusterConsumption(Long clusterId, short capacityType, long com
13041302
}
13051303
return 0;
13061304
}
1307-
1308-
@Override
1309-
public ConfigKey<?>[] getConfigKeys() {
1310-
return new ConfigKey<?>[] {allowRoutersOnDedicatedResources};
1311-
}
1312-
1313-
@Override
1314-
public String getConfigComponentName() {
1315-
return CapacityDaoImpl.class.getSimpleName();
1316-
}
13171305
}

plugins/deployment-planners/implicit-dedication/src/test/java/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ private void initializeForTest(VirtualMachineProfileImpl vmProfile, DataCenterDe
366366
clusterCapacityMap.put(2L, 2048D);
367367
clusterCapacityMap.put(3L, 2048D);
368368
Pair<List<Long>, Map<Long, Double>> clustersOrderedByCapacity = new Pair<List<Long>, Map<Long, Double>>(clustersWithEnoughCapacity, clusterCapacityMap);
369-
when(capacityDao.orderClustersByAggregateCapacity(dataCenterId, 12L, Capacity.CAPACITY_TYPE_CPU, false, true)).thenReturn(clustersOrderedByCapacity);
369+
when(capacityDao.orderClustersByAggregateCapacity(dataCenterId, 12L, Capacity.CAPACITY_TYPE_CPU, false, false, true)).thenReturn(clustersOrderedByCapacity);
370370

371371
List<Long> disabledClusters = new ArrayList<Long>();
372372
List<Long> clustersWithDisabledPods = new ArrayList<Long>();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ private Pair<List<Long>, Map<Long, Double>> getOrderedClustersByCapacity(long id
562562

563563
logger.debug("CapacityType: {} is used for Cluster ordering", getCapacityTypeName(capacityType));
564564
if (capacityType >= 0) { // for capacityType other than COMBINED
565-
return capacityDao.orderClustersByAggregateCapacity(id, vmId, capacityType, isVr, isZone);
565+
return capacityDao.orderClustersByAggregateCapacity(id, vmId, capacityType, isVr, allowRoutersOnDedicatedResources.value(), isZone);
566566
}
567567

568568
Long zoneId = isZone ? id : null;
@@ -695,6 +695,6 @@ public String getConfigComponentName() {
695695

696696
@Override
697697
public ConfigKey<?>[] getConfigKeys() {
698-
return new ConfigKey<?>[] {ClusterCPUCapacityDisableThreshold, ClusterMemoryCapacityDisableThreshold, ClusterThresholdEnabled, VmAllocationAlgorithm};
698+
return new ConfigKey<?>[] {ClusterCPUCapacityDisableThreshold, ClusterMemoryCapacityDisableThreshold, ClusterThresholdEnabled, VmAllocationAlgorithm, allowRoutersOnDedicatedResources};
699699
}
700700
}

server/src/test/java/com/cloud/vm/FirstFitPlannerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ private void initializeForTest(VirtualMachineProfileImpl vmProfile, DataCenterDe
373373
clusterCapacityMap.put(6L, 2048D);
374374

375375
Pair<List<Long>, Map<Long, Double>> clustersOrderedByCapacity = new Pair<List<Long>, Map<Long, Double>>(clustersWithEnoughCapacity, clusterCapacityMap);
376-
when(capacityDao.orderClustersByAggregateCapacity(dataCenterId, 12L, Capacity.CAPACITY_TYPE_CPU, false, true)).thenReturn(clustersOrderedByCapacity);
376+
when(capacityDao.orderClustersByAggregateCapacity(dataCenterId, 12L, Capacity.CAPACITY_TYPE_CPU, false, false,true)).thenReturn(clustersOrderedByCapacity);
377377

378378
List<Long> disabledClusters = new ArrayList<Long>();
379379
List<Long> clustersWithDisabledPods = new ArrayList<Long>();

0 commit comments

Comments
 (0)