ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnettle...@apache.org
Subject ambari git commit: AMBARI-9036. Deploying Storm via a Blueprint without Ganglia fails. (rnettleton)
Date Thu, 08 Jan 2015 17:13:06 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk aa41e110a -> a49cf5858


AMBARI-9036. Deploying Storm via a Blueprint without Ganglia fails. (rnettleton)


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

Branch: refs/heads/trunk
Commit: a49cf5858fdda5446a6b2b7463d45d7985b076f9
Parents: aa41e11
Author: Bob Nettleton <rnettleton@hortonworks.com>
Authored: Thu Jan 8 12:12:21 2015 -0500
Committer: Bob Nettleton <rnettleton@hortonworks.com>
Committed: Thu Jan 8 12:12:21 2015 -0500

----------------------------------------------------------------------
 .../BlueprintConfigurationProcessor.java        |  34 +++++-
 .../BlueprintConfigurationProcessorTest.java    | 109 +++++++++++++++++++
 2 files changed, 140 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a49cf585/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 807723e..d7b4498 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
@@ -701,6 +701,34 @@ public class BlueprintConfigurationProcessor {
   }
 
   /**
+   * Extension of SingleHostTopologyUpdater that supports the
+   * notion of an optional service.  An example: the Storm
+   * service has config properties that require the location
+   * of the Ganglia server when Ganglia is deployed, but Storm
+   * should also start properly without Ganglia.
+   *
+   * This updater detects the case when the specified component
+   * is not found, and returns the original property value.
+   *
+   */
+  private static class OptionalSingleHostTopologyUpdater extends SingleHostTopologyUpdater
{
+
+    public OptionalSingleHostTopologyUpdater(String component) {
+      super(component);
+    }
+
+    @Override
+    public String updateForClusterCreate(Map<String, ? extends HostGroup> hostGroups,
String origValue, Map<String, Map<String, String>> properties, Stack stackDefinition)
{
+      try {
+        return super.updateForClusterCreate(hostGroups, origValue, properties, stackDefinition);
+      } catch (IllegalArgumentException illegalArgumentException) {
+        // return the original value, since the optional component is not available in this
cluster
+        return origValue;
+      }
+    }
+  }
+
+  /**
    * Topology based updater which replaces the original host name of a database property
with the host name
    * where the DB is deployed in the new cluster.  If an existing database is specified,
the original property
    * value is returned.
@@ -1161,9 +1189,9 @@ public class BlueprintConfigurationProcessor {
 
     // STORM
     stormSiteMap.put("nimbus.host", new SingleHostTopologyUpdater("NIMBUS"));
-    stormSiteMap.put("worker.childopts", new SingleHostTopologyUpdater("GANGLIA_SERVER"));
-    stormSiteMap.put("supervisor.childopts", new SingleHostTopologyUpdater("GANGLIA_SERVER"));
-    stormSiteMap.put("nimbus.childopts", new SingleHostTopologyUpdater("GANGLIA_SERVER"));
+    stormSiteMap.put("worker.childopts", new OptionalSingleHostTopologyUpdater("GANGLIA_SERVER"));
+    stormSiteMap.put("supervisor.childopts", new OptionalSingleHostTopologyUpdater("GANGLIA_SERVER"));
+    stormSiteMap.put("nimbus.childopts", new OptionalSingleHostTopologyUpdater("GANGLIA_SERVER"));
     multiStormSiteMap.put("storm.zookeeper.servers",
         new YamlMultiValuePropertyDecorator(new MultipleHostTopologyUpdater("ZOOKEEPER_SERVER")));
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/a49cf585/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 3796bbb..167e8fa 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
@@ -1223,6 +1223,115 @@ public class BlueprintConfigurationProcessorTest {
   }
 
   @Test
+  public void testStormConfigClusterUpdateWithoutGangliaServer() throws Exception {
+    final String expectedHostGroupName = "host_group_1";
+
+    EasyMockSupport mockSupport = new EasyMockSupport();
+
+    HostGroup mockHostGroupOne = mockSupport.createMock(HostGroup.class);
+    Stack mockStack = mockSupport.createMock(Stack.class);
+
+    // simulate the case where Ganglia is not available in the cluster
+    expect(mockHostGroupOne.getComponents()).andReturn(Collections.<String>emptySet()).atLeastOnce();
+    expect(mockStack.getCardinality("GANGLIA_SERVER")).andReturn(new Cardinality("1")).atLeastOnce();
+
+    mockSupport.replayAll();
+
+    Map<String, Map<String, String>> configProperties =
+      new HashMap<String, Map<String, String>>();
+
+    Map<String, String> stormSiteProperties =
+      new HashMap<String, String>();
+
+    configProperties.put("storm-site", stormSiteProperties);
+
+    stormSiteProperties.put("worker.childopts", "localhost");
+    stormSiteProperties.put("supervisor.childopts", "localhost");
+    stormSiteProperties.put("nimbus.childopts", "localhost");
+
+
+    // setup properties that include host information
+
+    BlueprintConfigurationProcessor configProcessor =
+      new BlueprintConfigurationProcessor(configProperties);
+
+    Map<String, HostGroup> mapOfHostGroups =
+      new HashMap<String, HostGroup>();
+    mapOfHostGroups.put(expectedHostGroupName, mockHostGroupOne);
+
+    // call top-level export method
+    configProcessor.doUpdateForClusterCreate(mapOfHostGroups, mockStack);
+
+    // verify that the server name is not replaced, since the GANGLIA_SERVER
+    // component is not available
+    assertEquals("worker startup settings not properly handled by cluster create",
+      "localhost", stormSiteProperties.get("worker.childopts"));
+
+    assertEquals("supervisor startup settings not properly handled by cluster create",
+      "localhost", stormSiteProperties.get("supervisor.childopts"));
+
+    assertEquals("nimbus startup settings not properly handled by cluster create",
+      "localhost", stormSiteProperties.get("nimbus.childopts"));
+
+    mockSupport.verifyAll();
+  }
+
+  @Test
+  public void testStormConfigClusterUpdateWithGangliaServer() 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);
+    Stack mockStack = mockSupport.createMock(Stack.class);
+
+    expect(mockHostGroupOne.getHostInfo()).andReturn(Arrays.asList(expectedHostName, "serverTwo")).atLeastOnce();
+    // simulate the case where Ganglia is available in the cluster
+    expect(mockHostGroupOne.getComponents()).andReturn(Collections.singleton("GANGLIA_SERVER")).atLeastOnce();
+
+    mockSupport.replayAll();
+
+    Map<String, Map<String, String>> configProperties =
+      new HashMap<String, Map<String, String>>();
+
+    Map<String, String> stormSiteProperties =
+      new HashMap<String, String>();
+
+    configProperties.put("storm-site", stormSiteProperties);
+
+    stormSiteProperties.put("worker.childopts", "localhost");
+    stormSiteProperties.put("supervisor.childopts", "localhost");
+    stormSiteProperties.put("nimbus.childopts", "localhost");
+
+
+    // setup properties that include host information
+
+    BlueprintConfigurationProcessor configProcessor =
+      new BlueprintConfigurationProcessor(configProperties);
+
+    Map<String, HostGroup> mapOfHostGroups =
+      new HashMap<String, HostGroup>();
+    mapOfHostGroups.put(expectedHostGroupName, mockHostGroupOne);
+
+    // call top-level export method
+    configProcessor.doUpdateForClusterCreate(mapOfHostGroups, mockStack);
+
+    // verify that the server name is not replaced, since the GANGLIA_SERVER
+    // component is not available
+    assertEquals("worker startup settings not properly handled by cluster create",
+      expectedHostName, stormSiteProperties.get("worker.childopts"));
+
+    assertEquals("supervisor startup settings not properly handled by cluster create",
+      expectedHostName, stormSiteProperties.get("supervisor.childopts"));
+
+    assertEquals("nimbus startup settings not properly handled by cluster create",
+      expectedHostName, stormSiteProperties.get("nimbus.childopts"));
+
+    mockSupport.verifyAll();
+  }
+
+  @Test
   public void testDoUpdateForClusterWithNameNodeHAEnabled() throws Exception {
     final String expectedNameService = "mynameservice";
     final String expectedHostName = "c6401.apache.ambari.org";


Mime
View raw message