You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2015/12/03 09:55:51 UTC

[1/2] ambari git commit: AMBARI-14148. Exported blueprint does not contain "policymgr_external_url" property (aonishuk)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 2d7064894 -> 4a3a3affd
  refs/heads/trunk 4fbdb31d9 -> 04f420438


AMBARI-14148. Exported blueprint does not contain "policymgr_external_url" property (aonishuk)


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

Branch: refs/heads/trunk
Commit: 04f42043871fa3a7f16784329c98fe0fc0665b3b
Parents: 4fbdb31
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Thu Dec 3 10:55:36 2015 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Thu Dec 3 10:55:36 2015 +0200

----------------------------------------------------------------------
 .../BlueprintConfigurationProcessor.java        |  6 ++--
 .../stacks/HDP/2.0.6/services/stack_advisor.py  | 14 ++++++--
 .../BlueprintConfigurationProcessorTest.java    | 38 ++++++++++++++++++++
 3 files changed, 54 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/04f42043/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 7f11bb9..462bddc 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
@@ -125,11 +125,13 @@ public class BlueprintConfigurationProcessor {
   private static Pattern HOSTGROUP_PORT_REGEX = Pattern.compile("%HOSTGROUP::(\\S+?)%:?(\\d+)?");
 
   /**
-   * Statically-defined set of properties that can support using a nameservice name
+   * Statically-defined set of properties that can support HA using a nameservice name
    *   in the configuration, rather than just a host name.
+   *   This set also contains other HA properties that will be exported if the
+   *   expected hostname information is not found.
    */
   private static Set<String> configPropertiesWithHASupport =
-    new HashSet<String>(Arrays.asList("fs.defaultFS", "hbase.rootdir", "instance.volumes"));
+    new HashSet<String>(Arrays.asList("fs.defaultFS", "hbase.rootdir", "instance.volumes", "policymgr_external_url"));
 
   /**
    * Statically-defined list of filters to apply on property exports.

http://git-wip-us.apache.org/repos/asf/ambari/blob/04f42043/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
index d4d0e83..9d9e0dd 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
@@ -307,9 +307,19 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
 
     ranger_admin_hosts = self.getComponentHostNames(services, "RANGER", "RANGER_ADMIN")
     if ranger_admin_hosts:
-      ranger_admin_host = ranger_admin_hosts[0]
+      if len(ranger_admin_hosts) > 1 \
+        and services['configurations'] \
+        and 'admin-properties' in services['configurations'] and 'policymgr_external_url' in services['configurations']['admin-properties']['properties'] \
+        and services['configurations']['admin-properties']['properties']['policymgr_external_url'] \
+        and not services['configurations']['admin-properties']['properties']['policymgr_external_url'].strip().isempty():
+
+        # in case of HA deployment keep the policymgr_external_url specified in the config
+        policymgr_external_url = services['configurations']['admin-properties']['properties']['policymgr_external_url']
+      else:
+
+        ranger_admin_host = ranger_admin_hosts[0]
+        policymgr_external_url = "%s://%s:%s" % (protocol, ranger_admin_host, port)
 
-    policymgr_external_url = "%s://%s:%s" % (protocol, ranger_admin_host, port)
     putRangerAdminProperty('policymgr_external_url', policymgr_external_url)
 
     rangerServiceVersion = [service['StackServices']['service_version'] for service in services["services"] if service['StackServices']['service_name'] == 'RANGER'][0]

http://git-wip-us.apache.org/repos/asf/ambari/blob/04f42043/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 17c0157..648dabc 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
@@ -18,7 +18,10 @@
 
 package org.apache.ambari.server.controller.internal;
 
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 import org.apache.ambari.server.state.PropertyDependencyInfo;
 import org.apache.ambari.server.state.ServiceInfo;
 import org.apache.ambari.server.state.ValueAttributesInfo;
@@ -261,6 +264,41 @@ public class BlueprintConfigurationProcessorTest {
   }
 
   @Test
+  public void testDoUpdateForBlueprintExportRangerHAPolicyMgrExternalUrlProperty() throws Exception {
+    // Given
+    Map<String, String> rangerAdminProperties = Maps.newHashMap();
+    rangerAdminProperties.put("DB_FLAVOR", "test_db_flavor");
+    rangerAdminProperties.put("policymgr_external_url", "test_policymgr_external_url");
+
+
+    Map<String, Map<String, String>> properties =
+      ImmutableMap.of("admin-properties", rangerAdminProperties);
+
+
+    Configuration clusterConfig = new Configuration(properties, ImmutableMap.<String, Map<String,Map<String,String>>>of());
+
+    Collection<String> hostGroup1Components = ImmutableSet.of("RANGER_ADMIN");
+    TestHostGroup group1 = new TestHostGroup("group1", hostGroup1Components, Collections.singleton("testhost1"));
+
+    Collection<String> hostGroup2Components = ImmutableSet.of("RANGER_ADMIN");
+    TestHostGroup group2 = new TestHostGroup("group2", hostGroup2Components, Collections.singleton("testhost2"));
+
+
+    Collection<TestHostGroup> hostGroups = ImmutableSet.of(group1, group2);
+
+
+    ClusterTopology topology = createClusterTopology(bp, clusterConfig, hostGroups);
+    BlueprintConfigurationProcessor configProcessor = new BlueprintConfigurationProcessor(topology);
+
+    // When
+    configProcessor.doUpdateForBlueprintExport();
+
+    // Then
+    assertEquals("policymgr_external_url property's original value should be exported when Ranger Admin is deployed to multiple hosts.", "test_policymgr_external_url", properties.get("admin-properties").get("policymgr_external_url"));
+
+  }
+
+  @Test
   public void testDoUpdateForBlueprintExport_SingleHostProperty_specifiedInParentConfig() throws Exception {
     Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>();
     Map<String, String> yarnSiteProps = new HashMap<String, String>();


[2/2] ambari git commit: AMBARI-14148. Exported blueprint does not contain "policymgr_external_url" property (aonishuk)

Posted by ao...@apache.org.
AMBARI-14148. Exported blueprint does not contain "policymgr_external_url" property (aonishuk)


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

Branch: refs/heads/branch-2.1
Commit: 4a3a3affdfdb09731b49c471aaa6b0d98d9124e7
Parents: 2d70648
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Thu Dec 3 10:55:39 2015 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Thu Dec 3 10:55:39 2015 +0200

----------------------------------------------------------------------
 .../BlueprintConfigurationProcessor.java        |  6 ++--
 .../stacks/HDP/2.0.6/services/stack_advisor.py  | 14 ++++++--
 .../BlueprintConfigurationProcessorTest.java    | 38 ++++++++++++++++++++
 3 files changed, 54 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4a3a3aff/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 ecf2130..c6db071 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
@@ -124,11 +124,13 @@ public class BlueprintConfigurationProcessor {
   private static Pattern HOSTGROUP_PORT_REGEX = Pattern.compile("%HOSTGROUP::(\\S+?)%:?(\\d+)?");
 
   /**
-   * Statically-defined set of properties that can support using a nameservice name
+   * Statically-defined set of properties that can support HA using a nameservice name
    *   in the configuration, rather than just a host name.
+   *   This set also contains other HA properties that will be exported if the
+   *   expected hostname information is not found.
    */
   private static Set<String> configPropertiesWithHASupport =
-    new HashSet<String>(Arrays.asList("fs.defaultFS", "hbase.rootdir", "instance.volumes"));
+    new HashSet<String>(Arrays.asList("fs.defaultFS", "hbase.rootdir", "instance.volumes", "policymgr_external_url"));
 
   /**
    * Statically-defined list of filters to apply on property exports.

http://git-wip-us.apache.org/repos/asf/ambari/blob/4a3a3aff/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
index d4d0e83..9d9e0dd 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
@@ -307,9 +307,19 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
 
     ranger_admin_hosts = self.getComponentHostNames(services, "RANGER", "RANGER_ADMIN")
     if ranger_admin_hosts:
-      ranger_admin_host = ranger_admin_hosts[0]
+      if len(ranger_admin_hosts) > 1 \
+        and services['configurations'] \
+        and 'admin-properties' in services['configurations'] and 'policymgr_external_url' in services['configurations']['admin-properties']['properties'] \
+        and services['configurations']['admin-properties']['properties']['policymgr_external_url'] \
+        and not services['configurations']['admin-properties']['properties']['policymgr_external_url'].strip().isempty():
+
+        # in case of HA deployment keep the policymgr_external_url specified in the config
+        policymgr_external_url = services['configurations']['admin-properties']['properties']['policymgr_external_url']
+      else:
+
+        ranger_admin_host = ranger_admin_hosts[0]
+        policymgr_external_url = "%s://%s:%s" % (protocol, ranger_admin_host, port)
 
-    policymgr_external_url = "%s://%s:%s" % (protocol, ranger_admin_host, port)
     putRangerAdminProperty('policymgr_external_url', policymgr_external_url)
 
     rangerServiceVersion = [service['StackServices']['service_version'] for service in services["services"] if service['StackServices']['service_name'] == 'RANGER'][0]

http://git-wip-us.apache.org/repos/asf/ambari/blob/4a3a3aff/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 5b4f0c6..7dccdaa 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
@@ -18,7 +18,10 @@
 
 package org.apache.ambari.server.controller.internal;
 
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 import org.apache.ambari.server.state.PropertyDependencyInfo;
 import org.apache.ambari.server.state.ServiceInfo;
 import org.apache.ambari.server.state.ValueAttributesInfo;
@@ -261,6 +264,41 @@ public class BlueprintConfigurationProcessorTest {
   }
 
   @Test
+  public void testDoUpdateForBlueprintExportRangerHAPolicyMgrExternalUrlProperty() throws Exception {
+    // Given
+    Map<String, String> rangerAdminProperties = Maps.newHashMap();
+    rangerAdminProperties.put("DB_FLAVOR", "test_db_flavor");
+    rangerAdminProperties.put("policymgr_external_url", "test_policymgr_external_url");
+
+
+    Map<String, Map<String, String>> properties =
+      ImmutableMap.of("admin-properties", rangerAdminProperties);
+
+
+    Configuration clusterConfig = new Configuration(properties, ImmutableMap.<String, Map<String,Map<String,String>>>of());
+
+    Collection<String> hostGroup1Components = ImmutableSet.of("RANGER_ADMIN");
+    TestHostGroup group1 = new TestHostGroup("group1", hostGroup1Components, Collections.singleton("testhost1"));
+
+    Collection<String> hostGroup2Components = ImmutableSet.of("RANGER_ADMIN");
+    TestHostGroup group2 = new TestHostGroup("group2", hostGroup2Components, Collections.singleton("testhost2"));
+
+
+    Collection<TestHostGroup> hostGroups = ImmutableSet.of(group1, group2);
+
+
+    ClusterTopology topology = createClusterTopology(bp, clusterConfig, hostGroups);
+    BlueprintConfigurationProcessor configProcessor = new BlueprintConfigurationProcessor(topology);
+
+    // When
+    configProcessor.doUpdateForBlueprintExport();
+
+    // Then
+    assertEquals("policymgr_external_url property's original value should be exported when Ranger Admin is deployed to multiple hosts.", "test_policymgr_external_url", properties.get("admin-properties").get("policymgr_external_url"));
+
+  }
+
+  @Test
   public void testDoUpdateForBlueprintExport_SingleHostProperty_specifiedInParentConfig() throws Exception {
     Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>();
     Map<String, String> yarnSiteProps = new HashMap<String, String>();