ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject git commit: AMBARI-5154. Upgrade from 1.4.4 to 1.5.0 failed on Oracle DB. (swagle)
Date Thu, 20 Mar 2014 01:05:24 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk b3f8c1d01 -> d42a5b390


AMBARI-5154. Upgrade from 1.4.4 to 1.5.0 failed on Oracle DB. (swagle)


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

Branch: refs/heads/trunk
Commit: d42a5b3904ff4320e28442b804dcbe32884d4cfc
Parents: b3f8c1d
Author: Siddharth Wagle <swagle@hortonworks.com>
Authored: Wed Mar 19 17:19:48 2014 -0700
Committer: Siddharth Wagle <swagle@hortonworks.com>
Committed: Wed Mar 19 17:22:37 2014 -0700

----------------------------------------------------------------------
 .../ambari/server/orm/DBAccessorImpl.java       | 21 ++++++--------------
 .../server/upgrade/UpgradeCatalog150.java       |  8 ++++----
 .../main/resources/Ambari-DDL-MySQL-CREATE.sql  |  4 ++--
 .../main/resources/Ambari-DDL-Oracle-CREATE.sql |  2 +-
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |  4 ++--
 5 files changed, 15 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d42a5b39/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 9f8a359..e54dc9a 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
@@ -39,6 +39,7 @@ import java.sql.Connection;
 import java.sql.DatabaseMetaData;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Arrays;
@@ -135,14 +136,8 @@ public class DBAccessorImpl implements DBAccessor {
   public boolean tableExists(String tableName) throws SQLException {
     boolean result = false;
     DatabaseMetaData metaData = getDatabaseMetaData();
-    String schemaFilter = null;
-    if (getDbType().equals(Configuration.ORACLE_DB_NAME)) {
-      // Optimization to not query everything
-      schemaFilter = configuration.getDatabaseUser();
-    }
 
-    ResultSet res = metaData.getTables(null, schemaFilter,
-      convertObjectName(tableName), new String[] { "TABLE" });
+    ResultSet res = metaData.getTables(null, null, convertObjectName(tableName), new String[]
{ "TABLE" });
 
     if (res != null) {
       try {
@@ -195,14 +190,8 @@ public class DBAccessorImpl implements DBAccessor {
   public boolean tableHasColumn(String tableName, String columnName) throws SQLException
{
     boolean result = false;
     DatabaseMetaData metaData = getDatabaseMetaData();
-    String schemaFilter = null;
-    if (getDbType().equals(Configuration.ORACLE_DB_NAME)) {
-      // Optimization to not query everything
-      schemaFilter = configuration.getDatabaseUser();
-    }
 
-    ResultSet rs = metaData.getColumns(null, schemaFilter,
-        convertObjectName(tableName), convertObjectName(columnName));
+    ResultSet rs = metaData.getColumns(null, null, convertObjectName(tableName), convertObjectName(columnName));
 
     if (rs != null) {
       try {
@@ -274,7 +263,9 @@ public class DBAccessorImpl implements DBAccessor {
       } catch (SQLException e) {
         LOG.warn("Add FK constraint failed" +
           ", constraintName = " + constraintName +
-          ", tableName = " + tableName, e);
+          ", tableName = " + tableName + ", errorCode = " + e.getErrorCode() +
+          ", message = " + e.getMessage());
+        LOG.debug("Exception on add FK constraint.", e);
         if (!ignoreFailure) {
           throw e;
         }

http://git-wip-us.apache.org/repos/asf/ambari/blob/d42a5b39/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 ee5acb5..3c1ad47 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
@@ -280,7 +280,7 @@ public class UpgradeCatalog150 extends AbstractUpgradeCatalog {
       String msg = String.format("Table \"%s\" was not created during schema upgrade", tableName);
       LOG.error(msg);
       throw new AmbariException(msg);
-    }else if (!dbAccessor.tableHasData(tableName)) {
+    } else if (!dbAccessor.tableHasData(tableName)) {
       String query;
       if (getDbType().equals(Configuration.POSTGRES_DB_NAME)) {
         query = getPostgresRequestUpgradeQuery();
@@ -301,7 +301,7 @@ public class UpgradeCatalog150 extends AbstractUpgradeCatalog {
     dbAccessor.addFKConstraint("stage", "FK_stage_request_id", "request_id", "request", "request_id",
true);
     dbAccessor.addFKConstraint("request", "FK_request_cluster_id", "cluster_id", "clusters",
"cluster_id", true);
     dbAccessor.addFKConstraint("request", "FK_request_schedule_id", "request_schedule_id",
"requestschedule", "schedule_id", true);
-    dbAccessor.addFKConstraint("requestschedulebatchrequest", "FK_requestschedulebatchrequest_schedule_id",
"schedule_id", "requestschedule", "schedule_id", true);
+    dbAccessor.addFKConstraint("requestschedulebatchrequest", "FK_rsbatchrequest_schedule_id",
"schedule_id", "requestschedule", "schedule_id", true);
     dbAccessor.addFKConstraint("hostconfigmapping", "FK_hostconfigmapping_cluster_id", "cluster_id",
"clusters", "cluster_id", true);
     dbAccessor.addFKConstraint("hostconfigmapping", "FK_hostconfigmapping_host_name", "host_name",
"hosts", "host_name", true);
     dbAccessor.addFKConstraint("configgroup", "FK_configgroup_cluster_id", "cluster_id",
"clusters", "cluster_id", true);
@@ -310,7 +310,7 @@ public class UpgradeCatalog150 extends AbstractUpgradeCatalog {
     dbAccessor.addFKConstraint("configgrouphostmapping", "FK_cghostm_configgroup_id", "config_group_id",
"configgroup", "group_id", true);
     dbAccessor.addFKConstraint("configgrouphostmapping", "FK_cghostm_host_name", "host_name",
"hosts", "host_name", true);
     dbAccessor.addFKConstraint("clusterconfigmapping", "FK_clustercfgmap_cluster_id", "cluster_id",
"clusters", "cluster_id", true);
-    dbAccessor.addFKConstraint("requestresourcefilter", "FK_requestresourcefilter_req_id",
"request_id", "request", "request_id", true);
+    dbAccessor.addFKConstraint("requestresourcefilter", "FK_reqresfilter_req_id", "request_id",
"request", "request_id", true);
     dbAccessor.addFKConstraint("hostgroup", "FK_hostgroup_blueprint_name", "blueprint_name",
"blueprint", "blueprint_name", true);
     dbAccessor.addFKConstraint("hostgroup_component", "FK_component_blueprint_name", "blueprint_name",
"hostgroup", "blueprint_name", true);
     dbAccessor.addFKConstraint("hostgroup_component", "FK_component_hostgroup_name", "hostgroup_name",
"hostgroup", "name", true);
@@ -658,7 +658,7 @@ public class UpgradeCatalog150 extends AbstractUpgradeCatalog {
     return "INSERT INTO request" +
       "(request_id, cluster_id, request_context, start_time, end_time, create_time) " +
       "SELECT DISTINCT s.request_id, s.cluster_id, s.request_context, " +
-      "nvl(cmd.start_time, -1), nvl(cmd.end_time, -1), -1" +
+      "nvl(cmd.start_time, -1), nvl(cmd.end_time, -1), -1 " +
       "FROM " +
       "(SELECT DISTINCT request_id, cluster_id, request_context FROM stage ) s " +
       "LEFT JOIN " +

http://git-wip-us.apache.org/repos/asf/ambari/blob/d42a5b39/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 3225c1c..5f08340 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -92,11 +92,11 @@ ALTER TABLE confgroupclusterconfigmapping ADD CONSTRAINT FK_confgroupclusterconf
 ALTER TABLE configgroup ADD CONSTRAINT FK_configgroup_cluster_id FOREIGN KEY (cluster_id)
REFERENCES clusters (cluster_id);
 ALTER TABLE configgrouphostmapping ADD CONSTRAINT FK_configgrouphostmapping_configgroup_id
FOREIGN KEY (config_group_id) REFERENCES configgroup (group_id);
 ALTER TABLE configgrouphostmapping ADD CONSTRAINT FK_configgrouphostmapping_host_name FOREIGN
KEY (host_name) REFERENCES hosts (host_name);
-ALTER TABLE requestschedulebatchrequest ADD CONSTRAINT FK_requestschedulebatchrequest_schedule_id
FOREIGN KEY (schedule_id) REFERENCES ambari.requestschedule (schedule_id);
+ALTER TABLE requestschedulebatchrequest ADD CONSTRAINT FK_rsbatchrequest_schedule_id FOREIGN
KEY (schedule_id) REFERENCES requestschedule (schedule_id);
 ALTER TABLE hostgroup ADD FOREIGN KEY (blueprint_name) REFERENCES blueprint(blueprint_name);
 ALTER TABLE hostgroup_component ADD FOREIGN KEY (blueprint_name, hostgroup_name) REFERENCES
hostgroup(blueprint_name, name);
 ALTER TABLE blueprint_configuration ADD FOREIGN KEY (blueprint_name) REFERENCES blueprint(blueprint_name);
-ALTER TABLE requestresourcefilter ADD CONSTRAINT FK_requestresourcefilter_req_id FOREIGN
KEY (request_id) REFERENCES request (request_id);
+ALTER TABLE requestresourcefilter ADD CONSTRAINT FK_reqresfilter_req_id FOREIGN KEY (request_id)
REFERENCES request (request_id);
 
 
 INSERT INTO ambari_sequences(sequence_name, value) values ('cluster_id_seq', 1);

http://git-wip-us.apache.org/repos/asf/ambari/blob/d42a5b39/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index 2aabe57..36df81b 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -84,7 +84,7 @@ ALTER TABLE requestschedulebatchrequest ADD CONSTRAINT FK_rsbatchrequest_schedul
 ALTER TABLE hostgroup ADD FOREIGN KEY (blueprint_name) REFERENCES blueprint(blueprint_name);
 ALTER TABLE hostgroup_component ADD FOREIGN KEY (blueprint_name, hostgroup_name) REFERENCES
hostgroup(blueprint_name, name);
 ALTER TABLE blueprint_configuration ADD FOREIGN KEY (blueprint_name) REFERENCES blueprint(blueprint_name);
-ALTER TABLE requestresourcefilter ADD CONSTRAINT FK_requestresourcefilter_req_id FOREIGN
KEY (request_id) REFERENCES request (request_id);
+ALTER TABLE requestresourcefilter ADD CONSTRAINT FK_reqresfilter_req_id FOREIGN KEY (request_id)
REFERENCES request (request_id);
 
 INSERT INTO ambari_sequences(sequence_name, value) values ('host_role_command_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, value) values ('user_id_seq', 1);

http://git-wip-us.apache.org/repos/asf/ambari/blob/d42a5b39/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index f7760d4..e415359 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -158,10 +158,10 @@ ALTER TABLE ambari.confgroupclusterconfigmapping ADD CONSTRAINT FK_confgroupclus
 ALTER TABLE ambari.confgroupclusterconfigmapping ADD CONSTRAINT FK_confgroupclusterconfigmapping_group_id
FOREIGN KEY (config_group_id) REFERENCES ambari.configgroup (group_id);
 ALTER TABLE ambari.configgrouphostmapping ADD CONSTRAINT FK_configgrouphostmapping_configgroup_id
FOREIGN KEY (config_group_id) REFERENCES ambari.configgroup (group_id);
 ALTER TABLE ambari.configgrouphostmapping ADD CONSTRAINT FK_configgrouphostmapping_host_name
FOREIGN KEY (host_name) REFERENCES ambari.hosts (host_name);
-ALTER TABLE ambari.requestschedulebatchrequest ADD CONSTRAINT FK_requestschedulebatchrequest_schedule_id
FOREIGN KEY (schedule_id) REFERENCES ambari.requestschedule (schedule_id);
+ALTER TABLE ambari.requestschedulebatchrequest ADD CONSTRAINT FK_rsbatchrequest_schedule_id
FOREIGN KEY (schedule_id) REFERENCES ambari.requestschedule (schedule_id);
 ALTER TABLE ambari.hostgroup ADD FOREIGN KEY (blueprint_name) REFERENCES ambari.blueprint(blueprint_name);
 ALTER TABLE ambari.hostgroup_component ADD FOREIGN KEY (blueprint_name, hostgroup_name) REFERENCES
ambari.hostgroup(blueprint_name, name);
-ALTER TABLE ambari.requestresourcefilter ADD CONSTRAINT FK_requestresourcefilter_req_id FOREIGN
KEY (request_id) REFERENCES ambari.request (request_id);
+ALTER TABLE ambari.requestresourcefilter ADD CONSTRAINT FK_reqresfilter_req_id FOREIGN KEY
(request_id) REFERENCES ambari.request (request_id);
 
 
 ---------inserting some data-----------


Mime
View raw message