Source:
<code>private RecommendationWrapper getRecommendationWrapperFromAmbariHostGroups() { final Blueprint.Builder blueprintBuilder = new Blueprint.Builder(); final Bindings.Builder bindingsBuilder = new Bindings.Builder(); for (AmbariHostGroup ambariHostGroup : getHostGroups()) { HostGroup.Builder hostGroupBuilder = new HostGroup.Builder() .setName(ambariHostGroup.getDisplayName()) .addComponents(ambariHostGroup.getComponents()); if (componentsByNode.containsKey(ambariHostGroup.getDisplayName())) { hostGroupBuilder.addComponents(componentsByNode.get(ambariHostGroup.getDisplayName())); } blueprintBuilder.addHostGroup(hostGroupBuilder.build()); bindingsBuilder.addHostGroup(new HostGroup.Builder() .setName(ambariHostGroup.getDisplayName()) .addHosts(ambariHostGroup.getHostFQDNs()) .build()); } List<String> serverComponentsList = getConfig(AmbariCluster.SERVER_COMPONENTS); if (!serverComponentsList.isEmpty()) { HostGroup.Builder hostGroupBuilder = new HostGroup.Builder() .setName("server-group") .addComponents(serverComponentsList); if (componentsByNode.containsKey("server-group")) { hostGroupBuilder.addComponents(componentsByNode.get("server-group")); } blueprintBuilder.addHostGroup(hostGroupBuilder.build()); bindingsBuilder.addHostGroup(new HostGroup.Builder() .setName("server-group") <START> .addHosts(ImmutableList.of(Iterables.getFirst(Entities.descendants(this, AmbariServer.class), null).getFqdn())) <END> .build()); } return new RecommendationWrapper.Builder() .setStack(new Stack.Builder() .setName(getConfig(HADOOP_STACK_NAME)) .setVersion(getConfig(HADOOP_STACK_VERSION)) .build()) .setRecommendation(new Recommendation.Builder() .setBlueprint(blueprintBuilder.build()) .setBindings(bindingsBuilder.build()) .build()) .build(); }</code><technical_language>if list of FQDNs get list of getAmbariServers() servers mapped</technical_language>

Target:
private RecommendationWrapper getRecommendationWrapperFromAmbariHostGroups() { final Blueprint.Builder blueprintBuilder = new Blueprint.Builder(); final Bindings.Builder bindingsBuilder = new Bindings.Builder(); for (AmbariHostGroup ambariHostGroup : getHostGroups()) { HostGroup.Builder hostGroupBuilder = new HostGroup.Builder() .setName(ambariHostGroup.getDisplayName()) .addComponents(ambariHostGroup.getComponents()); if (componentsByNode.containsKey(ambariHostGroup.getDisplayName())) { hostGroupBuilder.addComponents(componentsByNode.get(ambariHostGroup.getDisplayName())); } blueprintBuilder.addHostGroup(hostGroupBuilder.build()); bindingsBuilder.addHostGroup(new HostGroup.Builder() .setName(ambariHostGroup.getDisplayName()) .addHosts(ambariHostGroup.getHostFQDNs()) .build()); } List<String> serverComponentsList = getConfig(AmbariCluster.SERVER_COMPONENTS); if (!serverComponentsList.isEmpty()) { HostGroup.Builder hostGroupBuilder = new HostGroup.Builder() .setName("server-group") .addComponents(serverComponentsList); if (componentsByNode.containsKey("server-group")) { hostGroupBuilder.addComponents(componentsByNode.get("server-group")); } blueprintBuilder.addHostGroup(hostGroupBuilder.build()); Iterable<AmbariServer> ambariServers = getAmbariServers(); Iterable<String> fqdns = Iterables.transform(ambariServers, mapAmbariServerToFQDN); bindingsBuilder.addHostGroup(new HostGroup.Builder() .setName("server-group") .addHosts(Lists.newArrayList(fqdns)) .build()); } return new RecommendationWrapper.Builder() .setStack(new Stack.Builder() .setName(getConfig(HADOOP_STACK_NAME)) .setVersion(getConfig(HADOOP_STACK_VERSION)) .build()) .setRecommendation(new Recommendation.Builder() .setBlueprint(blueprintBuilder.build()) .setBindings(bindingsBuilder.build()) .build()) .build(); }