Search in sources :

Example 11 with ApiClusterTemplateRoleConfigGroup

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

the class CmTemplateProcessor method extendTemplateWithAdditionalServices.

public void extendTemplateWithAdditionalServices(Map<String, ApiClusterTemplateService> hostGroupServices) {
    for (Entry<String, ApiClusterTemplateService> hostGroupService : hostGroupServices.entrySet()) {
        ApiClusterTemplateService service = hostGroupService.getValue();
        List<String> serviceRefNames = service.getRoleConfigGroups().stream().map(ApiClusterTemplateRoleConfigGroup::getRefName).collect(Collectors.toList());
        if (getServiceByType(service.getServiceType()).isEmpty()) {
            cmTemplate.addServicesItem(service);
        }
        cmTemplate.getHostTemplates().stream().filter(hostTemplate -> hostTemplate.getRefName().equals(hostGroupService.getKey())).forEach(ht -> ht.getRoleConfigGroupsRefNames().addAll(serviceRefNames));
    }
}
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 12 with ApiClusterTemplateRoleConfigGroup

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

the class CmTemplateProcessor method addInstantiator.

public void addInstantiator(ClouderaManagerRepo clouderaManagerRepoDetails, TemplatePreparationObject templatePreparationObject, String sdxContextName) {
    ApiClusterTemplateInstantiator instantiator = ofNullable(cmTemplate.getInstantiator()).orElseGet(ApiClusterTemplateInstantiator::new);
    if (instantiator.getClusterName() == null) {
        instantiator.setClusterName(templatePreparationObject.getGeneralClusterConfigs().getClusterName());
    }
    addCmVersionDependantConfigs(clouderaManagerRepoDetails, templatePreparationObject, instantiator);
    for (ApiClusterTemplateService service : ofNullable(cmTemplate.getServices()).orElse(List.of())) {
        List<String> nonBaseRefs = ofNullable(service.getRoleConfigGroups()).orElse(List.of()).stream().filter(rcg -> rcg.getBase() == null || !rcg.getBase()).map(ApiClusterTemplateRoleConfigGroup::getRefName).collect(Collectors.toList());
        for (String nonBaseRef : nonBaseRefs) {
            instantiator.addRoleConfigGroupsItem(new ApiClusterTemplateRoleConfigGroupInfo().rcgRefName(nonBaseRef));
        }
    }
    ofNullable(sdxContextName).map(name -> List.of(new ApiDataContextRef().name(name))).map(apiDataContextRefs -> new ApiClusterTemplateClusterSpec().dataContextRefs(apiDataContextRefs)).ifPresent(instantiator::clusterSpec);
    cmTemplate.setInstantiator(instantiator);
}
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) ApiDataContextRef(com.cloudera.api.swagger.model.ApiDataContextRef) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateInstantiator(com.cloudera.api.swagger.model.ApiClusterTemplateInstantiator) ApiClusterTemplateRoleConfigGroupInfo(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroupInfo) ApiClusterTemplateClusterSpec(com.cloudera.api.swagger.model.ApiClusterTemplateClusterSpec)

Example 13 with ApiClusterTemplateRoleConfigGroup

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

the class KnoxGatewayConfigProvider method createBaseKnoxService.

private ApiClusterTemplateService createBaseKnoxService() {
    ApiClusterTemplateService knox = new ApiClusterTemplateService().serviceType(KnoxRoles.KNOX).refName(KNOX_SERVICE_REF_NAME);
    ApiClusterTemplateRoleConfigGroup knoxGateway = new ApiClusterTemplateRoleConfigGroup().roleType(KnoxRoles.KNOX_GATEWAY).base(true).refName(KNOX_GATEWAY_REF_NAME);
    knox.roleConfigGroups(List.of(knoxGateway));
    return knox;
}
Also used : ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)

Example 14 with ApiClusterTemplateRoleConfigGroup

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

the class AbstractRoleConfigProvider method getRoleConfigs.

@Override
public Map<String, List<ApiClusterTemplateConfig>> getRoleConfigs(CmTemplateProcessor cmTemplate, TemplatePreparationObject source) {
    Optional<ApiClusterTemplateService> service = cmTemplate.getServiceByType(getServiceType());
    if (service.isEmpty()) {
        return Map.of();
    }
    Map<String, List<ApiClusterTemplateConfig>> configs = new HashMap<>();
    for (ApiClusterTemplateRoleConfigGroup rcg : ofNullable(service.get().getRoleConfigGroups()).orElse(new ArrayList<>())) {
        String roleType = rcg.getRoleType();
        if (roleType != null && getRoleTypes().contains(roleType)) {
            configs.put(rcg.getRefName(), getRoleConfigs(roleType, source));
        }
    }
    return configs;
}
Also used : HashMap(java.util.HashMap) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) ArrayList(java.util.ArrayList) List(java.util.List)

Example 15 with ApiClusterTemplateRoleConfigGroup

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

the class CoreConfigProvider method createBaseCoreSettingsService.

private ApiClusterTemplateService createBaseCoreSettingsService() {
    ApiClusterTemplateService coreSettings = new ApiClusterTemplateService().serviceType(CORE_SETTINGS).refName(CORE_SETTINGS_SERVICE_REF_NAME);
    ApiClusterTemplateRoleConfigGroup coreSettingsRole = new ApiClusterTemplateRoleConfigGroup().roleType(STORAGEOPERATIONS).base(true).refName(CORE_SETTINGS_REF_NAME);
    coreSettings.roleConfigGroups(List.of(coreSettingsRole));
    return coreSettings;
}
Also used : ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)

Aggregations

ApiClusterTemplateRoleConfigGroup (com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)25 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)22 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)11 ArrayList (java.util.ArrayList)11 List (java.util.List)11 HashMap (java.util.HashMap)10 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)9 Test (org.junit.jupiter.api.Test)8 ApiClusterTemplate (com.cloudera.api.swagger.model.ApiClusterTemplate)5 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)5 CustomConfigurationPropertyView (com.sequenceiq.cloudbreak.template.views.CustomConfigurationPropertyView)5 HashSet (java.util.HashSet)5 Map (java.util.Map)5 Optional (java.util.Optional)5 ApiClusterTemplateHostTemplate (com.cloudera.api.swagger.model.ApiClusterTemplateHostTemplate)4 ApiClusterTemplateInstantiator (com.cloudera.api.swagger.model.ApiClusterTemplateInstantiator)4 ApiClusterTemplateRoleConfigGroupInfo (com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroupInfo)4 JsonUtil (com.sequenceiq.cloudbreak.common.json.JsonUtil)4 ApiClusterTemplateHostInfo (com.cloudera.api.swagger.model.ApiClusterTemplateHostInfo)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3