ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smn...@apache.org
Subject ambari git commit: AMBARI-15122: Auto-start services - Add upgrade support for changes to servicecomponentdesiredstate table
Date Sun, 21 Feb 2016 01:10:26 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 4bdd8dd9c -> 6044f0c82


AMBARI-15122: Auto-start services - Add upgrade support for changes to servicecomponentdesiredstate
table


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

Branch: refs/heads/trunk
Commit: 6044f0c829c0879f3195d7fd445da413d8176222
Parents: 4bdd8dd
Author: Nahappan Somasundaram <nsomasundaram@hortonworks.com>
Authored: Fri Feb 19 16:07:15 2016 -0800
Committer: Nahappan Somasundaram <nsomasundaram@hortonworks.com>
Committed: Sat Feb 20 17:10:06 2016 -0800

----------------------------------------------------------------------
 .../ambari/server/upgrade/UpgradeCatalog240.java       | 13 +++++++++++++
 .../src/main/resources/Ambari-DDL-MySQL-CREATE.sql     |  2 +-
 .../src/main/resources/Ambari-DDL-Oracle-CREATE.sql    |  2 +-
 .../main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql   |  2 +-
 .../src/main/resources/Ambari-DDL-SQLServer-CREATE.sql |  2 +-
 .../ambari/server/upgrade/UpgradeCatalog240Test.java   | 12 ++++++++++++
 6 files changed, 29 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/6044f0c8/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
index d97962f..6a8ead1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
@@ -77,6 +77,8 @@ public class UpgradeCatalog240 extends AbstractUpgradeCatalog {
   private static final String ID = "id";
   private static final String SETTING_TABLE = "setting";
 
+  protected static final String SERVICE_COMPONENT_DESIRED_STATE_TABLE = "servicecomponentdesiredstate";
+  protected static final String RECOVERY_ENABLED_COL = "recovery_enabled";
 
   // ----- Constructors ------------------------------------------------------
 
@@ -115,6 +117,7 @@ public class UpgradeCatalog240 extends AbstractUpgradeCatalog {
   @Override
   protected void executeDDLUpdates() throws AmbariException, SQLException {
     updateAdminPermissionTable();
+    updateServiceComponentDesiredStateTable();
     createSettingTable();
   }
 
@@ -391,4 +394,14 @@ public class UpgradeCatalog240 extends AbstractUpgradeCatalog {
         7, PermissionEntity.VIEW_USER_PERMISSION_NAME));
   }
 
+  /**
+   * Alter servicecomponentdesiredstate table to add recovery_enabled column.
+   * @throws SQLException
+   */
+  private void updateServiceComponentDesiredStateTable() throws SQLException {
+    // ALTER TABLE servicecomponentdesiredstate ADD COLUMN
+    // recovery_enabled SMALLINT DEFAULT 0 NOT NULL
+    dbAccessor.addColumn(SERVICE_COMPONENT_DESIRED_STATE_TABLE,
+            new DBAccessor.DBColumnInfo(RECOVERY_ENABLED_COL, Short.class, null, 0, false));
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6044f0c8/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 1ea1646..2898ab7 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -177,7 +177,7 @@ CREATE TABLE servicecomponentdesiredstate (
   desired_stack_id BIGINT NOT NULL,
   desired_state VARCHAR(255) NOT NULL,
   service_name VARCHAR(100) NOT NULL,
-  recovery_enabled TINYINT(1) NOT NULL DEFAULT 0,
+  recovery_enabled SMALLINT NOT NULL DEFAULT 0,
   PRIMARY KEY (component_name, cluster_id, service_name)
 );
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6044f0c8/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 e5fa3e1..092f8c2 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -167,7 +167,7 @@ CREATE TABLE servicecomponentdesiredstate (
   desired_stack_id NUMBER(19) NOT NULL,
   desired_state VARCHAR2(255) NOT NULL,
   service_name VARCHAR2(255) NOT NULL,
-  recovery_enabled NUMBER(1) DEFAULT 0 NOT NULL,
+  recovery_enabled SMALLINT DEFAULT 0 NOT NULL,
   PRIMARY KEY (component_name, cluster_id, service_name)
 );
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6044f0c8/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
index 1f45bc7..20a7634 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
@@ -166,7 +166,7 @@ CREATE TABLE servicecomponentdesiredstate (
   desired_stack_id NUMERIC(19) NOT NULL,
   desired_state VARCHAR(255) NOT NULL,
   service_name VARCHAR(255) NOT NULL,
-  recovery_enabled BIT NOT NULL DEFAULT 0,
+  recovery_enabled SMALLINT NOT NULL DEFAULT 0,
   PRIMARY KEY (component_name, cluster_id, service_name)
 );
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6044f0c8/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 b1edbbd..2c9adf3 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -186,7 +186,7 @@ CREATE TABLE servicecomponentdesiredstate (
   desired_stack_id BIGINT NOT NULL,
   desired_state VARCHAR(255) NOT NULL,
   service_name VARCHAR(255) NOT NULL,
-  recovery_enabled BIT NOT NULL DEFAULT 0,
+  recovery_enabled SMALLINT NOT NULL DEFAULT 0,
   PRIMARY KEY CLUSTERED (component_name, cluster_id, service_name)
   );
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6044f0c8/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
index a145253..ca1b907 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
@@ -100,6 +100,7 @@ public class UpgradeCatalog240Test {
   @Test
   public void testExecuteDDLUpdates() throws SQLException, AmbariException {
     Capture<DBAccessor.DBColumnInfo> capturedColumnInfo = newCapture();
+    Capture<DBAccessor.DBColumnInfo> capturedScColumnInfo = newCapture();
     final DBAccessor dbAccessor = createStrictMock(DBAccessor.class);
     Configuration configuration = createNiceMock(Configuration.class);
     Connection connection = createNiceMock(Connection.class);
@@ -108,6 +109,8 @@ public class UpgradeCatalog240Test {
     Capture<List<DBAccessor.DBColumnInfo>> capturedSettingColumns = EasyMock.newCapture();
 
     dbAccessor.addColumn(eq("adminpermission"), capture(capturedColumnInfo));
+    dbAccessor.addColumn(eq(UpgradeCatalog240.SERVICE_COMPONENT_DESIRED_STATE_TABLE), capture(capturedScColumnInfo));
+
     dbAccessor.createTable(eq("setting"), capture(capturedSettingColumns), eq("id"));
     expect(configuration.getDatabaseUrl()).andReturn(Configuration.JDBC_IN_MEMORY_URL).anyTimes();
     expect(dbAccessor.getConnection()).andReturn(connection);
@@ -136,6 +139,15 @@ public class UpgradeCatalog240Test {
     Assert.assertEquals(1, columnInfo.getDefaultValue());
     Assert.assertEquals(false, columnInfo.isNullable());
 
+    // Verify if recovery_enabled column was added to servicecomponentdesiredstate table
+    DBAccessor.DBColumnInfo columnScInfo = capturedScColumnInfo.getValue();
+    Assert.assertNotNull(columnScInfo);
+    Assert.assertEquals(UpgradeCatalog240.RECOVERY_ENABLED_COL, columnScInfo.getName());
+    Assert.assertEquals(null, columnScInfo.getLength());
+    Assert.assertEquals(Short.class, columnScInfo.getType());
+    Assert.assertEquals(0, columnScInfo.getDefaultValue());
+    Assert.assertEquals(false, columnScInfo.isNullable());
+
     Map<String, Class> expectedCaptures = new HashMap<>();
     expectedCaptures.put("id", Long.class);
     expectedCaptures.put("name", String.class);


Mime
View raw message