You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by js...@apache.org on 2014/11/08 03:12:13 UTC

ambari git commit: AMBARI-8226. Export topology related properties in blueprint that have undefined hosts

Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 61efc45d1 -> 464537311


AMBARI-8226.  Export topology related properties in blueprint that have undefined hosts


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

Branch: refs/heads/branch-1.7.0
Commit: 464537311d997ccaba419af0d69101dcccb2cf4d
Parents: 61efc45
Author: John Speidel <js...@hortonworks.com>
Authored: Fri Nov 7 20:35:40 2014 -0500
Committer: John Speidel <js...@hortonworks.com>
Committed: Fri Nov 7 21:11:46 2014 -0500

----------------------------------------------------------------------
 .../BlueprintConfigurationProcessor.java        | 19 ++++++++-
 .../BlueprintConfigurationProcessorTest.java    | 44 +++++++++++++++++++-
 2 files changed, 59 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/46453731/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 5af81be..f1a6110 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
@@ -342,8 +342,12 @@ public class BlueprintConfigurationProcessor {
           // except in the case of HA-related properties, that
           // can contain nameservice references instead of hostnames (Fix for Bug AMBARI-7458).
           // also will not remove properties that reference the special 0.0.0.0 network
-          // address
-          if (! matchedHost && ! isNameServiceProperty(propertyName) && !isSpecialNetworkAddress(propValue)) {
+          // address or properties with undefined hosts
+          if (! matchedHost &&
+              ! isNameServiceProperty(propertyName) &&
+              ! isSpecialNetworkAddress(propValue)  &&
+              ! isUndefinedAddress(propValue)) {
+
             typeProperties.remove(propertyName);
           }
         }
@@ -380,6 +384,17 @@ public class BlueprintConfigurationProcessor {
   }
 
   /**
+   * Determine if a property has an undefined host.
+   *
+   * @param propertyValue  property value
+   *
+   * @return true if the property value contains "undefined"
+   */
+  private static boolean isUndefinedAddress(String propertyValue) {
+    return propertyValue.contains("undefined");
+  }
+
+  /**
    * Update multi host topology configuration properties for blueprint export.
    *
    * @param hostGroups  cluster host groups

http://git-wip-us.apache.org/repos/asf/ambari/blob/46453731/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 6c00927..48b9077 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
@@ -2042,8 +2042,6 @@ public class BlueprintConfigurationProcessorTest {
     Map<String, String> kafkaBrokerProperties =
       new HashMap<String, String>();
 
-
-
     configProperties.put("core-site", coreSiteProperties);
     configProperties.put("hbase-site", hbaseSiteProperties);
     configProperties.put("webhcat-site", webHCatSiteProperties);
@@ -2232,6 +2230,48 @@ public class BlueprintConfigurationProcessorTest {
 
   }
 
+  @Test
+  public void testPropertyWithUndefinedHostisExported() throws Exception {
+    final String expectedHostName = "c6401.apache.ambari.org";
+    final String expectedHostGroupName = "host_group_1";
+
+    EasyMockSupport mockSupport = new EasyMockSupport();
+
+    HostGroup mockHostGroupOne = mockSupport.createMock(HostGroup.class);
+
+    expect(mockHostGroupOne.getHostInfo()).andReturn(Arrays.asList(expectedHostName, "serverTwo")).atLeastOnce();
+    expect(mockHostGroupOne.getName()).andReturn(expectedHostGroupName).atLeastOnce();
+
+    mockSupport.replayAll();
+
+    Map<String, Map<String, String>> configProperties = new HashMap<String, Map<String, String>>();
+
+    Map<String, String> properties = new HashMap<String, String>();
+    configProperties.put("storm-site", properties);
+
+    // setup properties that include host information including undefined host properties
+    properties.put("storm.zookeeper.servers", expectedHostName);
+    properties.put("nimbus.childopts", "undefined");
+    properties.put("worker.childopts", "some other info, undefined, more info");
+
+
+    BlueprintConfigurationProcessor configProcessor =
+        new BlueprintConfigurationProcessor(configProperties);
+
+    // call top-level export method
+    configProcessor.doUpdateForBlueprintExport(Arrays.asList(mockHostGroupOne));
+
+    assertEquals("Property was incorrectly exported",
+        "%HOSTGROUP::" + expectedHostGroupName + "%", properties.get("storm.zookeeper.servers"));
+    assertEquals("Property with undefined host was incorrectly exported",
+        "undefined", properties.get("nimbus.childopts"));
+    assertEquals("Property with undefined host was incorrectly exported",
+        "some other info, undefined, more info" , properties.get("worker.childopts"));
+
+    mockSupport.verifyAll();
+  }
+
+
   private static String createExportedAddress(String expectedPortNum, String expectedHostGroupName) {
     return createExportedHostName(expectedHostGroupName) + ":" + expectedPortNum;
   }