cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [1/2] git commit: updated refs/heads/4.7 to 456d854
Date Fri, 08 Jan 2016 19:10:47 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.7 3ee53d3f5 -> 456d85448


Fix mariadb related listCapacity bug (CLOUDSTACK-8966)

type bigint(20) with type  varchar does not work well on MariaDB
So forcing it to type decimal


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/65d39d03
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/65d39d03
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/65d39d03

Branch: refs/heads/4.7
Commit: 65d39d034694993827456d97ddd562d4803b2109
Parents: d681574
Author: Anton Opgenoort <aopgenoort@schubergphilis.com>
Authored: Wed Jan 6 17:30:55 2016 +0100
Committer: Anton Opgenoort <aopgenoort@schubergphilis.com>
Committed: Thu Jan 7 10:21:13 2016 +0100

----------------------------------------------------------------------
 .../com/cloud/capacity/dao/CapacityDaoImpl.java | 37 ++++++++++----------
 1 file changed, 19 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/65d39d03/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 69dc014..bc992b0 100644
--- a/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java
+++ b/engine/schema/src/com/cloud/capacity/dao/CapacityDaoImpl.java
@@ -109,41 +109,42 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long>
implements
 
     private static final String LIST_CAPACITY_GROUP_BY_ZONE_TYPE_PART1 =
             "SELECT 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))"
+                    + " (case capacity_type when 1 then (sum(total_capacity) * CAST((select
value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND
cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL (10,4)))"
+                    + "when '0' then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details`
where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)
AS DECIMAL (10,4)))"
                     + "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,"
+                    + "((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) /
( case capacity_type when 1 then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details`
where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)
AS DECIMAL (10,4)))"
+                    + "when '0' then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details`
where cluster_details.name='memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)
AS DECIMAL (10,4)))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_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 =
             "SELECT 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),"
-                    + "((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,"
+                    + " (case capacity_type when 1 then (sum(total_capacity) * CAST((select
value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND
cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL (10,4))) "
+                    + "when '0' then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details`
where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)
AS DECIMAL (10,4)))else sum(total_capacity) end),"
+                    + "((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) /
( case capacity_type when 1 then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details`
where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)
AS DECIMAL (10,4))) "
+                    + "when '0' then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details`
where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)
AS DECIMAL (10,4)))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_POD_TYPE_PART2 = " GROUP BY pod_id,
capacity_type order by percent desc limit ";
 
     private static final String LIST_CAPACITY_GROUP_BY_CLUSTER_TYPE_PART1 =
             "SELECT 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),"
-                    + "((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,"
+                    + " (case capacity_type when 1 then (sum(total_capacity) * CAST((select
value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND
cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL (10,4))) "
+                    + "when '0' then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details`
where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)
AS DECIMAL (10,4)))else sum(total_capacity) end),"
+                    + "((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) /
( case capacity_type when 1 then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details`
where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)
AS DECIMAL (10,4))) "
+                    + "when '0' then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details`
where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)
AS DECIMAL (10,4)))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, 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)," +
-            " (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)," +
-            "((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, 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_CAPACITY_PART1=
+            "SELECT sum(capacity.used_capacity), sum(capacity.reserved_capacity),"
+                    + " (case capacity_type when 1 then (sum(total_capacity) * CAST((select
value from `cloud`.`cluster_details` where cluster_details.name= 'cpuOvercommitRatio' AND
cluster_details.cluster_id=capacity.cluster_id) AS DECIMAL (10,4))) "
+                    + "when '0' then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details`
where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)
AS DECIMAL(10,4)))else sum(total_capacity) end),"
+                    + "((sum(capacity.used_capacity) + sum(capacity.reserved_capacity)) /
( case capacity_type when 1 then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details`
where cluster_details.name= 'cpuOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)
AS DECIMAL(10,4))) "
+                    + "when '0' then (sum(total_capacity) * CAST((select value from `cloud`.`cluster_details`
where cluster_details.name= 'memoryOvercommitRatio' AND cluster_details.cluster_id=capacity.cluster_id)
AS DECIMAL(10,4))) 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_CAPACITY_PART2 = " GROUP BY capacity_type";
     private static final String LIST_CAPACITY_GROUP_BY_CAPACITY_DATA_CENTER_POD_CLUSTER =
" GROUP BY data_center_id, pod_id, cluster_id, capacity_type";


Mime
View raw message