Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 944C017CC1 for ; Mon, 2 Nov 2015 11:09:06 +0000 (UTC) Received: (qmail 33491 invoked by uid 500); 2 Nov 2015 11:09:03 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 33453 invoked by uid 500); 2 Nov 2015 11:09:03 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 33249 invoked by uid 99); 2 Nov 2015 11:09:03 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Nov 2015 11:09:03 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3BE3CDFCE0; Mon, 2 Nov 2015 11:09:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: remi@apache.org To: commits@cloudstack.apache.org Date: Mon, 02 Nov 2015 11:09:03 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] git commit: updated refs/heads/master to a981d34 Repository: cloudstack Updated Branches: refs/heads/master e3a4ec6cf -> a981d34f4 CLOUDSTACK-8825, CLOUDSTACK-8824 : Fixed following issues if vm.allocation.algorithm is set to firstfitleastconsumed 1. VM deployment failure if thre is only ZWPS in setup 2. VM migration is impossible from UI Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a5555ed2 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a5555ed2 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a5555ed2 Branch: refs/heads/master Commit: a5555ed229de466a0b3834cc8983551cf36fcc53 Parents: 3079253 Author: Anshul Gangwar Authored: Tue Sep 8 17:08:59 2015 +0530 Committer: Anshul Gangwar Committed: Tue Sep 8 17:09:36 2015 +0530 ---------------------------------------------------------------------- .../com/cloud/capacity/dao/CapacityDaoImpl.java | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5555ed2/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java b/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java index 2bd6bcc..cdb69ce 100644 --- a/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java +++ b/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java @@ -98,9 +98,9 @@ public class CapacityDaoImpl extends GenericDaoBase implements 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 " + + "capacity_type = ? "; + private static final String ORDER_HOSTS_BY_FREE_CAPACITY_PART2 = " GROUP BY host_id ORDER BY SUM(total_capacity - (used_capacity+reserved_capacity))/SUM(total_capacity) DESC "; private static final String LIST_CAPACITY_BY_RESOURCE_STATE = "SELECT capacity.data_center_id, sum(capacity.used_capacity), sum(capacity.reserved_quantity), sum(capacity.total_capacity), capacity_capacity_type " + "FROM `cloud`.`op_host_capacity` capacity INNER JOIN `cloud`.`data_center` dc ON (dc.id = capacity.data_center_id AND dc.removed is NULL)" @@ -864,12 +864,18 @@ public class CapacityDaoImpl extends GenericDaoBase implements TransactionLegacy txn = TransactionLegacy.currentTxn(); PreparedStatement pstmt = null; List result = new ArrayList(); - StringBuilder sql = new StringBuilder(ORDER_HOSTS_BY_FREE_CAPACITY); - + StringBuilder sql = new StringBuilder(ORDER_HOSTS_BY_FREE_CAPACITY_PART1); + if(clusterId != null) { + sql.append("AND cluster_id = ?"); + } + sql.append(ORDER_HOSTS_BY_FREE_CAPACITY_PART2); try { pstmt = txn.prepareAutoCloseStatement(sql.toString()); - pstmt.setLong(1, clusterId); - pstmt.setShort(2, capacityTypeForOrdering); + pstmt.setShort(1, capacityTypeForOrdering); + if(clusterId != null) { + pstmt.setLong(2, clusterId); + } + ResultSet rs = pstmt.executeQuery(); while (rs.next()) { result.add(rs.getLong(1));