ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject git commit: AMBARI-5232. Warnings/exceptions when updating DB (1.4.1->current trunk). (swagle)
Date Wed, 26 Mar 2014 22:16:35 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.5.0 c94a7084f -> d22d57b4d


AMBARI-5232. Warnings/exceptions when updating DB (1.4.1->current trunk). (swagle)


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

Branch: refs/heads/branch-1.5.0
Commit: d22d57b4d47fd0b855b6796f4f9dc31978156d00
Parents: c94a708
Author: Siddharth Wagle <swagle@hortonworks.com>
Authored: Wed Mar 26 14:18:38 2014 -0700
Committer: Siddharth Wagle <swagle@hortonworks.com>
Committed: Wed Mar 26 14:18:38 2014 -0700

----------------------------------------------------------------------
 .../ambari/server/orm/DBAccessorImpl.java       |  5 +++-
 .../server/upgrade/UpgradeCatalog150.java       | 26 +++++++++++---------
 2 files changed, 19 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d22d57b4/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
index 5a84956..069a4f2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessorImpl.java
@@ -412,9 +412,12 @@ public class DBAccessorImpl implements DBAccessor {
     try {
       statement.execute(query);
     } catch (SQLException e) {
-      LOG.warn("Error executing query: "+query, e);
       if (!ignoreFailure) {
+        LOG.warn("Error executing query: " + query, e);
         throw e;
+      } else {
+        LOG.warn("Error executing query: " + query + ", " +
+          "errorCode = " + e.getErrorCode() + ", message = " + e.getMessage());
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/d22d57b4/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java
index 8bbbfd4..8c8a9ba 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java
@@ -69,7 +69,7 @@ public class UpgradeCatalog150 extends AbstractUpgradeCatalog {
   @Override
   public void executeDDLUpdates() throws AmbariException, SQLException {
     LOG.debug("Upgrading schema...");
-
+    String dbType = getDbType();
     List<DBColumnInfo> columns = new ArrayList<DBColumnInfo>();
 
     // ========================================================================
@@ -259,20 +259,24 @@ public class UpgradeCatalog150 extends AbstractUpgradeCatalog {
 
     // Alter columns
 
-    if (getDbType().equals(Configuration.POSTGRES_DB_NAME)) {
-      dbAccessor.executeQuery("ALTER TABLE hostcomponentdesiredconfigmapping rename to hcdesiredconfigmapping;",
true);
+    if (dbType.equals(Configuration.POSTGRES_DB_NAME)) {
+      if (dbAccessor.tableExists("hostcomponentdesiredconfigmapping")) {
+        dbAccessor.executeQuery("ALTER TABLE hostcomponentdesiredconfigmapping rename to
hcdesiredconfigmapping;", true);
+      }
       dbAccessor.executeQuery("ALTER TABLE users ALTER column user_id DROP DEFAULT;", true);
       dbAccessor.executeQuery("ALTER TABLE users ALTER column ldap_user TYPE INTEGER USING
CASE WHEN ldap_user=true THEN 1 ELSE 0 END;", true);
     }
 
-    if (Configuration.ORACLE_DB_NAME.equals(getDbType()) ||
-        Configuration.POSTGRES_DB_NAME.equals(getDbType())) {
-      dbAccessor.executeQuery("ALTER TABLE hosts DROP COLUMN disks_info;", true);
+    if (Configuration.ORACLE_DB_NAME.equals(dbType) ||
+        Configuration.POSTGRES_DB_NAME.equals(dbType)) {
+      if (dbAccessor.tableHasColumn("hosts", "disks_info")) {
+        dbAccessor.executeQuery("ALTER TABLE hosts DROP COLUMN disks_info;", true);
+      }
     }
 
 
     //Move tables from ambarirca db to ambari db; drop ambarirca; Mysql
-    if (getDbType().equals(Configuration.MYSQL_DB_NAME)) {
+    if (dbType.equals(Configuration.MYSQL_DB_NAME)) {
       String dbName = configuration.getServerJDBCSchemaName();
       moveRCATableInMySQL("workflow", dbName);
       moveRCATableInMySQL("job", dbName);
@@ -293,9 +297,9 @@ public class UpgradeCatalog150 extends AbstractUpgradeCatalog {
       throw new AmbariException(msg);
     } else if (!dbAccessor.tableHasData(tableName)) {
       String query;
-      if (getDbType().equals(Configuration.POSTGRES_DB_NAME)) {
+      if (dbType.equals(Configuration.POSTGRES_DB_NAME)) {
         query = getPostgresRequestUpgradeQuery();
-      } else if (getDbType().equals(Configuration.ORACLE_DB_NAME)) {
+      } else if (dbType.equals(Configuration.ORACLE_DB_NAME)) {
         query = getOracleRequestUpgradeQuery();
       } else {
         query = getMysqlRequestUpgradeQuery();
@@ -308,8 +312,8 @@ public class UpgradeCatalog150 extends AbstractUpgradeCatalog {
 
     // Drop old constraints
     // ========================================================================
-    if (Configuration.POSTGRES_DB_NAME.equals(getDbType())
-      || Configuration.MYSQL_DB_NAME.equals(getDbType())) {
+    if (Configuration.POSTGRES_DB_NAME.equals(dbType)
+      || Configuration.MYSQL_DB_NAME.equals(dbType)) {
 
       //recreate old constraints to sync with oracle
       dbAccessor.dropConstraint("clusterconfigmapping", "FK_clusterconfigmapping_cluster_id");


Mime
View raw message