cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ni...@apache.org
Subject git commit: updated refs/heads/4.2-forward to 4a7d732
Date Thu, 29 Aug 2013 06:56:24 GMT
Updated Branches:
  refs/heads/4.2-forward 995e193be -> 4a7d7324d


CLOUDSTACK-4538 Should update the vmware clusters with the global overporvisioning factors
after upgrade to 4.2.
Signed off by : Nitin Mehta <nitin.mehta@citrix.com>


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

Branch: refs/heads/4.2-forward
Commit: 4a7d7324d0f71888365c0b8f235b30909c9cbceb
Parents: 995e193
Author: bharat kumar <bharat.kumar@citrix.com>
Authored: Thu Aug 29 12:24:45 2013 +0530
Committer: Nitin Mehta <nitin.mehta@citrix.com>
Committed: Thu Aug 29 12:25:18 2013 +0530

----------------------------------------------------------------------
 .../com/cloud/upgrade/dao/Upgrade410to420.java  | 66 +++++++++++++++-----
 1 file changed, 51 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a7d7324/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
index 5db6420..a2c6b4e 100755
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -845,31 +845,67 @@ public class Upgrade410to420 implements DbUpgrade {
         PreparedStatement pstmt = null;
         PreparedStatement pstmt1 = null;
         PreparedStatement pstmt2 =null;
-        ResultSet rs = null;
-
+        PreparedStatement pstmt3 = null;
+        ResultSet rs1 = null;
+        ResultSet rscpu_global = null;
+        ResultSet rsmem_global = null;
         try {
-            pstmt = conn.prepareStatement("select id from `cloud`.`cluster`");
-            pstmt1=conn.prepareStatement("INSERT INTO `cloud`.`cluster_details` (cluster_id,
name, value)  VALUES(?, 'cpuOvercommitRatio', '1')");
-            pstmt2=conn.prepareStatement("INSERT INTO `cloud`.`cluster_details` (cluster_id,
name, value)  VALUES(?, 'memoryOvercommitRatio', '1')");
-            rs = pstmt.executeQuery();
-            while (rs.next()) {
-                long id = rs.getLong(1);
-                //update cluster_details table with the default overcommit ratios.
-                pstmt1.setLong(1,id);
-                pstmt1.execute();
-                pstmt2.setLong(1,id);
-                pstmt2.execute();
+            pstmt = conn.prepareStatement("select id, hypervisor_type from `cloud`.`cluster`");
+            pstmt1=conn.prepareStatement("INSERT INTO `cloud`.`cluster_details` (cluster_id,
name, value)  VALUES(?, 'cpuOvercommitRatio', ?)");
+            pstmt2=conn.prepareStatement("INSERT INTO `cloud`.`cluster_details` (cluster_id,
name, value)  VALUES(?, 'memoryOvercommitRatio', ?)");
+            pstmt3=conn.prepareStatement("select value from `cloud`.`configuration` where
name=?");
+            pstmt3.setString(1,"cpu.overprovisioning.factor");
+            rscpu_global = pstmt3.executeQuery();
+            rscpu_global.next();
+            String global_cpu_overprovisioning_factor=rscpu_global.getString(1);
+            pstmt3.setString(1,"mem.overprovisioning.factor");
+            rsmem_global = pstmt3.executeQuery();
+            rsmem_global.next();
+            String global_mem_overprovisioning_factor = rsmem_global.getString(1);
+            rs1 = pstmt.executeQuery();
+
+            while (rs1.next()) {
+                long id = rs1.getLong(1);
+                String hypervisor_type = rs1.getString(2);
+                if (hypervisor_type.equalsIgnoreCase(HypervisorType.VMware.toString())) {
+                    pstmt1.setLong(1,id);
+                    pstmt1.setString(2,global_cpu_overprovisioning_factor);
+                    pstmt1.execute();
+                    pstmt2.setLong(1,id);
+                    pstmt2.setString(2,global_mem_overprovisioning_factor);
+                    pstmt2.execute();
+                }else {
+                    //update cluster_details table with the default overcommit ratios.
+                    pstmt1.setLong(1,id);
+                    pstmt1.setString(2,"1");
+                    pstmt1.execute();
+                    pstmt2.setLong(1,id);
+                    pstmt2.setString(2,"1");
+                    pstmt2.execute();
+                }
             }
         } catch (SQLException e) {
             throw new CloudRuntimeException("Unable to update cluster_details with default
overcommit ratios.", e);
         } finally {
             try {
-                if (rs != null) {
-                    rs.close();
+                if (rs1 != null) {
+                    rs1.close();
+                }
+                if (rsmem_global != null) {
+                    rsmem_global.close();
+                }
+                if (rscpu_global != null) {
+                    rsmem_global.close();
                 }
                 if (pstmt != null) {
                     pstmt.close();
                 }
+                if (pstmt2 != null) {
+                    pstmt2.close();
+                }
+                if (pstmt3 != null) {
+                    pstmt3.close();
+                }
             } catch (SQLException e) {
             }
         }


Mime
View raw message