Search in sources :

Example 86 with ApiClusterTemplateConfig

use of com.cloudera.api.swagger.model.ApiClusterTemplateConfig in project cloudbreak by hortonworks.

the class CmTemplateProcessor method removeDanglingVariableReferences.

private List<ApiClusterTemplateConfig> removeDanglingVariableReferences(List<ApiClusterTemplateConfig> configs, Set<String> existingVariables, String refName) {
    if (configs != null) {
        for (Iterator<ApiClusterTemplateConfig> iter = configs.iterator(); iter.hasNext(); ) {
            ApiClusterTemplateConfig config = iter.next();
            String variable = config.getVariable();
            if (variable != null && !existingVariables.contains(variable)) {
                LOGGER.info("Removed dangling variable reference '{}': '{}' from section {}", config.getName(), variable, refName);
                iter.remove();
            }
        }
        if (configs.isEmpty()) {
            return null;
        }
    }
    return configs;
}
Also used : ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig)

Example 87 with ApiClusterTemplateConfig

use of com.cloudera.api.swagger.model.ApiClusterTemplateConfig in project cloudbreak by hortonworks.

the class CmTemplateProcessor method getCustomServiceConfigsMap.

public Map<String, List<ApiClusterTemplateConfig>> getCustomServiceConfigsMap(Set<CustomConfigurationPropertyView> configProperties) {
    Map<String, List<ApiClusterTemplateConfig>> serviceConfigsMap = new HashMap<>();
    List<CustomConfigurationPropertyView> serviceConfigs = getCustomServiceConfigs(configProperties);
    serviceConfigs.forEach(serviceConfig -> {
        serviceConfigsMap.computeIfAbsent(serviceConfig.getServiceType(), k -> new ArrayList<>());
        serviceConfigsMap.get(serviceConfig.getServiceType()).add(new ApiClusterTemplateConfig().name(serviceConfig.getName()).value(serviceConfig.getValue()));
    });
    return serviceConfigsMap;
}
Also used : HashMap(java.util.HashMap) CustomConfigurationPropertyView(com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView) List(java.util.List) ArrayList(java.util.ArrayList) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig)

Example 88 with ApiClusterTemplateConfig

use of com.cloudera.api.swagger.model.ApiClusterTemplateConfig in project cloudbreak by hortonworks.

the class CmTemplateProcessor method chooseApiClusterTemplateConfig.

private void chooseApiClusterTemplateConfig(Map<String, ApiClusterTemplateConfig> existingConfigs, ApiClusterTemplateConfig newConfig) {
    String configName = newConfig.getName();
    ApiClusterTemplateConfig existingApiClusterTemplateConfig = existingConfigs.get(configName);
    if (existingApiClusterTemplateConfig != null) {
        // OPSAPS-54706 Let's honor the safety valve settings in both bp and generated.
        if (configName.endsWith("_safety_valve")) {
            String oldConfigValue = existingApiClusterTemplateConfig.getValue();
            String newConfigValue = newConfig.getValue();
            // By CB-1452 append the bp config at the end of generated config to give precedence to it. Add a newline in between for it to be safe
            // with property file safety valves and command line safety valves.
            newConfig.setValue(newConfigValue + '\n' + oldConfigValue);
        } else {
            // Again by CB-1452 we need to give precedence to the value given in bp.
            return;
        }
    }
    existingConfigs.put(configName, newConfig);
}
Also used : ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig)

Example 89 with ApiClusterTemplateConfig

use of com.cloudera.api.swagger.model.ApiClusterTemplateConfig in project cloudbreak by hortonworks.

the class CmTemplateProcessor method addRoleConfigs.

public void addRoleConfigs(String serviceType, Map<String, List<ApiClusterTemplateConfig>> newConfigMap) {
    Optional<ApiClusterTemplateService> serviceOpt = getServiceByType(serviceType);
    if (serviceOpt.isPresent()) {
        ApiClusterTemplateService service = serviceOpt.get();
        newConfigMap.forEach((configRef, newConfigs) -> service.getRoleConfigGroups().stream().filter(rcg -> rcg.getRefName().equals(configRef)).findFirst().ifPresent(group -> mergeRoleConfigs(group, newConfigs)));
    }
}
Also used : InstanceCount(com.sequenceiq.cloudbreak.cloud.model.InstanceCount) InstanceCount.atLeast(com.sequenceiq.cloudbreak.cloud.model.InstanceCount.atLeast) LoggerFactory(org.slf4j.LoggerFactory) JsonUtil(com.sequenceiq.cloudbreak.common.json.JsonUtil) BigDecimal(java.math.BigDecimal) Collectors.toMap(java.util.stream.Collectors.toMap) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) ApiConfigureForKerberosArguments(com.cloudera.api.swagger.model.ApiConfigureForKerberosArguments) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) Collectors.toSet(java.util.stream.Collectors.toSet) ApiClusterTemplateRoleConfigGroupInfo(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroupInfo) ApiClusterTemplate(com.cloudera.api.swagger.model.ApiClusterTemplate) ClusterHostAttributes(com.sequenceiq.cloudbreak.cluster.model.ClusterHostAttributes) Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Set(java.util.Set) ApiClusterTemplateHostTemplate(com.cloudera.api.swagger.model.ApiClusterTemplateHostTemplate) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) Collectors(java.util.stream.Collectors) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) Objects(java.util.Objects) ServiceComponent(com.sequenceiq.cloudbreak.template.model.ServiceComponent) List(java.util.List) ApiEntityTag(com.cloudera.api.swagger.model.ApiEntityTag) YarnConstants(com.sequenceiq.cloudbreak.cmtemplate.configproviders.yarn.YarnConstants) ApiClusterTemplateHostInfo(com.cloudera.api.swagger.model.ApiClusterTemplateHostInfo) CollectionUtils(org.springframework.util.CollectionUtils) ApiProductVersion(com.cloudera.api.swagger.model.ApiProductVersion) ResizeRecommendation(com.sequenceiq.cloudbreak.cloud.model.ResizeRecommendation) Entry(java.util.Map.Entry) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Optional(java.util.Optional) ApiClusterTemplateClusterSpec(com.cloudera.api.swagger.model.ApiClusterTemplateClusterSpec) ApiClusterTemplateVariable(com.cloudera.api.swagger.model.ApiClusterTemplateVariable) CMRepositoryVersionUtil.isTagsResourceSupportedViaBlueprint(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.isTagsResourceSupportedViaBlueprint) NotImplementedException(org.apache.commons.lang3.NotImplementedException) ApiDataContextRef(com.cloudera.api.swagger.model.ApiDataContextRef) SiteConfigurations(com.sequenceiq.cloudbreak.template.processor.configuration.SiteConfigurations) HashMap(java.util.HashMap) ServiceAttributes(com.sequenceiq.cloudbreak.template.model.ServiceAttributes) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Enums(com.google.common.base.Enums) HashSet(java.util.HashSet) Strings(com.google.common.base.Strings) ClusterManagerType(com.sequenceiq.cloudbreak.common.type.ClusterManagerType) ApiClusterTemplateInstantiator(com.cloudera.api.swagger.model.ApiClusterTemplateInstantiator) CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited) GatewayRecommendation(com.sequenceiq.cloudbreak.cloud.model.GatewayRecommendation) BlueprintProcessingException(com.sequenceiq.cloudbreak.template.BlueprintProcessingException) Entitlement(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement) YarnRoles(com.sequenceiq.cloudbreak.cmtemplate.configproviders.yarn.YarnRoles) Nonnull(javax.annotation.Nonnull) InstanceCount.exactly(com.sequenceiq.cloudbreak.cloud.model.InstanceCount.exactly) CustomConfigurationPropertyView(com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) AutoscaleRecommendation(com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation) Optional.ofNullable(java.util.Optional.ofNullable) HostgroupConfigurations(com.sequenceiq.cloudbreak.template.processor.configuration.HostgroupConfigurations) IOException(java.io.IOException) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) TreeMap(java.util.TreeMap) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService)

Example 90 with ApiClusterTemplateConfig

use of com.cloudera.api.swagger.model.ApiClusterTemplateConfig in project cloudbreak by hortonworks.

the class CmHostGroupRoleConfigProviderProcessor method groupByHostGroupName.

private void groupByHostGroupName(TemplatePreparationObject source, Map<String, Map<String, List<ApiClusterTemplateConfig>>> configsByRoleConfigGroup, Map<String, ServiceComponent> serviceComponents, String hostGroupName, List<String> roleConfigGroups, HostgroupView hostgroupView) {
    for (String roleConfigGroup : roleConfigGroups) {
        for (CmHostGroupRoleConfigProvider provider : providers) {
            ServiceComponent serviceComponent = serviceComponents.get(roleConfigGroup);
            if (isServiceComponentEquals(provider, serviceComponent)) {
                Map<String, List<ApiClusterTemplateConfig>> configs = configsByRoleConfigGroup.computeIfAbsent(roleConfigGroup, __ -> new HashMap<>());
                configs.computeIfAbsent(hostGroupName, __ -> new ArrayList<>()).addAll(provider.getRoleConfigs(serviceComponent.getComponent(), hostgroupView, source));
            }
        }
    }
}
Also used : Logger(org.slf4j.Logger) Optional.ofNullable(java.util.Optional.ofNullable) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ApiClusterTemplateHostTemplate(com.cloudera.api.swagger.model.ApiClusterTemplateHostTemplate) Function(java.util.function.Function) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ArrayList(java.util.ArrayList) Objects(java.util.Objects) Inject(javax.inject.Inject) ServiceComponent(com.sequenceiq.cloudbreak.template.model.ServiceComponent) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) List(java.util.List) Component(org.springframework.stereotype.Component) Collectors.toMap(java.util.stream.Collectors.toMap) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) ApiClusterTemplateInstantiator(com.cloudera.api.swagger.model.ApiClusterTemplateInstantiator) Optional(java.util.Optional) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) VisibleForTesting(com.google.common.annotations.VisibleForTesting) ApiClusterTemplateRoleConfigGroupInfo(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroupInfo) ServiceComponent(com.sequenceiq.cloudbreak.template.model.ServiceComponent) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)172 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)129 Test (org.junit.Test)78 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)74 Test (org.junit.jupiter.api.Test)57 ArrayList (java.util.ArrayList)55 List (java.util.List)50 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)25 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)22 Builder (com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder)21 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)18 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)17 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)17 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)13 AccountMappingView (com.sequenceiq.cloudbreak.template.views.AccountMappingView)13 ApiClusterTemplateRoleConfigGroup (com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)12 HashMap (java.util.HashMap)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)11 BaseFileSystemConfigurationsView (com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView)9 BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)8