Search in sources :

Example 1 with SiteConfiguration

use of com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfiguration in project cloudbreak by hortonworks.

the class BlueprintTextProcessor method addSiteToSettings.

private void addSiteToSettings(ArrayNode settings, String siteName, List<SiteConfiguration> siteList) {
    ObjectNode config = settings.addObject();
    ArrayNode siteNodeArray = config.putArray(siteName);
    for (SiteConfiguration site : siteList) {
        ObjectNode siteNode = siteNodeArray.addObject();
        putAll(siteNode, site.getProperties());
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SiteConfiguration(com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfiguration) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 2 with SiteConfiguration

use of com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfiguration in project cloudbreak by hortonworks.

the class BlueprintTextProcessor method extendBlueprintHostGroupConfiguration.

public BlueprintTextProcessor extendBlueprintHostGroupConfiguration(HostgroupConfigurations hostGroupConfig, boolean forced) {
    ArrayNode configurations = getArrayFromNodeByNodeName(blueprint, CONFIGURATIONS_NODE);
    ArrayNode hostgroups = getArrayFromObjectNodeByPath(blueprint, HOST_GROUPS_NODE);
    HostgroupConfigurations filteredConfiguraitons = hostGroupConfig.getFilteredConfigs(getExistingParametersFromGlobals(configurations), forced);
    for (HostgroupConfiguration filteredConfig : filteredConfiguraitons) {
        ObjectNode hostgroup = getHostgroup(hostgroups, filteredConfig.getName());
        JsonNode hostgroupConfig = hostgroup.path(CONFIGURATIONS_NODE);
        if (hostgroupConfig.isMissingNode()) {
            ArrayNode hostgroupConfigs = hostgroup.putArray(CONFIGURATIONS_NODE);
            for (SiteConfiguration e : filteredConfig.getSiteConfigs()) {
                addSiteToHostgroupConfiguration(hostgroupConfigs, e.getName(), e.getProperties());
            }
        } else {
            for (SiteConfiguration e : filteredConfig.getSiteConfigs()) {
                ArrayNode hostgroupConfigs = (ArrayNode) hostgroupConfig;
                String siteName = e.getName();
                ObjectNode site = (ObjectNode) hostgroupConfigs.findValue(siteName);
                if (site == null) {
                    addSiteToHostgroupConfiguration(hostgroupConfigs, siteName, e.getProperties());
                } else {
                    ObjectNode objectToModify = (ObjectNode) site.get(PROPERTIES_NODE);
                    if (objectToModify == null) {
                        objectToModify = site;
                    }
                    putAllObjects(objectToModify, e.getProperties(), forced);
                }
            }
        }
    }
    return this;
}
Also used : HostgroupConfiguration(com.sequenceiq.cloudbreak.blueprint.configuration.HostgroupConfiguration) HostgroupConfigurations(com.sequenceiq.cloudbreak.blueprint.configuration.HostgroupConfigurations) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SiteConfiguration(com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfiguration) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 3 with SiteConfiguration

use of com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfiguration in project cloudbreak by hortonworks.

the class BlueprintTextProcessor method extendBlueprintGlobalConfiguration.

public BlueprintTextProcessor extendBlueprintGlobalConfiguration(SiteConfigurations globalConfig, boolean forced) {
    JsonNode configurations = blueprint.path(CONFIGURATIONS_NODE);
    if (configurations.isMissingNode() && globalConfig != null && !globalConfig.isEmpty()) {
        configurations = blueprint.putArray(CONFIGURATIONS_NODE);
        for (SiteConfiguration site : globalConfig) {
            addSiteToConfiguration((ArrayNode) configurations, site);
        }
    } else {
        if (globalConfig != null) {
            for (SiteConfiguration site : globalConfig) {
                ObjectNode siteNode = (ObjectNode) configurations.findValue(site.getName());
                if (siteNode == null) {
                    addSiteToConfiguration((ArrayNode) configurations, site);
                } else {
                    ObjectNode objectToModify = (ObjectNode) siteNode.get(PROPERTIES_NODE);
                    if (objectToModify == null) {
                        objectToModify = siteNode;
                    }
                    putAllObjects(objectToModify, site.getProperties(), forced);
                }
            }
        }
    }
    return this;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SiteConfiguration(com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfiguration) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 4 with SiteConfiguration

use of com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfiguration in project cloudbreak by hortonworks.

the class BlueprintTextProcessor method putAllSettings.

private void putAllSettings(ArrayNode siteNode, List<SiteConfiguration> siteList) {
    for (SiteConfiguration conf : siteList) {
        ObjectNode replace = findBestMatch(siteNode, conf);
        if (replace == null) {
            replace = siteNode.addObject();
        }
        replace.removeAll();
        putAll(replace, conf.getProperties());
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SiteConfiguration(com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfiguration)

Example 5 with SiteConfiguration

use of com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfiguration in project cloudbreak by hortonworks.

the class BlueprintTextProcessor method putAllSettingsIfAbsent.

private void putAllSettingsIfAbsent(ArrayNode siteNode, List<SiteConfiguration> siteList) {
    for (SiteConfiguration conf : siteList) {
        ObjectNode replace = findBestMatch(siteNode, conf);
        if (replace != null) {
            continue;
        }
        replace = siteNode.addObject();
        putAll(replace, conf.getProperties());
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SiteConfiguration(com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfiguration)

Aggregations

ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 SiteConfiguration (com.sequenceiq.cloudbreak.blueprint.configuration.SiteConfiguration)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 HostgroupConfiguration (com.sequenceiq.cloudbreak.blueprint.configuration.HostgroupConfiguration)1 HostgroupConfigurations (com.sequenceiq.cloudbreak.blueprint.configuration.HostgroupConfigurations)1