ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject [1/2] git commit: AMBARI-8079. 1.5.1 -> 1.7.0 upgrade fails with mysql DB. (Myroslav Papirkovskyy via swagle)
Date Fri, 31 Oct 2014 21:12:28 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 315c1ca79 -> 240c9f69c


AMBARI-8079. 1.5.1 -> 1.7.0 upgrade fails with mysql DB. (Myroslav Papirkovskyy via swagle)


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

Branch: refs/heads/branch-1.7.0
Commit: fe30baed43c4c84dee27da39d3c37fa22cddb2b0
Parents: 315c1ca
Author: Siddharth Wagle <swagle@hortonworks.com>
Authored: Fri Oct 31 14:11:30 2014 -0700
Committer: Siddharth Wagle <swagle@hortonworks.com>
Committed: Fri Oct 31 14:11:30 2014 -0700

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog160.java       | 84 ++++++++++++++++++++
 1 file changed, 84 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/fe30baed/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog160.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog160.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog160.java
index ea90e0d..cd01779 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog160.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog160.java
@@ -24,6 +24,7 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.orm.DBAccessor;
 
 import com.google.inject.Inject;
@@ -52,6 +53,8 @@ public class UpgradeCatalog160 extends AbstractUpgradeCatalog {
 
   @Override
   protected void executeDDLUpdates() throws AmbariException, SQLException {
+    fixViewTablesForMysql();
+
     List<DBAccessor.DBColumnInfo> columns = new ArrayList<DBAccessor.DBColumnInfo>();
 
     // BP host group configuration
@@ -94,6 +97,87 @@ public class UpgradeCatalog160 extends AbstractUpgradeCatalog {
   }
 
 
+  protected void fixViewTablesForMysql() throws SQLException {
+    //fixes 1.5.1 issue for mysql with non-default db name
+    //view tables were not created
+
+    if (!Configuration.MYSQL_DB_NAME.equals(getDbType()) || "ambari".equals(configuration.getServerDBName()))
{
+      //no need to run for non-mysql dbms or default db name
+      return;
+    }
+
+    List<DBAccessor.DBColumnInfo> columns = new ArrayList<DBAccessor.DBColumnInfo>();
+
+    // ========================================================================
+    // Create tables
+
+    // View
+    columns.clear();
+    columns.add(new DBAccessor.DBColumnInfo("view_name", String.class, 255, null, false));
+    columns.add(new DBAccessor.DBColumnInfo("label", String.class, 255, null, true));
+    columns.add(new DBAccessor.DBColumnInfo("version", String.class, 255, null, true));
+    columns.add(new DBAccessor.DBColumnInfo("archive", String.class, 255, null, true));
+
+    dbAccessor.createTable("viewmain", columns, "view_name");
+
+    // View Instance Data
+    columns.clear();
+    columns.add(new DBAccessor.DBColumnInfo("view_name", String.class, 255, null, false));
+    columns.add(new DBAccessor.DBColumnInfo("view_instance_name", String.class, 255, null,
false));
+    columns.add(new DBAccessor.DBColumnInfo("name", String.class, 255, null, false));
+    columns.add(new DBAccessor.DBColumnInfo("value", String.class, 255, null, true));
+
+    dbAccessor.createTable("viewinstancedata", columns, "view_name", "view_instance_name",
"name");
+
+    // View Instance
+    columns.clear();
+    columns.add(new DBAccessor.DBColumnInfo("view_name", String.class, 255, null, false));
+    columns.add(new DBAccessor.DBColumnInfo("name", String.class, 255, null, false));
+
+    dbAccessor.createTable("viewinstance", columns, "view_name", "name");
+
+    // View Instance Property
+    columns.clear();
+    columns.add(new DBAccessor.DBColumnInfo("view_name", String.class, 255, null, false));
+    columns.add(new DBAccessor.DBColumnInfo("view_instance_name", String.class, 255, null,
false));
+    columns.add(new DBAccessor.DBColumnInfo("name", String.class, 255, null, false));
+    columns.add(new DBAccessor.DBColumnInfo("value", String.class, 255, null, true));
+
+    dbAccessor.createTable("viewinstanceproperty", columns, "view_name", "view_instance_name",
"name");
+
+    // View Parameter
+    columns.clear();
+    columns.add(new DBAccessor.DBColumnInfo("view_name", String.class, 255, null, false));
+    columns.add(new DBAccessor.DBColumnInfo("name", String.class, 255, null, false));
+    columns.add(new DBAccessor.DBColumnInfo("description", String.class, 255, null, true));
+    columns.add(new DBAccessor.DBColumnInfo("required", Character.class, 1, null, true));
+
+    dbAccessor.createTable("viewparameter", columns, "view_name", "name");
+
+    // View Resource
+    columns.clear();
+    columns.add(new DBAccessor.DBColumnInfo("view_name", String.class, 255, null, false));
+    columns.add(new DBAccessor.DBColumnInfo("name", String.class, 255, null, false));
+    columns.add(new DBAccessor.DBColumnInfo("plural_name", String.class, 255, null, true));
+    columns.add(new DBAccessor.DBColumnInfo("id_property", String.class, 255, null, true));
+    columns.add(new DBAccessor.DBColumnInfo("subResource_names", String.class, 255, null,
true));
+    columns.add(new DBAccessor.DBColumnInfo("provider", String.class, 255, null, true));
+    columns.add(new DBAccessor.DBColumnInfo("service", String.class, 255, null, true));
+    columns.add(new DBAccessor.DBColumnInfo("`resource`", String.class, 255, null, true));
+    dbAccessor.createTable("viewresource", columns, "view_name", "name");
+
+    // ========================================================================
+    // Add constraints
+    dbAccessor.addFKConstraint("viewparameter", "FK_viewparam_view_name", "view_name", "viewmain",
"view_name", true);
+    dbAccessor.addFKConstraint("viewresource", "FK_viewres_view_name", "view_name", "viewmain",
"view_name", true);
+    dbAccessor.addFKConstraint("viewinstance", "FK_viewinst_view_name", "view_name", "viewmain",
"view_name", true);
+    dbAccessor.addFKConstraint("viewinstanceproperty", "FK_viewinstprop_view_name",
+      new String[]{"view_name", "view_instance_name"}, "viewinstance", new String[]{"view_name",
"name"}, true);
+    dbAccessor.addFKConstraint("viewinstancedata", "FK_viewinstdata_view_name",
+      new String[]{"view_name", "view_instance_name"}, "viewinstance", new String[]{"view_name",
"name"}, true);
+  }
+
+
   // ----- UpgradeCatalog ----------------------------------------------------
 
   @Override


Mime
View raw message