You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by vb...@apache.org on 2014/02/26 16:31:16 UTC

git commit: AMBARI-4843. Ambari DDL for MySQL should not create ambarirca database.(vbrodetskyi)

Repository: ambari
Updated Branches:
  refs/heads/trunk 01b4d27f2 -> d8cfceb9d


AMBARI-4843. Ambari DDL for MySQL should not create ambarirca database.(vbrodetskyi)


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

Branch: refs/heads/trunk
Commit: d8cfceb9d3f69c28021a4714fd352331cc239da5
Parents: 01b4d27
Author: Vitaly Brodetskyi <vb...@hortonworks.com>
Authored: Wed Feb 26 17:30:11 2014 +0200
Committer: Vitaly Brodetskyi <vb...@hortonworks.com>
Committed: Wed Feb 26 17:30:11 2014 +0200

----------------------------------------------------------------------
 .../server/configuration/Configuration.java      |  5 +++++
 .../ambari/server/upgrade/UpgradeCatalog150.java | 19 +++++++++++++++++++
 .../main/resources/Ambari-DDL-MySQL-CREATE.sql   |  3 ---
 3 files changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d8cfceb9/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
index 56bb58c..c02d633 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
@@ -94,6 +94,7 @@ public class Configuration {
   public static final String CLIENT_API_SSL_KEY_NAME_KEY = "client.api.ssl.key_name";
   public static final String SERVER_DB_NAME_KEY = "server.jdbc.database";
   public static final String SERVER_DB_NAME_DEFAULT = "ambari";
+  public static final String SERVER_JDBC_SCHEMA_NAME = "server.jdbc.schema";
   public static final String POSTGRES_DB_NAME = "postgres";
   public static final String ORACLE_DB_NAME = "oracle";
   public static final String MYSQL_DB_NAME = "mysql";
@@ -941,4 +942,8 @@ public class Configuration {
   public String getResourceDirPath() {
     return properties.getProperty(RESOURCES_DIR_KEY, RESOURCES_DIR_DEFAULT);
   }
+
+  public String getServerJDBCSchemaName() {
+    return properties.getProperty(SERVER_JDBC_SCHEMA_NAME, SERVER_DB_NAME_DEFAULT);
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/d8cfceb9/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 f104259..8032896 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
@@ -234,6 +234,19 @@ public class UpgradeCatalog150 extends AbstractUpgradeCatalog {
       }
     }
 
+    //Move tables from ambarirca db to ambari db; drop ambarirca; Mysql
+    if (getDbType().equals(Configuration.MYSQL_DB_NAME)) {
+      String dbName = configuration.getServerJDBCSchemaName();
+      moveRCATableInMySQL("workflow", dbName);
+      moveRCATableInMySQL("job", dbName);
+      moveRCATableInMySQL("task", dbName);
+      moveRCATableInMySQL("taskAttempt", dbName);
+      moveRCATableInMySQL("hdfsEvent", dbName);
+      moveRCATableInMySQL("mapreduceEvent", dbName);
+      moveRCATableInMySQL("clusterEvent", dbName);
+      dbAccessor.executeQuery("DROP DATABASE IF EXISTS ambarirca;");
+    }
+
     // ========================================================================
     // Add constraints
 
@@ -255,6 +268,12 @@ public class UpgradeCatalog150 extends AbstractUpgradeCatalog {
     updateMetaInfoVersion(getTargetVersion());
   }
 
+  private void moveRCATableInMySQL(String tableName, String dbName) throws SQLException {
+    if (!dbAccessor.tableExists(tableName)) {
+      dbAccessor.executeQuery(String.format("RENAME TABLE ambarirca.%s TO %s.%s;", tableName, dbName, tableName), true);
+    }
+  }
+
   @Override
   public void executeDMLUpdates() throws AmbariException, SQLException {
     // Service Config mapping

http://git-wip-us.apache.org/repos/asf/ambari/blob/d8cfceb9/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index 2e97b08..2c4cd5f 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -286,9 +286,6 @@ create index idx_qrtz_ft_tg on QRTZ_FIRED_TRIGGERS(SCHED_NAME,TRIGGER_GROUP);
 
 commit;
 
-CREATE DATABASE ambarirca;
-USE ambarirca;
-
 CREATE TABLE workflow (
   workflowId VARCHAR(255), workflowName TEXT,
   parentWorkflowId VARCHAR(255),