ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vbrodets...@apache.org
Subject ambari git commit: AMBARI-9872. Check Kerberos failed after Ambari upgrade 1.7.0->2.0.0.(vbrodetskyi)
Date Mon, 02 Mar 2015 18:05:03 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 37e0d6d51 -> d54457c20


AMBARI-9872. Check Kerberos failed after Ambari upgrade 1.7.0->2.0.0.(vbrodetskyi)


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

Branch: refs/heads/trunk
Commit: d54457c20376bebcee6a2a8b7051567701b75cc9
Parents: 37e0d6d
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Mon Mar 2 20:04:49 2015 +0200
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Mon Mar 2 20:04:49 2015 +0200

----------------------------------------------------------------------
 .../apache/ambari/server/orm/DBAccessor.java    | 42 +++++++++++++++++++-
 .../ambari/server/orm/DBAccessorImpl.java       | 26 ++++++++++--
 .../server/orm/helpers/dbms/DbmsHelper.java     |  3 +-
 .../orm/helpers/dbms/GenericDbmsHelper.java     |  4 +-
 .../server/upgrade/UpgradeCatalog200.java       | 42 +-------------------
 .../server/upgrade/UpgradeCatalog200Test.java   |  8 +---
 6 files changed, 71 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d54457c2/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessor.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessor.java
index 98e2bbb..2b01c72 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/DBAccessor.java
@@ -63,7 +63,6 @@ public interface DBAccessor {
   public void createIndex(String indexName, String tableName,
                           String... columnNames) throws SQLException;
 
-
   /**
    * Add foreign key for a relation
    * @param tableName
@@ -80,11 +79,33 @@ public interface DBAccessor {
                               boolean ignoreFailure) throws SQLException;
 
   /**
-   * Add foreign key for a relation
+   *
    * @param tableName
    * @param constraintName
    * @param keyColumn
+   * @param referenceTableName
    * @param referenceColumn
+   * @param shouldCascadeOnDelete
+   * @param ignoreFailure
+   * @throws SQLException
+   */
+  public void addFKConstraint(String tableName,
+                              String constraintName,
+                              String keyColumn,
+                              String referenceTableName,
+                              String referenceColumn,
+                              boolean shouldCascadeOnDelete,
+                              boolean ignoreFailure) throws SQLException;
+
+  /**
+   * Add foreign key for a relation
+   * @param tableName
+   * @param constraintName
+   * @param keyColumns
+   * @param referenceTableName
+   * @param referenceColumns
+   * @param shouldCascadeOnDelete
+   * @param ignoreFailure
    * @throws SQLException
    */
   public void addFKConstraint(String tableName,
@@ -92,9 +113,26 @@ public interface DBAccessor {
                               String[] keyColumns,
                               String referenceTableName,
                               String[] referenceColumns,
+                              boolean shouldCascadeOnDelete,
                               boolean ignoreFailure) throws SQLException;
 
   /**
+   * Add foreign key for a relation
+   * @param tableName
+   * @param constraintName
+   * @param keyColumns
+   * @param referenceTableName
+   * @param referenceColumns
+   * @param ignoreFailure
+   * @throws SQLException
+   */
+  public void addFKConstraint(String tableName,
+                              String constraintName,
+                              String[] keyColumns,
+                              String referenceTableName,
+                              String[] referenceColumns,
+                              boolean ignoreFailure) throws SQLException;
+  /**
    * Add column to existing table
    * @param tableName
    * @param columnInfo

http://git-wip-us.apache.org/repos/asf/ambari/blob/d54457c2/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 05db3f7..279c78f 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
@@ -335,19 +335,37 @@ public class DBAccessorImpl implements DBAccessor {
                               String referenceColumn, boolean ignoreFailure) throws SQLException
{
 
     addFKConstraint(tableName, constraintName, new String[]{keyColumn}, referenceTableName,
-      new String[]{referenceColumn}, ignoreFailure);
+        new String[]{referenceColumn}, false, ignoreFailure);
+  }
+  @Override
+  public void addFKConstraint(String tableName, String constraintName,
+                              String keyColumn, String referenceTableName,
+                              String referenceColumn, boolean shouldCascadeOnDelete,
+                              boolean ignoreFailure) throws SQLException {
+
+    addFKConstraint(tableName, constraintName, new String[]{keyColumn}, referenceTableName,
+      new String[]{referenceColumn}, shouldCascadeOnDelete, ignoreFailure);
+  }
+
+  @Override
+  public void addFKConstraint(String tableName, String constraintName,
+                              String[] keyColumns, String referenceTableName,
+                              String[] referenceColumns,
+                              boolean ignoreFailure) throws SQLException {
+    addFKConstraint(tableName, constraintName, keyColumns, referenceTableName, referenceColumns,
false, ignoreFailure);
   }
 
   @Override
   public void addFKConstraint(String tableName, String constraintName,
                               String[] keyColumns, String referenceTableName,
-                              String[] referenceColumns, boolean ignoreFailure) throws SQLException
{
+                              String[] referenceColumns, boolean shouldCascadeOnDelete,
+                              boolean ignoreFailure) throws SQLException {
     if (!tableHasForeignKey(tableName, referenceTableName, keyColumns, referenceColumns))
{
       String query = dbmsHelper.getAddForeignKeyStatement(tableName, constraintName,
           Arrays.asList(keyColumns),
           referenceTableName,
-          Arrays.asList(referenceColumns)
-      );
+          Arrays.asList(referenceColumns),
+          shouldCascadeOnDelete);
 
       try {
         executeQuery(query, ignoreFailure);

http://git-wip-us.apache.org/repos/asf/ambari/blob/d54457c2/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/DbmsHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/DbmsHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/DbmsHelper.java
index dcef71c..66ab314 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/DbmsHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/DbmsHelper.java
@@ -59,7 +59,8 @@ public interface DbmsHelper {
   String getAddForeignKeyStatement(String tableName, String constraintName,
                                    List<String> keyColumns,
                                    String referenceTableName,
-                                   List<String> referenceColumns);
+                                   List<String> referenceColumns,
+                                   boolean shouldCascadeOnDelete);
 
   String getAddColumnStatement(String tableName, DBAccessor.DBColumnInfo columnInfo);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d54457c2/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/GenericDbmsHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/GenericDbmsHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/GenericDbmsHelper.java
index 0ee2920..9816133 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/GenericDbmsHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/dbms/GenericDbmsHelper.java
@@ -193,12 +193,14 @@ public class GenericDbmsHelper implements DbmsHelper {
   public String getAddForeignKeyStatement(String tableName, String constraintName,
                                           List<String> keyColumns,
                                           String referenceTableName,
-                                          List<String> referenceColumns) {
+                                          List<String> referenceColumns,
+                                          boolean shouldCascadeOnDelete) {
     ForeignKeyConstraint foreignKeyConstraint = new ForeignKeyConstraint();
     foreignKeyConstraint.setName(constraintName);
     foreignKeyConstraint.setTargetTable(referenceTableName);
     foreignKeyConstraint.setSourceFields(keyColumns);
     foreignKeyConstraint.setTargetFields(referenceColumns);
+    foreignKeyConstraint.setShouldCascadeOnDelete(shouldCascadeOnDelete);
 
     TableDefinition tableDefinition = new TableDefinition();
     tableDefinition.setName(tableName);

http://git-wip-us.apache.org/repos/asf/ambari/blob/d54457c2/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
index a6a6ca2..95d8300 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
@@ -297,8 +297,8 @@ public class UpgradeCatalog200 extends AbstractUpgradeCatalog {
     columns.add(new DBColumnInfo("principal_name", String.class, 255, null, false));
     columns.add(new DBColumnInfo("host_name", String.class, 255, null, false));
     dbAccessor.createTable(KERBEROS_PRINCIPAL_HOST_TABLE, columns, "principal_name", "host_name");
-    dbAccessor.addFKConstraint(KERBEROS_PRINCIPAL_HOST_TABLE, "FK_krb_pr_host_hostname",
"host_name", "hosts", "host_name", false);
-    dbAccessor.addFKConstraint(KERBEROS_PRINCIPAL_HOST_TABLE, "FK_krb_pr_host_principalname",
"principal_name", KERBEROS_PRINCIPAL_TABLE, "principal_name", false);
+    dbAccessor.addFKConstraint(KERBEROS_PRINCIPAL_HOST_TABLE, "FK_krb_pr_host_hostname",
"host_name", "hosts", "host_name", true, false);
+    dbAccessor.addFKConstraint(KERBEROS_PRINCIPAL_HOST_TABLE, "FK_krb_pr_host_principalname",
"principal_name", KERBEROS_PRINCIPAL_TABLE, "principal_name", true, false);
   }
 
   // ----- UpgradeCatalog ----------------------------------------------------
@@ -312,7 +312,6 @@ public class UpgradeCatalog200 extends AbstractUpgradeCatalog {
     removeNagiosService();
     addNewConfigurationsFromXml();
     updateHiveDatabaseType();
-    setSecurityType();
     updateTezConfiguration();
     addMissingConfigs();
     persistHDPRepo();
@@ -394,43 +393,6 @@ public class UpgradeCatalog200 extends AbstractUpgradeCatalog {
   }
 
   /**
-   * Processes existing clusters to set it's security type as indicated by it's <code>cluster-env/security_enabled</code>
flag.
-   * <p/>
-   * If the <code>cluster-env/security_enabled</code is set to "true", the cluster's
security state
-   * will be set to "KERBEROS" since that is the only option. Else, the value will be set
to  "NONE".
-   */
-  protected void setSecurityType() {
-    AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class);
-    Clusters clusters = ambariManagementController.getClusters();
-
-    if (clusters != null) {
-      Map<String, Cluster> clusterMap = clusters.getClusters();
-
-      if (clusterMap != null) {
-        for (final Cluster cluster : clusterMap.values()) {
-          Config configClusterEnv = cluster.getDesiredConfigByType("cluster-env");
-
-          if (configClusterEnv != null) {
-            Map<String, String> properties = configClusterEnv.getProperties();
-
-            if (properties != null) {
-              String securityEnabled = properties.get("security_enabled");
-
-              if ("true".equalsIgnoreCase(securityEnabled)) {
-                // Currently the only security option is Kerberos. If security is enabled,
blindly
-                // set security type to SecurityType.KERBEROS
-                cluster.setSecurityType(SecurityType.KERBEROS);
-              } else {
-                cluster.setSecurityType(SecurityType.NONE);
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-
-  /**
    * The RemoveNagiosRunnable is used to remove Nagios from the cluster. This
    * runnable is exepected to run inside of a transation so that if any of the
    * removals fails, Nagios is returned to a valid service state.

http://git-wip-us.apache.org/repos/asf/ambari/blob/d54457c2/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
index ceacbe9..61fa5a8 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
@@ -235,9 +235,9 @@ public class UpgradeCatalog200Test {
     dbAccessor.createTable(eq("kerberos_principal_host"), capture(kerberosPrincipalHostCapture),
         eq("principal_name"), eq("host_name"));
     dbAccessor.addFKConstraint(eq("kerberos_principal_host"), eq("FK_krb_pr_host_hostname"),
-        eq("host_name"), eq("hosts"), eq("host_name"), eq(false));
+        eq("host_name"), eq("hosts"), eq("host_name"), eq(true), eq(false));
     dbAccessor.addFKConstraint(eq("kerberos_principal_host"), eq("FK_krb_pr_host_principalname"),
-        eq("principal_name"), eq("kerberos_principal"), eq("principal_name"), eq(false));
+        eq("principal_name"), eq("kerberos_principal"), eq("principal_name"), eq(true), eq(false));
 
     setViewInstancePropertyExpectations(dbAccessor, valueColumnCapture);
     setViewInstanceDataExpectations(dbAccessor, dataValueColumnCapture);
@@ -339,7 +339,6 @@ public class UpgradeCatalog200Test {
     Method updateHiveDatabaseType = UpgradeCatalog200.class.getDeclaredMethod("updateHiveDatabaseType");
     Method addNewConfigurationsFromXml = AbstractUpgradeCatalog.class.getDeclaredMethod
         ("addNewConfigurationsFromXml");
-    Method setSecurityType = UpgradeCatalog200.class.getDeclaredMethod("setSecurityType");
     Method updateTezConfiguration = UpgradeCatalog200.class.getDeclaredMethod("updateTezConfiguration");
     Method updateClusterEnvConfiguration = UpgradeCatalog200.class.getDeclaredMethod("updateClusterEnvConfiguration");
     Method updateConfigurationProperties = AbstractUpgradeCatalog.class.getDeclaredMethod
@@ -350,7 +349,6 @@ public class UpgradeCatalog200Test {
         .addMockedMethod(removeNagiosService)
         .addMockedMethod(updateHiveDatabaseType)
         .addMockedMethod(addNewConfigurationsFromXml)
-        .addMockedMethod(setSecurityType)
         .addMockedMethod(updateTezConfiguration)
         .addMockedMethod(updateConfigurationProperties)
         .addMockedMethod(updateClusterEnvConfiguration)
@@ -364,8 +362,6 @@ public class UpgradeCatalog200Test {
     
     upgradeCatalog.updateHiveDatabaseType();
     expectLastCall().once();
-    upgradeCatalog.setSecurityType();
-    expectLastCall().once();
 
     upgradeCatalog.updateTezConfiguration();
     expectLastCall().once();


Mime
View raw message