Search in sources :

Example 11 with BlueprintTextProcessor

use of com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor in project cloudbreak by hortonworks.

the class HdfConfigProvider method createHdfConfig.

public HdfConfigs createHdfConfig(Set<HostGroup> hostgroups, Map<String, List<InstanceMetaData>> groupInstances, String blueprintText) {
    BlueprintTextProcessor blueprintTextProcessor = createTextProcessor(blueprintText);
    Set<String> nifiMasters = collectNifiMasters(blueprintText);
    Set<InstanceGroup> nifiIgs = collectInstanceGroupsWhichContainsNifiMasters(hostgroups, nifiMasters);
    List<String> nifiFqdns = collectFqdnsByInstanceGroupName(groupInstances, nifiIgs);
    AtomicInteger index = new AtomicInteger(0);
    String nodeIdentities = nifiFqdns.stream().map(fqdn -> String.format("<property name=\"Node Identity %s\">CN=%s, OU=NIFI</property>", index.addAndGet(1), fqdn)).collect(Collectors.joining());
    return new HdfConfigs(nodeIdentities, getProxyHostsParameter(nifiIgs, blueprintTextProcessor, groupInstances));
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) BlueprintTextProcessor(com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) Set(java.util.Set) Collectors(java.util.stream.Collectors) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Inject(javax.inject.Inject) List(java.util.List) Component(org.springframework.stereotype.Component) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BlueprintProcessorFactory(com.sequenceiq.cloudbreak.blueprint.BlueprintProcessorFactory) Map(java.util.Map) Optional(java.util.Optional) StringUtils(org.springframework.util.StringUtils) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BlueprintTextProcessor(com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Example 12 with BlueprintTextProcessor

use of com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor 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

BlueprintTextProcessor (com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor)12 Test (org.junit.Test)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)9 BlueprintPreparationObject (com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject)6 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)4 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)4 Stack (com.sequenceiq.cloudbreak.domain.Stack)4 BlueprintProcessorFactory (com.sequenceiq.cloudbreak.blueprint.BlueprintProcessorFactory)2 GeneralClusterConfigs (com.sequenceiq.cloudbreak.blueprint.templates.GeneralClusterConfigs)2 KerberosConfig (com.sequenceiq.cloudbreak.domain.KerberosConfig)2 List (java.util.List)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 Component (org.springframework.stereotype.Component)2 JsonIgnoreProperties (com.fasterxml.jackson.annotation.JsonIgnoreProperties)1 JsonPropertyOrder (com.fasterxml.jackson.annotation.JsonPropertyOrder)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 GATEWAY (com.sequenceiq.cloudbreak.api.model.InstanceGroupType.GATEWAY)1