AMBARI-22253. Fix impossible condition during cluster creation (adoroszlai)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/cc0eabf9 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/cc0eabf9 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/cc0eabf9 Branch: refs/heads/branch-feature-AMBARI-14714-blueprintv2 Commit: cc0eabf9a221de2132b8b505efe75b77248c10ca Parents: 60a5253 Author: Doroszlai, Attila <adorosz...@hortonworks.com> Authored: Wed Dec 6 10:29:02 2017 +0100 Committer: Doroszlai, Attila <adorosz...@hortonworks.com> Committed: Fri Dec 8 20:24:25 2017 +0100 ---------------------------------------------------------------------- .../ambari/server/topology/AmbariContext.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/cc0eabf9/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java index 70850fb..da03f3c 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java @@ -338,17 +338,18 @@ public class AmbariContext { for (Map.Entry<Service, ? extends Iterable<ComponentV2>> entry : components.entrySet()) { Service service = entry.getKey(); - for (ComponentV2 component : entry.getValue()) { - //todo: handle this in a generic manner. These checks are all over the code - try { - if (cluster.getService(service.getName()) != null && !RootComponent.AMBARI_SERVER.name().equals("AMBARI_SERVER")) { - requests.add(new ServiceComponentHostRequest(clusterName, service.getServiceGroup().getName(), - service.getName(), component.getName(), hostName, null)); - + try { + if (cluster.getService(service.getName()) != null) { + for (ComponentV2 component : entry.getValue()) { + //todo: handle this in a generic manner. These checks are all over the code + if (!RootComponent.AMBARI_SERVER.name().equals(component.getType())) { + requests.add(new ServiceComponentHostRequest(clusterName, service.getServiceGroup().getName(), + service.getName(), component.getName(), hostName, null)); + } } - } catch(AmbariException se) { - LOG.warn("Service already deleted from cluster: {}", service); } + } catch(AmbariException se) { + LOG.warn("Service already deleted from cluster: {}", service); } } try {