Search in sources :

Example 16 with HostgroupView

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();
}
Also used : JsonPropertyOrder(com.fasterxml.jackson.annotation.JsonPropertyOrder) BlueprintPreparationObject(com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject) LoggerFactory(org.slf4j.LoggerFactory) Function(java.util.function.Function) BlueprintComponentConfigProvider(com.sequenceiq.cloudbreak.blueprint.BlueprintComponentConfigProvider) GATEWAY(com.sequenceiq.cloudbreak.api.model.InstanceGroupType.GATEWAY) BlueprintConfigurationEntry(com.sequenceiq.cloudbreak.blueprint.BlueprintConfigurationEntry) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Value(org.springframework.beans.factory.annotation.Value) HostgroupView(com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView) Json(com.sequenceiq.cloudbreak.domain.json.Json) Logger(org.slf4j.Logger) BlueprintTextProcessor(com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor) SmartsenseConfigurationLocator(com.sequenceiq.cloudbreak.blueprint.SmartsenseConfigurationLocator) Collection(java.util.Collection) Set(java.util.Set) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Collectors(java.util.stream.Collectors) List(java.util.List) Component(org.springframework.stereotype.Component) BlueprintProcessorFactory(com.sequenceiq.cloudbreak.blueprint.BlueprintProcessorFactory) Optional(java.util.Optional) CloudbreakNodeConfig(com.sequenceiq.cloudbreak.ha.CloudbreakNodeConfig) JsonIgnoreProperties(com.fasterxml.jackson.annotation.JsonIgnoreProperties) HostgroupView(com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView)

Aggregations

HostgroupView (com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView)16 Test (org.junit.Test)13 HashMap (java.util.HashMap)10 Map (java.util.Map)10 Collections.emptyMap (java.util.Collections.emptyMap)9 Collections.singletonMap (java.util.Collections.singletonMap)9 Set (java.util.Set)6 Collections.emptySet (java.util.Collections.emptySet)4 JsonIgnoreProperties (com.fasterxml.jackson.annotation.JsonIgnoreProperties)1 JsonPropertyOrder (com.fasterxml.jackson.annotation.JsonPropertyOrder)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 GATEWAY (com.sequenceiq.cloudbreak.api.model.InstanceGroupType.GATEWAY)1 BlueprintComponentConfigProvider (com.sequenceiq.cloudbreak.blueprint.BlueprintComponentConfigProvider)1 BlueprintConfigurationEntry (com.sequenceiq.cloudbreak.blueprint.BlueprintConfigurationEntry)1 BlueprintPreparationObject (com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject)1 BlueprintProcessingException (com.sequenceiq.cloudbreak.blueprint.BlueprintProcessingException)1 BlueprintProcessorFactory (com.sequenceiq.cloudbreak.blueprint.BlueprintProcessorFactory)1 BlueprintTextProcessor (com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor)1 SmartsenseConfigurationLocator (com.sequenceiq.cloudbreak.blueprint.SmartsenseConfigurationLocator)1