ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vbrodets...@apache.org
Subject ambari git commit: AMBARI-12287. Schema version of Ambari updated before actual end of DML queries (if a problem is encountered during upgrade, fixing issues and running it again did not drop obsolete columns).(vbrodetskyi)
Date Mon, 06 Jul 2015 11:10:36 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 f88cce75a -> 1432a259c


AMBARI-12287. Schema version of Ambari updated before actual end of DML queries (if a problem
is encountered during upgrade, fixing issues and running it again did not drop obsolete columns).(vbrodetskyi)


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

Branch: refs/heads/branch-2.1
Commit: 1432a259c842ad57ddeba0c0cbc2a007987b699f
Parents: f88cce7
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Mon Jul 6 14:09:22 2015 +0300
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Mon Jul 6 14:10:20 2015 +0300

----------------------------------------------------------------------
 .../ambari/server/orm/helpers/dbms/DerbyHelper.java      | 11 +++++++++++
 .../ambari/server/upgrade/AbstractUpgradeCatalog.java    |  4 ++++
 .../ambari/server/upgrade/SchemaUpgradeHelper.java       |  2 +-
 .../org/apache/ambari/server/upgrade/UpgradeCatalog.java |  5 +++++
 .../apache/ambari/server/upgrade/UpgradeCatalog210.java  |  1 +
 .../org/apache/ambari/server/upgrade/UpgradeTest.java    |  2 ++
 6 files changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1432a259/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/DerbyHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/DerbyHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/DerbyHelper.java
index c012a77..8f58c87 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/DerbyHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/DerbyHelper.java
@@ -58,4 +58,15 @@ public class DerbyHelper extends GenericDbmsHelper {
     builder.append(nullStatement);
     return builder;
   }
+
+  @Override
+  public String writeGetTableConstraints(String databaseName, String tableName){
+    StringBuilder statement = new StringBuilder()
+      .append("SELECT")
+        .append(" C.CONSTRAINTNAME AS CONSTRAINT_NAME,")
+        .append(" C.TYPE AS CONSTRAINT_TYPE")
+      .append(" FROM SYS.SYSCONSTRAINTS AS C, SYS.SYSTABLES AS T")
+      .append(" WHERE C.TABLEID = T.TABLEID AND T.TABLENAME = '").append(tableName).append("'");
+    return statement.toString();
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/1432a259/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java
index 8c7f831..7a323c8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java
@@ -532,6 +532,10 @@ public abstract class AbstractUpgradeCatalog implements UpgradeCatalog
{
   @Override
   public void upgradeData() throws AmbariException, SQLException {
     executeDMLUpdates();
+  }
+
+  @Override
+  public final void updateDatabaseSchemaVersion() {
     updateMetaInfoVersion(getTargetVersion());
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/1432a259/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
index 687569b..5dc58e8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
@@ -234,7 +234,7 @@ public class SchemaUpgradeHelper {
       for (UpgradeCatalog upgradeCatalog : upgradeCatalogs) {
         try {
           upgradeCatalog.onPostUpgrade();
-          ;
+          upgradeCatalog.updateDatabaseSchemaVersion();
         } catch (Exception e) {
           LOG.error("Upgrade failed. ", e);
           throw new AmbariException(e.getMessage(), e);

http://git-wip-us.apache.org/repos/asf/ambari/blob/1432a259/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog.java
index 976cc99..41c2215 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog.java
@@ -76,4 +76,9 @@ public interface UpgradeCatalog {
    * @return null : default
    */
   String getSourceVersion();
+
+  /**
+   * Update schema version in the database to the Target one
+   */
+  void updateDatabaseSchemaVersion();
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/1432a259/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java
index 47ddd7a..0be06c8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java
@@ -1513,6 +1513,7 @@ public class UpgradeCatalog210 extends AbstractUpgradeCatalog {
     }
   }
 
+
   /**
    * Adds non NULL constraints and drops outdated columns no longer needed after
    * the column data migration.

http://git-wip-us.apache.org/repos/asf/ambari/blob/1432a259/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeTest.java
index 9e516e7..405e6f7 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeTest.java
@@ -224,6 +224,8 @@ public class UpgradeTest {
 
     schemaUpgradeHelper.executeDMLUpdates(upgradeCatalogs);
 
+    schemaUpgradeHelper.executeOnPostUpgrade(upgradeCatalogs);
+
     LOG.info("Upgrade successful.");
 
     schemaUpgradeHelper.stopPersistenceService();


Mime
View raw message