Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E612D17EC4 for ; Mon, 2 Feb 2015 11:32:50 +0000 (UTC) Received: (qmail 88102 invoked by uid 500); 2 Feb 2015 11:32:48 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 88002 invoked by uid 500); 2 Feb 2015 11:32:48 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 87989 invoked by uid 99); 2 Feb 2015 11:32:48 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Feb 2015 11:32:48 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 82F1FE028F; Mon, 2 Feb 2015 11:32:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aonishuk@apache.org To: commits@ambari.apache.org Date: Mon, 02 Feb 2015 11:32:49 -0000 Message-Id: <85bcadb0ba4047cb9113a12a05a9f90c@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/2] ambari git commit: AMBARI-9422. Group Add In Any Hooks Fail Because of Invalid Group Name after Upgrade (aonishuk) AMBARI-9422. Group Add In Any Hooks Fail Because of Invalid Group Name after Upgrade (aonishuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a0284cc3 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a0284cc3 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a0284cc3 Branch: refs/heads/trunk Commit: a0284cc33fa9a22359953103c0516222acb3757e Parents: 31243e4 Author: Andrew Onishuk Authored: Mon Feb 2 13:32:45 2015 +0200 Committer: Andrew Onishuk Committed: Mon Feb 2 13:32:45 2015 +0200 ---------------------------------------------------------------------- .../server/upgrade/UpgradeCatalog200.java | 35 ++++++++++++++++++++ .../server/upgrade/UpgradeCatalog200Test.java | 6 ++++ 2 files changed, 41 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/a0284cc3/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 a8b3fc3..a83d26d 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 @@ -282,9 +282,44 @@ public class UpgradeCatalog200 extends AbstractUpgradeCatalog { // remove NAGIOS to make way for the new embedded alert framework removeNagiosService(); addNewConfigurationsFromXml(); + updateDfsClusterAdmintistratorsProperty(); updateHiveDatabaseType(); setSecurityType(); } + + protected void updateDfsClusterAdmintistratorsProperty() throws AmbariException { + /* + * Remove trailing and leading whitespaces from hdfs-site/dfs.cluster.administrators + * property. + */ + AmbariManagementController ambariManagementController = injector.getInstance( + AmbariManagementController.class); + Clusters clusters = ambariManagementController.getClusters(); + + if (clusters != null) { + Map clusterMap = clusters.getClusters(); + Map prop = new HashMap(); + String properyValue = null; + + if (clusterMap != null && !clusterMap.isEmpty()) { + for (final Cluster cluster : clusterMap.values()) { + properyValue = null; + if (cluster.getDesiredConfigByType("hdfs-site") != null) { + properyValue = cluster.getDesiredConfigByType( + "hdfs-site").getProperties().get("dfs.cluster.administrators"); + } + + if (properyValue != null) { + properyValue = properyValue.trim(); + + prop.put("dfs.cluster.administrators", properyValue); + updateConfigurationPropertiesForCluster(cluster, "hdfs-site", + prop, true, false); + } + } + } + } + } protected void updateHiveDatabaseType() throws AmbariException { final String PROPERTY_NAME = "hive_database_type"; http://git-wip-us.apache.org/repos/asf/ambari/blob/a0284cc3/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 d6f9e6e..b935c29 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 @@ -307,18 +307,24 @@ public class UpgradeCatalog200Test { Method addNewConfigurationsFromXml = AbstractUpgradeCatalog.class.getDeclaredMethod ("addNewConfigurationsFromXml"); Method setSecurityType = UpgradeCatalog200.class.getDeclaredMethod("setSecurityType"); + Method updateDfsClusterAdmintistratorsProperty = UpgradeCatalog200.class.getDeclaredMethod("updateDfsClusterAdmintistratorsProperty"); UpgradeCatalog200 upgradeCatalog = createMockBuilder(UpgradeCatalog200.class) .addMockedMethod(removeNagiosService) .addMockedMethod(updateHiveDatabaseType) .addMockedMethod(addNewConfigurationsFromXml) .addMockedMethod(setSecurityType) + .addMockedMethod(updateDfsClusterAdmintistratorsProperty) .createMock(); upgradeCatalog.removeNagiosService(); expectLastCall().once(); upgradeCatalog.addNewConfigurationsFromXml(); expectLastCall(); + + upgradeCatalog.updateDfsClusterAdmintistratorsProperty(); + expectLastCall(); + upgradeCatalog.updateHiveDatabaseType(); expectLastCall().once(); upgradeCatalog.setSecurityType();