AMBARI-22297. componentInfos should be keyed by component name, not service 
name (adoroszlai)


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

Branch: refs/heads/branch-feature-AMBARI-14714-blueprintv2
Commit: e6b0f513198481efc5c9a12b238184aa0ed2b6fa
Parents: 9d30bed
Author: Attila Doroszlai <adorosz...@hortonworks.com>
Authored: Thu Nov 16 20:36:28 2017 +0100
Committer: Doroszlai, Attila <adorosz...@hortonworks.com>
Committed: Fri Nov 24 13:30:45 2017 +0100

----------------------------------------------------------------------
 .../server/controller/StackV2Factory.java       | 21 ++++++++------------
 1 file changed, 8 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e6b0f513/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
index 5d3bcfd..201fcb1 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
@@ -18,16 +18,12 @@
 
 package org.apache.ambari.server.controller;
 
-import static java.util.AbstractMap.SimpleImmutableEntry;
-
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.stream.Collectors;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
@@ -97,19 +93,18 @@ public class StackV2Factory {
   }
 
   private void getComponentInfos(StackData stackData) {
-    List<Map.Entry<String, String>> componentServices = 
stackData.serviceComponents.entrySet().stream().
-      flatMap(e -> e.getValue().stream().map( v -> new 
SimpleImmutableEntry<>(e.getKey(), v))).
-      collect(Collectors.toList());
-    componentServices.forEach( componentService -> {
+    stackData.componentService.forEach( (componentName, serviceName) -> {
       try {
-        ComponentInfo componentInfo = 
controller.getAmbariMetaInfo().getComponent(stackData.stackName,
-          stackData.stackVersion, componentService.getKey(), 
componentService.getValue());
+        ComponentInfo componentInfo = 
controller.getAmbariMetaInfo().getComponent(stackData.stackName, 
stackData.stackVersion, serviceName, componentName);
         if (null != componentInfo) {
-          stackData.componentInfos.put(componentService.getKey(), 
componentInfo);
+          stackData.componentInfos.put(componentName, componentInfo);
+        } else {
+          LOG.debug("No component info for service: {}, component: {}, stack 
name: {}, stack version: {}",
+            serviceName, componentName, stackData.stackName, 
stackData.stackVersion);
         }
       } catch (AmbariException e) {
-        LOG.debug("No component info for service: {}, component: {}, stack 
name: {}, stack version: {}, Exception: {}",
-          componentService.getKey(), componentService.getValue(), 
stackData.stackName, stackData.stackVersion, e);
+        LOG.debug("No component info for service: {}, component: {}, stack 
name: {}, stack version: {}",
+          serviceName, componentName, stackData.stackName, 
stackData.stackVersion, e);
       }
     });
   }

Reply via email to