cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject git commit: updated refs/heads/4.2 to c0d2e32
Date Fri, 16 Aug 2013 20:44:17 GMT
Updated Branches:
  refs/heads/4.2 016faeaf2 -> c0d2e3253


CLOUDSTACK-4369 [UPGRADE]Upgrade failed from 307 to 4.2

Changes:
- Do not consider removed zones
- Create affinity group per domain


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

Branch: refs/heads/4.2
Commit: c0d2e3253b17d290b173ec3bae624fc155fb86c8
Parents: 016faea
Author: Prachi Damle <prachi@cloud.com>
Authored: Fri Aug 16 13:30:49 2013 -0700
Committer: Prachi Damle <prachi@cloud.com>
Committed: Fri Aug 16 13:30:49 2013 -0700

----------------------------------------------------------------------
 .../com/cloud/upgrade/dao/Upgrade412to420.java  | 41 +++++++++++++++-----
 1 file changed, 31 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0d2e325/engine/schema/src/com/cloud/upgrade/dao/Upgrade412to420.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade412to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade412to420.java
index 0c77ce4..5552a1a 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade412to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade412to420.java
@@ -116,19 +116,21 @@ public class Upgrade412to420 implements DbUpgrade {
         PreparedStatement pstmt = null;
         ResultSet rs = null;
         PreparedStatement pstmtUpdate = null;
+        PreparedStatement pstmt3 = null;
+        ResultSet rs3 = null;
+
 
         try {
-            pstmt = conn.prepareStatement("SELECT `id`, `domain_id` FROM `cloud`.`data_center`
WHERE `domain_id` IS NOT NULL");
-            rs = pstmt.executeQuery();
 
-            while (rs.next()) {
-                long zoneId = rs.getLong(1);
-                long domainId = rs.getLong(2);
-                long affinityGroupId;
+            pstmt3 = conn.prepareStatement("SELECT distinct(`domain_id`) FROM `cloud`.`data_center`
WHERE `domain_id` IS NOT NULL AND removed IS NULL");
+            rs3 = pstmt3.executeQuery();
+
+            while (rs3.next()) {
+                long domainId = rs3.getLong(1);
+                long affinityGroupId = 0;
 
                 // create or find an affinity group for this domain of type
                 // 'ExplicitDedication'
-
                 PreparedStatement pstmt2 = null;
                 ResultSet rs2 = null;
                 pstmt2 = conn
@@ -138,7 +140,6 @@ public class Upgrade412to420 implements DbUpgrade {
                 if (rs2.next()) {
                     // group exists, use it
                     affinityGroupId = rs2.getLong(1);
-                    dedicateZone(conn, zoneId, domainId, affinityGroupId);
                 } else {
                     // create new group
                     rs2.close();
@@ -149,7 +150,6 @@ public class Upgrade412to420 implements DbUpgrade {
                     rs2 = pstmt2.executeQuery();
                     String domainName = "";
                     if (rs2.next()) {
-                        // group exists, use it
                         domainName = rs2.getString(1);
                     }
                     rs2.close();
@@ -175,11 +175,20 @@ public class Upgrade412to420 implements DbUpgrade {
                     rs2 = pstmt2.executeQuery();
                     if (rs2.next()) {
                         affinityGroupId = rs2.getLong(1);
-                        dedicateZone(conn, zoneId, domainId, affinityGroupId);
                     }
                 }
+
                 rs2.close();
                 pstmt2.close();
+
+                pstmt = conn.prepareStatement("SELECT `id` FROM `cloud`.`data_center` WHERE
`domain_id` = ? AND removed IS NULL");
+                pstmt.setLong(1, domainId);
+                rs = pstmt.executeQuery();
+
+                while (rs.next()) {
+                    long zoneId = rs.getLong(1);
+                    dedicateZone(conn, zoneId, domainId, affinityGroupId);
+                }
             }
 
         } catch (SQLException e) {
@@ -203,6 +212,18 @@ public class Upgrade412to420 implements DbUpgrade {
                 } catch (SQLException e) {
                 }
             }
+            if (rs3 != null) {
+                try {
+                    rs3.close();
+                } catch (SQLException e) {
+                }
+            }
+            if (pstmt3 != null) {
+                try {
+                    pstmt3.close();
+                } catch (SQLException e) {
+                }
+            }
 
         }
     }


Mime
View raw message