mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
CLOUDSTACK-7571 changing value of cpu/mem.overprovisioning.factor for xen cluster is not affecting total memory at zone level
(cherry picked from commit 476733cb92634c8494fe64762d7fbc178292a754) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
45108fdbad
commit
bf8db0c743
@ -113,7 +113,7 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
||||
+ "else sum(total_capacity) end),"
|
||||
+ "((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) / ( case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id))"
|
||||
+ "when '0' then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name='memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id))else sum(total_capacity) end)) percent,"
|
||||
+ "capacity.capacity_type, capacity.data_center_id FROM `cloud`.`op_host_capacity` capacity WHERE total_capacity > 0 AND data_center_id is not null AND capacity_state='Enabled'";
|
||||
+ "capacity.capacity_type, capacity.data_center_id, pod_id, cluster_id FROM `cloud`.`op_host_capacity` capacity WHERE total_capacity > 0 AND data_center_id is not null AND capacity_state='Enabled'";
|
||||
|
||||
private static final String LIST_CAPACITY_GROUP_BY_ZONE_TYPE_PART2 = " GROUP BY data_center_id, capacity_type order by percent desc limit ";
|
||||
private static final String LIST_CAPACITY_GROUP_BY_POD_TYPE_PART1 =
|
||||
@ -122,7 +122,7 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
||||
+ "when '0' then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id))else sum(total_capacity) end),"
|
||||
+ "((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) / ( case capacity_type when 1 then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)) "
|
||||
+ "when '0' then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id))else sum(total_capacity) end)) percent,"
|
||||
+ "capacity.capacity_type, capacity.data_center_id, pod_id FROM `cloud`.`op_host_capacity` capacity WHERE total_capacity > 0 AND data_center_id is not null AND capacity_state='Enabled' ";
|
||||
+ "capacity.capacity_type, capacity.data_center_id, pod_id, cluster_id FROM `cloud`.`op_host_capacity` capacity WHERE total_capacity > 0 AND data_center_id is not null AND capacity_state='Enabled' ";
|
||||
|
||||
private static final String LIST_CAPACITY_GROUP_BY_POD_TYPE_PART2 = " GROUP BY pod_id, capacity_type order by percent desc limit ";
|
||||
|
||||
@ -134,7 +134,7 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
||||
+ "when '0' then (sum(total_capacity) * (select value from `cloud`.`cluster_details` where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id))else sum(total_capacity) end)) percent,"
|
||||
+ "capacity.capacity_type, capacity.data_center_id, pod_id, cluster_id FROM `cloud`.`op_host_capacity` capacity WHERE total_capacity > 0 AND data_center_id is not null AND capacity_state='Enabled' ";
|
||||
|
||||
private static final String LIST_CAPACITY_GROUP_BY_CLUSTER_TYPE_PART2 = " GROUP BY cluster_id, capacity_type order by percent desc limit ";
|
||||
private static final String LIST_CAPACITY_GROUP_BY_CLUSTER_TYPE_PART2 = " GROUP BY cluster_id, capacity_type, pod_id order by percent desc limit ";
|
||||
private static final String UPDATE_CAPACITY_STATE = "UPDATE `cloud`.`op_host_capacity` SET capacity_state = ? WHERE ";
|
||||
|
||||
private static final String LIST_CAPACITY_GROUP_BY_CAPACITY_PART1= "SELECT sum(capacity.used_capacity), sum(capacity.reserved_capacity)," +
|
||||
@ -317,7 +317,7 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
||||
StringBuilder finalQuery = new StringBuilder();
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||
PreparedStatement pstmt = null;
|
||||
List<SummedCapacity> result = new ArrayList<SummedCapacity>();
|
||||
List<SummedCapacity> results = new ArrayList<SummedCapacity>();
|
||||
|
||||
List<Long> resourceIdList = new ArrayList<Long>();
|
||||
|
||||
@ -354,11 +354,11 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
||||
|
||||
switch (level) {
|
||||
case 1: // List all the capacities grouped by zone, capacity Type
|
||||
finalQuery.append(LIST_CAPACITY_GROUP_BY_ZONE_TYPE_PART2);
|
||||
finalQuery.append(LIST_CAPACITY_GROUP_BY_CLUSTER_TYPE_PART2);
|
||||
break;
|
||||
|
||||
case 2: // List all the capacities grouped by pod, capacity Type
|
||||
finalQuery.append(LIST_CAPACITY_GROUP_BY_POD_TYPE_PART2);
|
||||
finalQuery.append(LIST_CAPACITY_GROUP_BY_CLUSTER_TYPE_PART2);
|
||||
break;
|
||||
|
||||
case 3: // List all the capacities grouped by cluster, capacity Type
|
||||
@ -387,9 +387,25 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
||||
SummedCapacity summedCapacity =
|
||||
new SummedCapacity(rs.getLong(1), rs.getLong(2), rs.getLong(3), rs.getFloat(4), (short)rs.getLong(5), rs.getLong(6), capacityPodId, capacityClusterId);
|
||||
|
||||
result.add(summedCapacity);
|
||||
results.add(summedCapacity);
|
||||
}
|
||||
return result;
|
||||
|
||||
HashMap<Integer, SummedCapacity> capacityMap = new HashMap<Integer, SummedCapacity>();
|
||||
for (SummedCapacity result: results) {
|
||||
if (capacityMap.containsKey(result.getCapacityType().intValue())) {
|
||||
SummedCapacity tempCapacity = capacityMap.get(result.getCapacityType().intValue());
|
||||
tempCapacity.setUsedCapacity(tempCapacity.getUsedCapacity()+result.getUsedCapacity());
|
||||
tempCapacity.setReservedCapacity(tempCapacity.getReservedCapacity()+result.getReservedCapacity());
|
||||
tempCapacity.setSumTotal(tempCapacity.getTotalCapacity()+result.getTotalCapacity());
|
||||
}else {
|
||||
capacityMap.put(result.getCapacityType().intValue(),result);
|
||||
}
|
||||
}
|
||||
List<SummedCapacity> summedCapacityList = new ArrayList<SummedCapacity>();
|
||||
for (Integer capacity_type : capacityMap.keySet()) {
|
||||
summedCapacityList.add(capacityMap.get(capacity_type));
|
||||
}
|
||||
return summedCapacityList;
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("DB Exception on: " + finalQuery, e);
|
||||
} catch (Throwable e) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user