use of com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView in project cloudbreak by hortonworks.
the class SmartSenseConfigProvider method addSmartSenseServerToBp.
private String addSmartSenseServerToBp(BlueprintTextProcessor blueprintProcessor, Iterable<HostgroupView> hostgroupViews, Collection<String> hostGroupNames) {
if (!blueprintProcessor.componentExistsInBlueprint(HST_SERVER_COMPONENT)) {
String aHostGroupName = hostGroupNames.stream().findFirst().get();
boolean singleNodeGatewayFound = false;
for (HostgroupView hostGroup : hostgroupViews) {
if (hostGroup.isInstanceGroupConfigured() && GATEWAY.equals(hostGroup.getInstanceGroupType()) && hostGroup.getNodeCount().equals(1)) {
aHostGroupName = hostGroup.getName();
singleNodeGatewayFound = true;
break;
}
}
if (!singleNodeGatewayFound && blueprintProcessor.componentExistsInBlueprint(RESOURCEMANAGER_COMPONENT)) {
Optional<String> hostGroupNameOfNameNode = hostGroupNames.stream().filter(hGName -> blueprintProcessor.getComponentsInHostGroup(hGName).contains(RESOURCEMANAGER_COMPONENT)).findFirst();
if (hostGroupNameOfNameNode.isPresent()) {
aHostGroupName = hostGroupNameOfNameNode.get();
}
}
LOGGER.info("Adding '{}' component to '{}' hosgroup in the Blueprint.", HST_SERVER_COMPONENT, aHostGroupName);
final String finalAHostGroupName = aHostGroupName;
blueprintProcessor.addComponentToHostgroups(HST_SERVER_COMPONENT, hg -> finalAHostGroupName.equals(hg));
}
return blueprintProcessor.asText();
}
Aggregations