Github user DaanHoogland commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/787#discussion_r43580727 --- Diff: engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java --- @@ -98,9 +98,9 @@ private static final String ORDER_PODS_BY_AGGREGATE_OVERCOMMIT_CAPACITY = "SELECT capacity.pod_id, SUM(used_capacity+reserved_capacity)/SUM(total_capacity * cluster_details.value) FROM `cloud`.`op_host_capacity` capacity INNER JOIN `cloud`.`cluster_details` cluster_details ON (capacity.cluster_id = cluster_details.cluster_id) WHERE data_center_id=? AND capacity_type = ? AND cluster_details.name = ? GROUP BY capacity.pod_id ORDER BY SUM(used_capacity+reserved_capacity)/SUM(total_capacity * cluster_details.value) ASC"; - private static final String ORDER_HOSTS_BY_FREE_CAPACITY = "SELECT host_id, SUM(total_capacity - (used_capacity+reserved_capacity))/SUM(total_capacity) FROM `cloud`.`op_host_capacity` WHERE " - + " cluster_id = ? AND capacity_type = ? GROUP BY host_id ORDER BY SUM(total_capacity - (used_capacity+reserved_capacity))/SUM(total_capacity) DESC "; - + private static final String ORDER_HOSTS_BY_FREE_CAPACITY_PART1 = "SELECT host_id, SUM(total_capacity - (used_capacity+reserved_capacity))/SUM(total_capacity) FROM `cloud`.`op_host_capacity` WHERE " --- End diff -- the naming of these constants is not really in line with their purpose this way. how about splitting it further and changing the names to ORDER_HOSTS_BY_FREE_CAPACITY_SELECT_CLAUSE , ORDER_HOSTS_BY_FREE_CAPACITY_WHERE_CLAUSE , ... ORDER_HOSTS_BY_FREE_CAPACITY_ORDER_BY_CLAUSE , also the conditional part can be defined here ORDER_HOSTS_BY_FREE_CAPACITY_CLUSTER_SELECTION = "AND cluster_id = ?";
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---