ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rle...@apache.org
Subject ambari git commit: AMBARI-10665. Internal Exception: org.postgresql.util.PSQLException: ERROR: column "config_attributes" does not exist (Emil Anca via rlevas)
Date Fri, 08 May 2015 12:17:25 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.0.maint 87fd33c17 -> 014a72179


AMBARI-10665. Internal Exception: org.postgresql.util.PSQLException: ERROR: column "config_attributes"
does not exist (Emil Anca via rlevas)


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

Branch: refs/heads/branch-2.0.maint
Commit: 014a7217962c6483067c1a29e9487e02eee76bbd
Parents: 87fd33c
Author: Emil Anca <eanca@hortonworks.com>
Authored: Fri May 8 08:17:02 2015 -0400
Committer: Robert Levas <rlevas@hortonworks.com>
Committed: Fri May 8 08:17:02 2015 -0400

----------------------------------------------------------------------
 .../orm/entities/BlueprintConfigEntity.java     |  3 +-
 .../orm/entities/ClusterConfigEntity.java       |  2 +-
 .../orm/entities/HostGroupConfigEntity.java     |  3 +-
 .../server/upgrade/UpgradeCatalog170.java       | 27 +++++++++++-----
 .../main/resources/Ambari-DDL-MySQL-CREATE.sql  |  4 +--
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |  6 ++--
 .../Ambari-DDL-Postgres-EMBEDDED-CREATE.sql     |  6 ++--
 .../resources/Ambari-DDL-SQLServer-CREATE.sql   |  4 +--
 .../server/upgrade/UpgradeCatalog170Test.java   | 33 +++++++++++++++-----
 9 files changed, 61 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/014a7217/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintConfigEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintConfigEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintConfigEntity.java
index b27f7ef..24b0ad2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintConfigEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintConfigEntity.java
@@ -50,7 +50,8 @@ public class BlueprintConfigEntity implements BlueprintConfiguration {
   private String configData;
 
   @Column(name = "config_attributes", nullable = true, insertable = true, updatable = false)
-  @Basic
+  @Basic(fetch = FetchType.LAZY)
+  @Lob
   private String configAttributes;
 
   @ManyToOne

http://git-wip-us.apache.org/repos/asf/ambari/blob/014a7217/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigEntity.java
index cb36923..334d442 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigEntity.java
@@ -56,7 +56,7 @@ public class ClusterConfigEntity {
   private String configJson;
 
   @Basic(fetch = FetchType.LAZY)
-  @Column(name = "config_attributes", nullable = true, insertable = true, updatable = false,
length = 32000)
+  @Column(name = "config_attributes", nullable = true, insertable = true, updatable = false)
   @Lob
   private String configAttributesJson;
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/014a7217/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupConfigEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupConfigEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupConfigEntity.java
index 49870fe..877f34b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupConfigEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupConfigEntity.java
@@ -56,7 +56,8 @@ public class HostGroupConfigEntity implements BlueprintConfiguration {
   private String configData;
 
   @Column(name = "config_attributes", nullable = true, insertable = true, updatable = false)
-  @Basic
+  @Basic(fetch = FetchType.LAZY)
+  @Lob
   private String configAttributes;
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/014a7217/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
index a703d42..0d8709b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
@@ -253,13 +253,11 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
 
     dbAccessor.insertRow("adminprivilege", new String[]{"privilege_id", "permission_id",
"resource_id", "principal_id"}, new String[]{"1", "1", "1", "1"}, true);
 
-    if (databaseType == DatabaseType.ORACLE) {
-      dbAccessor.executeQuery("ALTER TABLE clusterconfig ADD config_attributes CLOB NULL");
-    } else {
-      DBColumnInfo clusterConfigAttributesColumn = new DBColumnInfo(
-          "config_attributes", String.class, 32000, null, true);
-      dbAccessor.addColumn("clusterconfig", clusterConfigAttributesColumn);
-    }
+    String [] configAttributesTableNames = {"clusterconfig", "hostgroup_configuration", "blueprint_configuration"};
+
+    for(String tableName : configAttributesTableNames) {
+      addConfigAttributesColumn(tableName);
+     }
 
     // Add columns
     dbAccessor.addColumn("viewmain", new DBColumnInfo("mask",
@@ -492,6 +490,21 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
   }
 
   /**
+   * @param tableName
+   * @throws SQLException
+   */
+  private void addConfigAttributesColumn(String tableName) throws SQLException {
+    final DatabaseType databaseType = configuration.getDatabaseType();
+    if (databaseType == DatabaseType.ORACLE) {
+      dbAccessor.executeQuery("ALTER TABLE " + tableName + " ADD config_attributes CLOB NULL");
+    } else {
+      DBColumnInfo clusterConfigAttributesColumn = new DBColumnInfo(
+          "config_attributes", Character[].class, null, null, true);
+      dbAccessor.addColumn(tableName, clusterConfigAttributesColumn);
+    }
+  }
+
+  /**
    * Note that you can't use dbAccessor.renameColumn(...) here as the column name is a reserved
word and
    * thus requires custom approach for every database type.
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/014a7217/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 9ff62df..3c2c908 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -392,7 +392,7 @@ CREATE TABLE blueprint_configuration (
   blueprint_name VARCHAR(255) NOT NULL,
   type_name VARCHAR(255) NOT NULL,
   config_data LONGTEXT NOT NULL,
-  config_attributes VARCHAR(32000),
+  config_attributes LONGTEXT,
   PRIMARY KEY(blueprint_name, type_name));
 
 CREATE TABLE hostgroup_configuration (
@@ -400,7 +400,7 @@ CREATE TABLE hostgroup_configuration (
   hostgroup_name VARCHAR(255) NOT NULL,
   type_name VARCHAR(255) NOT NULL,
   config_data LONGTEXT NOT NULL,
-  config_attributes TEXT,
+  config_attributes LONGTEXT,
   PRIMARY KEY(blueprint_name, hostgroup_name, type_name));
 
 CREATE TABLE viewmain (

http://git-wip-us.apache.org/repos/asf/ambari/blob/014a7217/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 78a263f..0ebe714 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -35,7 +35,7 @@ CREATE TABLE clusterconfig (
   type_name VARCHAR(255) NOT NULL,
   cluster_id BIGINT NOT NULL,
   config_data TEXT NOT NULL,
-  config_attributes VARCHAR(32000),
+  config_attributes TEXT,
   create_timestamp BIGINT NOT NULL,
   PRIMARY KEY (config_id));
 
@@ -383,7 +383,7 @@ CREATE TABLE blueprint_configuration (
   blueprint_name varchar(255) NOT NULL,
   type_name varchar(255) NOT NULL,
   config_data TEXT NOT NULL ,
-  config_attributes varchar(32000),
+  config_attributes TEXT,
   PRIMARY KEY(blueprint_name, type_name));
 
 CREATE TABLE hostgroup_configuration (
@@ -391,7 +391,7 @@ CREATE TABLE hostgroup_configuration (
   hostgroup_name VARCHAR(255) NOT NULL,
   type_name VARCHAR(255) NOT NULL,
   config_data TEXT NOT NULL,
-  config_attributes varchar(32000),
+  config_attributes TEXT,
   PRIMARY KEY(blueprint_name, hostgroup_name, type_name));
 
 CREATE TABLE viewmain (

http://git-wip-us.apache.org/repos/asf/ambari/blob/014a7217/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
index a06f1d2..06bf1ad 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
@@ -47,7 +47,7 @@ CREATE TABLE ambari.clusterconfig (
   type_name VARCHAR(255) NOT NULL,
   cluster_id BIGINT NOT NULL,
   config_data TEXT NOT NULL,
-  config_attributes VARCHAR(32000),
+  config_attributes TEXT,
   create_timestamp BIGINT NOT NULL,
   PRIMARY KEY (config_id));
 GRANT ALL PRIVILEGES ON TABLE ambari.clusterconfig TO :username;
@@ -433,7 +433,7 @@ CREATE TABLE ambari.blueprint_configuration (
   blueprint_name varchar(255) NOT NULL,
   type_name varchar(255) NOT NULL,
   config_data TEXT NOT NULL,
-  config_attributes varchar(32000),
+  config_attributes TEXT,
   PRIMARY KEY(blueprint_name, type_name));
 
 CREATE TABLE ambari.hostgroup_configuration (
@@ -441,7 +441,7 @@ CREATE TABLE ambari.hostgroup_configuration (
   hostgroup_name VARCHAR(255) NOT NULL,
   type_name VARCHAR(255) NOT NULL,
   config_data TEXT NOT NULL,
-  config_attributes varchar(32000),
+  config_attributes TEXT,
   PRIMARY KEY(blueprint_name, hostgroup_name, type_name));
 
 GRANT ALL PRIVILEGES ON TABLE ambari.blueprint TO :username;

http://git-wip-us.apache.org/repos/asf/ambari/blob/014a7217/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
index 796b288..8f32db3 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -69,8 +69,8 @@ CREATE TABLE requestschedulebatchrequest (schedule_id bigint, batch_id bigint,
r
 CREATE TABLE blueprint (blueprint_name VARCHAR(255) NOT NULL, stack_name VARCHAR(255) NOT
NULL, stack_version VARCHAR(255) NOT NULL, PRIMARY KEY(blueprint_name));
 CREATE TABLE hostgroup (blueprint_name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL,
cardinality VARCHAR(255) NOT NULL, PRIMARY KEY(blueprint_name, name));
 CREATE TABLE hostgroup_component (blueprint_name VARCHAR(255) NOT NULL, hostgroup_name VARCHAR(255)
NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(blueprint_name, hostgroup_name, name));
-CREATE TABLE blueprint_configuration (blueprint_name varchar(255) NOT NULL, type_name varchar(255)
NOT NULL, config_data text NOT NULL, config_attributes VARCHAR(8000), PRIMARY KEY(blueprint_name,
type_name));
-CREATE TABLE hostgroup_configuration (blueprint_name VARCHAR(255) NOT NULL, hostgroup_name
VARCHAR(255) NOT NULL, type_name VARCHAR(255) NOT NULL, config_data TEXT NOT NULL, config_attributes
TEXT, PRIMARY KEY(blueprint_name, hostgroup_name, type_name));
+CREATE TABLE blueprint_configuration (blueprint_name varchar(255) NOT NULL, type_name varchar(255)
NOT NULL, config_data text NOT NULL, config_attributes VARCHAR(MAX), PRIMARY KEY(blueprint_name,
type_name));
+CREATE TABLE hostgroup_configuration (blueprint_name VARCHAR(255) NOT NULL, hostgroup_name
VARCHAR(255) NOT NULL, type_name VARCHAR(255) NOT NULL, config_data TEXT NOT NULL, config_attributes
VARCHAR(MAX), PRIMARY KEY(blueprint_name, hostgroup_name, type_name));
 CREATE TABLE viewmain (view_name VARCHAR(255) NOT NULL, label VARCHAR(255), description VARCHAR(2048),
version VARCHAR(255), resource_type_id INTEGER NOT NULL, icon VARCHAR(255), icon64 VARCHAR(255),
archive VARCHAR(255), mask VARCHAR(255), system_view BIT NOT NULL DEFAULT 0, PRIMARY KEY(view_name));
 CREATE TABLE viewinstancedata (view_instance_id BIGINT, view_name VARCHAR(255) NOT NULL,
view_instance_name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, user_name VARCHAR(255)
NOT NULL, value VARCHAR(2000) NOT NULL, PRIMARY KEY(view_instance_id, name, user_name));
 CREATE TABLE viewinstance (view_instance_id BIGINT, resource_id BIGINT NOT NULL, view_name
VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, label VARCHAR(255), description VARCHAR(2048),
visible CHAR(1), icon VARCHAR(255), icon64 VARCHAR(255), xml_driven CHAR(1), PRIMARY KEY(view_instance_id));

http://git-wip-us.apache.org/repos/asf/ambari/blob/014a7217/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
index b51cac2..4e886c0 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
@@ -180,6 +180,8 @@ public class UpgradeCatalog170Test {
     expectLastCall();
 
     Capture<DBAccessor.DBColumnInfo> clusterConfigAttributesColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
+    Capture<DBAccessor.DBColumnInfo> hostgroupConfigAttributesColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
+    Capture<DBAccessor.DBColumnInfo> blueprintConfigAttributesColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
     Capture<DBAccessor.DBColumnInfo> maskColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
     Capture<DBAccessor.DBColumnInfo> systemColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
     Capture<DBAccessor.DBColumnInfo> maskedColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
@@ -205,7 +207,9 @@ public class UpgradeCatalog170Test {
 
     setViewExpectations(dbAccessor, maskColumnCapture, systemColumnCapture);
     setViewParameterExpectations(dbAccessor, maskedColumnCapture);
-    setClusterConfigExpectations(dbAccessor, clusterConfigAttributesColumnCapture);
+    setConfigAttributesColumnExpectations(dbAccessor, clusterConfigAttributesColumnCapture,
"clusterconfig");
+    setConfigAttributesColumnExpectations(dbAccessor, hostgroupConfigAttributesColumnCapture,
"hostgroup_configuration");
+    setConfigAttributesColumnExpectations(dbAccessor, blueprintConfigAttributesColumnCapture,
"blueprint_configuration");
     setStageExpectations(dbAccessor, stageCommandParamsColumnCapture, stageHostParamsColumnCapture);
 
     dbAccessor.createTable(eq("alert_definition"),
@@ -261,6 +265,8 @@ public class UpgradeCatalog170Test {
     verify(dbAccessor, configuration, resultSet, connection, stmt);
 
     assertClusterConfigColumns(clusterConfigAttributesColumnCapture);
+    assertHostgroupConfigColumns(hostgroupConfigAttributesColumnCapture);
+    assertBlueprintConfigColumns(blueprintConfigAttributesColumnCapture);
     assertViewColumns(maskColumnCapture, systemColumnCapture);
     assertViewParameterColumns(maskedColumnCapture);
     assertStageColumns(stageCommandParamsColumnCapture, stageHostParamsColumnCapture);
@@ -628,18 +634,31 @@ public class UpgradeCatalog170Test {
 
   private void assertClusterConfigColumns(Capture<DBAccessor.DBColumnInfo> clusterConfigAttributesColumnCapture)
{
     DBAccessor.DBColumnInfo column = clusterConfigAttributesColumnCapture.getValue();
+    assertConfigAttriburesColumn(column);
+  }
+
+  private void assertHostgroupConfigColumns(Capture<DBAccessor.DBColumnInfo> hostgroupConfigAttributesColumnCapture)
{
+    DBAccessor.DBColumnInfo column = hostgroupConfigAttributesColumnCapture.getValue();
+    assertConfigAttriburesColumn(column);
+  }
+
+  private void assertBlueprintConfigColumns(Capture<DBAccessor.DBColumnInfo> blueprintConfigAttributesColumnCapture)
{
+    DBAccessor.DBColumnInfo column = blueprintConfigAttributesColumnCapture.getValue();
+    assertConfigAttriburesColumn(column);
+  }
+
+  private void assertConfigAttriburesColumn(DBAccessor.DBColumnInfo column) {
     assertEquals("config_attributes", column.getName());
-    assertEquals(32000, (int) column.getLength());
-    assertEquals(String.class, column.getType());
+    assertEquals(Character[].class, column.getType());
     assertEquals(null, column.getDefaultValue());
     assertTrue(column.isNullable());
   }
 
-  private void setClusterConfigExpectations(DBAccessor dbAccessor,
-                                   Capture<DBAccessor.DBColumnInfo> clusterConfigAttributesColumnCapture)
+  private void setConfigAttributesColumnExpectations(DBAccessor dbAccessor,
+                                   Capture<DBAccessor.DBColumnInfo> configAttributesColumnCapture,
String tableName)
       throws SQLException {
-    dbAccessor.addColumn(eq("clusterconfig"),
-        capture(clusterConfigAttributesColumnCapture));
+    dbAccessor.addColumn(eq(tableName),
+        capture(configAttributesColumnCapture));
   }
 
   private void setStageExpectations(DBAccessor dbAccessor,


Mime
View raw message