Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 162A6200C8E for ; Thu, 8 Jun 2017 19:33:12 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 14E0C160BC3; Thu, 8 Jun 2017 17:33:12 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 34D47160BE5 for ; Thu, 8 Jun 2017 19:33:11 +0200 (CEST) Received: (qmail 45507 invoked by uid 500); 8 Jun 2017 17:33:10 -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 45250 invoked by uid 99); 8 Jun 2017 17:33:10 -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; Thu, 08 Jun 2017 17:33:10 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2CD1DDFC8B; Thu, 8 Jun 2017 17:33:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: alejandro@apache.org To: commits@ambari.apache.org Message-Id: <04250699fd934d13b0215dbeb9dd6bff@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: ambari git commit: AMBARI-21137. Blueprint export should allow tokenized values in SingleHostUpdater (Amruta Borkar via alejandro) Date: Thu, 8 Jun 2017 17:33:10 +0000 (UTC) archived-at: Thu, 08 Jun 2017 17:33:12 -0000 Repository: ambari Updated Branches: refs/heads/trunk 9c302dcd2 -> b98f07f90 AMBARI-21137. Blueprint export should allow tokenized values in SingleHostUpdater (Amruta Borkar via alejandro) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b98f07f9 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b98f07f9 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b98f07f9 Branch: refs/heads/trunk Commit: b98f07f9093a0b9635443f317e96768b2d8b8ef7 Parents: 9c302dc Author: Alejandro Fernandez Authored: Thu Jun 8 10:33:06 2017 -0700 Committer: Alejandro Fernandez Committed: Thu Jun 8 10:33:06 2017 -0700 ---------------------------------------------------------------------- .../BlueprintConfigurationProcessor.java | 19 ++++++++++++++++++- .../BlueprintConfigurationProcessorTest.java | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/b98f07f9/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java index 508bf15..7ebefdd 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java @@ -139,6 +139,11 @@ public class BlueprintConfigurationProcessor { private static Pattern LOCALHOST_PORT_REGEX = Pattern.compile("localhost:?(\\d+)?"); /** + * Compiled regex for placeholder + */ + private static final Pattern PLACEHOLDER = Pattern.compile("\\{\\{.*\\}\\}"); + + /** * Special network address */ private static String BIND_ALL_IP_ADDRESS = "0.0.0.0"; @@ -1133,7 +1138,8 @@ public class BlueprintConfigurationProcessor { if (! matchedHost && ! isNameServiceProperty(propertyName) && ! isSpecialNetworkAddress(propValue) && - ! isUndefinedAddress(propValue)) { + ! isUndefinedAddress(propValue) && + ! isPlaceholder(propValue)) { configuration.removeProperty(type, propertyName); } @@ -1143,6 +1149,17 @@ public class BlueprintConfigurationProcessor { } /** + * Determine if a property is a placeholder + * + * @param propertyValue property value + * + * @return true if the property has format "{{%s}}" + */ + private static boolean isPlaceholder(String propertyValue) { + return PLACEHOLDER.matcher(propertyValue).find(); + } + + /** * Determines if a given property name's value can include * nameservice references instead of host names. * http://git-wip-us.apache.org/repos/asf/ambari/blob/b98f07f9/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java index 24fc3c7..ca579ea 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java @@ -426,6 +426,7 @@ public class BlueprintConfigurationProcessorTest extends EasyMockSupport { Map> group2Properties = new HashMap<>(); Map group2YarnSiteProps = new HashMap<>(); group2YarnSiteProps.put("yarn.resourcemanager.resource-tracker.address", "testhost"); + group2YarnSiteProps.put("yarn.resourcemanager.webapp.https.address", "{{rm_host}}"); group2Properties.put("yarn-site", group2YarnSiteProps); // host group config -> BP config -> cluster scoped config Configuration group2BPConfiguration = new Configuration(Collections.>emptyMap(), @@ -449,6 +450,8 @@ public class BlueprintConfigurationProcessorTest extends EasyMockSupport { assertEquals("%HOSTGROUP::group1%", properties.get("yarn-site").get("yarn.resourcemanager.hostname")); assertEquals("%HOSTGROUP::group1%", group2Configuration.getPropertyValue("yarn-site", "yarn.resourcemanager.resource-tracker.address")); + assertNotNull("Placeholder property should not have been removed.", + group2Configuration.getPropertyValue("yarn-site", "yarn.resourcemanager.webapp.https.address")); } @Test