소스 검색

AMBARI-15653. Blueprint installation with Hive without Atlas fails (aonishuk)

Andrew Onishuk 9 년 전
부모
커밋
2b122b3b70

+ 20 - 12
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java

@@ -2412,19 +2412,27 @@ public class BlueprintConfigurationProcessor {
     //todo: john - this property should be removed
     hiveSiteMap.put("atlas.rest.address", new SingleHostTopologyUpdater("ATLAS_SERVER") {
       @Override
-      public String replacePropertyValue(String origValue, String host, Map<String, Map<String, String>> properties) {
-        boolean tlsEnabled = Boolean.parseBoolean(properties.get("application-properties").get("atlas.enableTLS"));
-        String scheme;
-        String port;
-        if (tlsEnabled) {
-          scheme = "https";
-          port = properties.get("application-properties").get("atlas.server.https.port");
-        } else {
-          scheme = "http";
-          port = properties.get("application-properties").get("atlas.server.http.port");
+      public String updateForClusterCreate(String propertyName,
+                                           String origValue,
+                                           Map<String, Map<String, String>> properties,
+                                           ClusterTopology topology) {
+        if (topology.getBlueprint().getServices().contains("ATLAS")) {
+          String host = topology.getHostAssignmentsForComponent("ATLAS_SERVER").iterator().next();
+          
+          boolean tlsEnabled = Boolean.parseBoolean(properties.get("application-properties").get("atlas.enableTLS"));
+          String scheme;
+          String port;
+          if (tlsEnabled) {
+            scheme = "https";
+            port = properties.get("application-properties").get("atlas.server.https.port");
+          } else {
+            scheme = "http";
+            port = properties.get("application-properties").get("atlas.server.http.port");
+          }
+  
+          return String.format("%s://%s:%s", scheme, host, port);
         }
-
-        return String.format("%s://%s:%s", scheme, host, port);
+        return origValue;
       }
     });
 

+ 32 - 0
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java

@@ -5395,6 +5395,38 @@ public class BlueprintConfigurationProcessorTest {
     assertEquals("*", leafConfigCoreSiteProps.get("hadoop.proxyuser.test-falcon-user.groups"));
   }
 
+  @Test
+  public void testHiveWithoutAtlas() throws Exception {
+    Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>();
+
+    Map<String, String> hiveProperties = new HashMap<String, String>();
+    hiveProperties.put("hive.exec.post.hooks", "");
+    hiveProperties.put("atlas.cluster.name", "primary");
+    hiveProperties.put("atlas.rest.address", "http://localhost:21000");
+    properties.put("hive-site", hiveProperties);
+
+
+    Map<String, Map<String, String>> parentProperties = new HashMap<String, Map<String, String>>();
+    Configuration parentClusterConfig = new Configuration(parentProperties,
+        Collections.<String, Map<String, Map<String, String>>>emptyMap());
+    Configuration clusterConfig = new Configuration(properties,
+        Collections.<String, Map<String, Map<String, String>>>emptyMap(), parentClusterConfig);
+
+
+    Collection<String> hgComponents1 = new HashSet<String>();
+    hgComponents1.add("HIVE_SERVER");
+    TestHostGroup group1 = new TestHostGroup("group1", hgComponents1, Collections.singleton("host1"));
+
+    Collection<TestHostGroup> hostGroups = Collections.singletonList(group1);
+
+    ClusterTopology topology = createClusterTopology(bp, clusterConfig, hostGroups);
+    BlueprintConfigurationProcessor configProcessor = new BlueprintConfigurationProcessor(topology);
+
+    configProcessor.doUpdateForClusterCreate();
+
+    assertEquals("http://localhost:21000", clusterConfig.getPropertyValue("hive-site", "atlas.rest.address"));
+  }
+  
   @Test
   public void testAtlasHiveProperties() throws Exception {
     Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>();