Search in sources :

Example 46 with ApiClusterTemplateService

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

the class GeneratedCmTemplateService method prepareApiClusterTemplateServices.

private List<ApiClusterTemplateService> prepareApiClusterTemplateServices(Set<ServiceConfig> serviceConfigs, Map<String, Set<String>> hostServiceMap) {
    List<ApiClusterTemplateService> clusterTemplateServices = new ArrayList<>();
    for (ServiceConfig serviceConfig : serviceConfigs) {
        String serviceName = serviceConfig.getName();
        String lowerCaseServiceName = serviceName.toLowerCase();
        ApiClusterTemplateService apiClusterTemplateService = new ApiClusterTemplateService();
        apiClusterTemplateService.setRefName(lowerCaseServiceName);
        apiClusterTemplateService.setServiceType(serviceName);
        apiClusterTemplateService.setRoleConfigGroups(new ArrayList<>());
        serviceConfig.getComponents().forEach(component -> {
            Set<ApiClusterTemplateRoleConfigGroup> roleConfigGroups = new HashSet<>();
            component.getGroups().forEach(group -> {
                String componentName = component.getName();
                boolean base = component.getGroups().size() == 1 || component.isBase();
                String hostServiceNameEnd = base ? "BASE" : group.toUpperCase();
                String hostServiceName = String.format("%s-%s-%s", lowerCaseServiceName, component.getName().toUpperCase(), hostServiceNameEnd);
                ApiClusterTemplateRoleConfigGroup apiClusterTemplateRoleConfigGroup = new ApiClusterTemplateRoleConfigGroup();
                apiClusterTemplateRoleConfigGroup.setRoleType(componentName.toUpperCase());
                apiClusterTemplateRoleConfigGroup.setRefName(hostServiceName);
                apiClusterTemplateRoleConfigGroup.setBase(base);
                if (hostServiceMap.keySet().contains(group)) {
                    hostServiceMap.get(group).add(hostServiceName);
                } else {
                    hostServiceMap.put(group, Sets.newHashSet(hostServiceName));
                }
                roleConfigGroups.add(apiClusterTemplateRoleConfigGroup);
            });
            apiClusterTemplateService.getRoleConfigGroups().addAll(roleConfigGroups);
        });
        clusterTemplateServices.add(apiClusterTemplateService);
    }
    return clusterTemplateServices;
}
Also used : ServiceConfig(com.sequenceiq.cloudbreak.cmtemplate.generator.configuration.domain.dependencies.ServiceConfig) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) ArrayList(java.util.ArrayList) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) HashSet(java.util.HashSet)

Example 47 with ApiClusterTemplateService

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

the class KnoxGatewayConfigProvider method getAdditionalServices.

@Override
public Map<String, ApiClusterTemplateService> getAdditionalServices(CmTemplateProcessor cmTemplateProcessor, TemplatePreparationObject source) {
    if (source.getGatewayView() != null && cmTemplateProcessor.getServiceByType(KnoxRoles.KNOX).isEmpty()) {
        ApiClusterTemplateService knox = createBaseKnoxService();
        Set<HostgroupView> hostgroupViews = source.getHostgroupViews();
        return hostgroupViews.stream().filter(hg -> InstanceGroupType.GATEWAY.equals(hg.getInstanceGroupType())).collect(Collectors.toMap(HostgroupView::getName, v -> knox));
    }
    return Map.of();
}
Also used : EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) ConfigUtils.config(com.sequenceiq.cloudbreak.cmtemplate.configproviders.ConfigUtils.config) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) Map(java.util.Map) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) CLOUDERAMANAGER_VERSION_7_4_1(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.CLOUDERAMANAGER_VERSION_7_4_1) CLOUDERA_STACK_VERSION_7_2_9(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.CLOUDERA_STACK_VERSION_7_2_9) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) AbstractRoleConfigProvider(com.sequenceiq.cloudbreak.cmtemplate.configproviders.AbstractRoleConfigProvider) GatewayView(com.sequenceiq.cloudbreak.template.views.GatewayView) Set(java.util.Set) Collectors(java.util.stream.Collectors) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) List(java.util.List) Component(org.springframework.stereotype.Component) UmsVirtualGroupRight(com.sequenceiq.cloudbreak.auth.altus.UmsVirtualGroupRight) VirtualGroupService(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupService) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Optional(java.util.Optional) CMRepositoryVersionUtil.isKnoxDatabaseSupported(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.isKnoxDatabaseSupported) VisibleForTesting(com.google.common.annotations.VisibleForTesting) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) KerberosConfig(com.sequenceiq.cloudbreak.dto.KerberosConfig) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView)

Example 48 with ApiClusterTemplateService

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

the class CoreConfigProvider method getAdditionalServices.

@Override
public Map<String, ApiClusterTemplateService> getAdditionalServices(CmTemplateProcessor cmTemplateProcessor, TemplatePreparationObject source) {
    if (isConfigurationNeeded(cmTemplateProcessor, source) && cmTemplateProcessor.getServiceByType(CORE_SETTINGS).isEmpty()) {
        ApiClusterTemplateService coreSettings = createBaseCoreSettingsService();
        Set<HostgroupView> hostgroupViews = source.getHostgroupViews();
        return hostgroupViews.stream().filter(hg -> InstanceGroupType.GATEWAY.equals(hg.getInstanceGroupType())).collect(Collectors.toMap(HostgroupView::getName, v -> coreSettings));
    }
    return Map.of();
}
Also used : ConfigUtils.config(com.sequenceiq.cloudbreak.cmtemplate.configproviders.ConfigUtils.config) ArrayList(java.util.ArrayList) ConfigUtils(com.sequenceiq.cloudbreak.cmtemplate.configproviders.ConfigUtils) Inject(javax.inject.Inject) Lists(com.google.common.collect.Lists) CORE_SETTINGS(com.sequenceiq.cloudbreak.cmtemplate.configproviders.core.CoreRoles.CORE_SETTINGS) Map(java.util.Map) ApiClusterTemplateRoleConfigGroup(com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) HDFS(com.sequenceiq.cloudbreak.cmtemplate.configproviders.hdfs.HdfsRoles.HDFS) CORE_SETTINGS_REF_NAME(com.sequenceiq.cloudbreak.cmtemplate.configproviders.core.CoreRoles.CORE_SETTINGS_REF_NAME) NAMENODE(com.sequenceiq.cloudbreak.cmtemplate.configproviders.hdfs.HdfsRoles.NAMENODE) AbstractRoleConfigProvider(com.sequenceiq.cloudbreak.cmtemplate.configproviders.AbstractRoleConfigProvider) CORE_SETTINGS_SERVICE_REF_NAME(com.sequenceiq.cloudbreak.cmtemplate.configproviders.core.CoreRoles.CORE_SETTINGS_SERVICE_REF_NAME) Set(java.util.Set) Collectors(java.util.stream.Collectors) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) List(java.util.List) Component(org.springframework.stereotype.Component) S3ConfigProvider(com.sequenceiq.cloudbreak.cmtemplate.configproviders.s3.S3ConfigProvider) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) Optional(java.util.Optional) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) STORAGEOPERATIONS(com.sequenceiq.cloudbreak.cmtemplate.configproviders.core.CoreRoles.STORAGEOPERATIONS) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView)

Aggregations

ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)48 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)30 ApiClusterTemplateRoleConfigGroup (com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)25 HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)25 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)19 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)18 DisplayName (org.junit.jupiter.api.DisplayName)16 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)16 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)15 ArrayList (java.util.ArrayList)14 Test (org.junit.jupiter.api.Test)13 MethodSource (org.junit.jupiter.params.provider.MethodSource)13 List (java.util.List)12 Map (java.util.Map)10 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)9 HashMap (java.util.HashMap)9 HashSet (java.util.HashSet)9 Set (java.util.Set)9 Collectors (java.util.stream.Collectors)9 Optional (java.util.Optional)8