You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ki...@apache.org on 2013/07/30 15:48:17 UTC
git commit: updated refs/heads/4.2 to 03cbf51
Updated Branches:
refs/heads/4.2 4653cff88 -> 03cbf51e1
Cloudstack-3910 Upgrade from 3.0.6 to 4.2 is failing with DB exceptions.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/03cbf51e
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/03cbf51e
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/03cbf51e
Branch: refs/heads/4.2
Commit: 03cbf51e159a452f18f560ac64c6ae64e34df12c
Parents: 4653cff
Author: Bharat Kumar <bh...@citrix.com>
Authored: Mon Jul 29 20:21:54 2013 +0530
Committer: Kishan Kavala <ki...@cloud.com>
Committed: Tue Jul 30 19:12:59 2013 +0530
----------------------------------------------------------------------
.../com/cloud/upgrade/dao/Upgrade410to420.java | 60 ++++++++++++++++++++
setup/db/db/schema-410to420.sql | 2 -
2 files changed, 60 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/03cbf51e/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 e8ca579..13074cf 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -100,6 +100,7 @@ public class Upgrade410to420 implements DbUpgrade {
migrateSnapshotStoreRef(conn);
fixNiciraKeys(conn);
fixRouterKeys(conn);
+ updateConcurrentConnectionsInNetworkOfferings(conn);
}
private void fixBaremetalForeignKeys(Connection conn) {
@@ -1942,4 +1943,63 @@ public class Upgrade410to420 implements DbUpgrade {
}
}
}
+
+ protected void updateConcurrentConnectionsInNetworkOfferings(Connection conn) {
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+ ResultSet rs1 = null;
+ ResultSet rs2 = null;
+ try {
+ try {
+ pstmt = conn.prepareStatement("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'cloud' AND TABLE_NAME = 'network_offerings' AND COLUMN_NAME = 'concurrent_connections'");
+ rs = pstmt.executeQuery();
+ if (!rs.next()) {
+ pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `concurrent_connections` int(10) unsigned COMMENT 'Load Balancer(haproxy) maximum number of concurrent connections(global max)'");
+ pstmt.executeUpdate();
+ }
+ }catch (SQLException e) {
+ throw new CloudRuntimeException("migration of concurrent connections from network_detais failed");
+ }
+
+
+
+ pstmt = conn.prepareStatement("select network_id, value from `cloud`.`network_details` where name='maxconnections'");
+ rs = pstmt.executeQuery();
+ while (rs.next()) {
+ long networkId = rs.getLong(1);
+ int maxconnections = Integer.parseInt(rs.getString(2));
+ pstmt = conn.prepareStatement("select network_offering_id from `cloud`.`networks` where id= ?");
+ pstmt.setLong(1, networkId);
+ rs1 = pstmt.executeQuery();
+ if (rs1.next()) {
+ long network_offering_id = rs1.getLong(1);
+ pstmt = conn.prepareStatement("select concurrent_connections from `cloud`.`network_offerings` where id= ?");
+ pstmt.setLong(1,network_offering_id);
+ rs2 = pstmt.executeQuery();
+ if ((!rs2.next()) || (rs2.getInt(1) < maxconnections)) {
+ pstmt = conn.prepareStatement("update network_offerings set concurrent_connections=? where id=?");
+ pstmt.setInt(1, maxconnections);
+ pstmt.setLong(2, network_offering_id);
+ pstmt.executeUpdate();
+ }
+ }
+ }
+ } catch (SQLException e) {
+ }
+ finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+
+ if (rs1 != null) {
+ rs1.close();
+ }
+ if (pstmt != null) {
+ pstmt.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/03cbf51e/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index 15044a5..9cdf837 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -2193,8 +2193,6 @@ ALTER TABLE `cloud_usage`.`usage_storage` ADD COLUMN `virtual_size` bigint unsig
ALTER TABLE `cloud_usage`.`cloud_usage` ADD COLUMN `virtual_size` bigint unsigned;
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'network.loadbalancer.haproxy.max.conn', '4096', 'Load Balancer(haproxy) maximum number of concurrent connections(global max)');
-ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `concurrent_connections` int(10) unsigned COMMENT 'Load Balancer(haproxy) maximum number of concurrent connections(global max)';
-
DROP TABLE IF EXISTS `cloud_usage`.`usage_vmsnapshot`;
CREATE TABLE `cloud_usage`.`usage_vmsnapshot` (
`id` bigint(20) unsigned NOT NULL,