You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by rl...@apache.org on 2017/06/08 19:23:02 UTC
[48/50] [abbrv] ambari git commit: AMBARI-21137. Blueprint export
should allow tokenized values in SingleHostUpdater (Amruta Borkar via
alejandro)
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/branch-feature-AMBARI-20859
Commit: b98f07f9093a0b9635443f317e96768b2d8b8ef7
Parents: 9c302dc
Author: Alejandro Fernandez <af...@hortonworks.com>
Authored: Thu Jun 8 10:33:06 2017 -0700
Committer: Alejandro Fernandez <af...@hortonworks.com>
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<String, Map<String, String>> group2Properties = new HashMap<>();
Map<String, String> 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.<String, Map<String, String>>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