Search in sources :

Example 66 with HostgroupView

use of com.sequenceiq.cloudbreak.template.views.HostgroupView in project cloudbreak by hortonworks.

the class CruiseControlRoleConfigProviderTest method testRoleConfigWithCdpVersionIsLowerThan7211.

@Test
void testRoleConfigWithCdpVersionIsLowerThan7211() {
    cdpMainVersionIs("7.2.10");
    HostgroupView hostGroup = new HostgroupView("test group");
    assertEquals(List.of(), provider.getRoleConfigs(CruiseControlRoles.CRUISE_CONTROL_SERVER, hostGroup, getTemplatePreparationObject(hostGroup)));
}
Also used : HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) Test(org.junit.jupiter.api.Test)

Example 67 with HostgroupView

use of com.sequenceiq.cloudbreak.template.views.HostgroupView in project cloudbreak by hortonworks.

the class CentralCmTemplateUpdaterTest method getKafkaPropertiesWhenNoHdfsInClusterShouldPresentCoreSettings.

@Test
public void getKafkaPropertiesWhenNoHdfsInClusterShouldPresentCoreSettings() {
    CoreConfigProvider coreConfigProvider = new CoreConfigProvider();
    ReflectionTestUtils.setField(coreConfigProvider, "s3ConfigProvider", s3ConfigProvider);
    List<CmTemplateComponentConfigProvider> cmTemplateComponentConfigProviders = List.of(coreConfigProvider);
    ReflectionTestUtils.setField(cmTemplateComponentConfigProviderProcessor, "providers", cmTemplateComponentConfigProviders);
    S3FileSystem s3FileSystem = new S3FileSystem();
    s3FileSystem.setInstanceProfile("profile");
    s3FileSystem.setS3GuardDynamoTableName("cb-table");
    s3FileSystem.setStorageContainer("cloudbreak-bucket");
    StorageLocation storageLocation = new StorageLocation();
    storageLocation.setProperty("core_defaultfs");
    storageLocation.setValue("s3a://cloudbreak-bucket/kafka");
    storageLocation.setConfigFile("core_settings");
    StorageLocationView storageLocationView = new StorageLocationView(storageLocation);
    BaseFileSystemConfigurationsView baseFileSystemConfigurationsView = new S3FileSystemConfigurationsView(s3FileSystem, Sets.newHashSet(storageLocationView), false);
    when(templatePreparationObject.getFileSystemConfigurationView()).thenReturn(Optional.of(baseFileSystemConfigurationsView));
    when(templatePreparationObject.getGatewayView()).thenReturn(new GatewayView(new Gateway(), "signkey", new HashSet<>()));
    Set<HostgroupView> hostgroupViews = new HashSet<>();
    hostgroupViews.add(new HostgroupView("master", 1, InstanceGroupType.GATEWAY, 1));
    when(templatePreparationObject.getHostgroupViews()).thenReturn(hostgroupViews);
    when(templatePreparationObject.getGatewayView()).thenReturn(new GatewayView(new Gateway(), "signkey", new HashSet<>()));
    when(blueprintView.getBlueprintText()).thenReturn(getBlueprintText("input/kafka-without-hdfs.bp"));
    String generated = generator.getBlueprintText(templatePreparationObject);
    String expected = new CmTemplateProcessor(getBlueprintText("output/kafka-without-hdfs.bp")).getTemplate().toString();
    String output = new CmTemplateProcessor(generated).getTemplate().toString();
    Assert.assertEquals(expected, output);
}
Also used : StorageLocationView(com.sequenceiq.cloudbreak.template.filesystem.StorageLocationView) CoreConfigProvider(com.sequenceiq.cloudbreak.cmtemplate.configproviders.core.CoreConfigProvider) BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) S3FileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.s3.S3FileSystemConfigurationsView) S3FileSystem(com.sequenceiq.common.api.filesystem.S3FileSystem) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) StorageLocation(com.sequenceiq.cloudbreak.domain.StorageLocation) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) GatewayView(com.sequenceiq.cloudbreak.template.views.GatewayView) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 68 with HostgroupView

use of com.sequenceiq.cloudbreak.template.views.HostgroupView in project cloudbreak by hortonworks.

the class RangerRazDatahubConfigProvider method getAdditionalServices.

@Override
public Map<String, ApiClusterTemplateService> getAdditionalServices(CmTemplateProcessor cmTemplateProcessor, TemplatePreparationObject source) {
    if (isConfigurationNeeded(cmTemplateProcessor, source)) {
        ApiClusterTemplateService coreSettings = createTemplate();
        Set<HostgroupView> hostgroupViews = source.getHostgroupViews();
        Map<String, Set<ServiceComponent>> serviceComponentsByHostGroup = cmTemplateProcessor.getServiceComponentsByHostGroup();
        Set<String> zkServerGroups = collectZKServers(serviceComponentsByHostGroup);
        boolean weHaveMoreThan2ZKServer = getZKHostNumbers(hostgroupViews, zkServerGroups);
        return hostgroupViews.stream().filter(hg -> isProperHostGroupForRaz(hg, zkServerGroups, weHaveMoreThan2ZKServer)).collect(Collectors.toMap(HostgroupView::getName, v -> coreSettings));
    }
    return Map.of();
}
Also used : CMRepositoryVersionUtil(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil) Set(java.util.Set) Collectors(java.util.stream.Collectors) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) ServiceComponent(com.sequenceiq.cloudbreak.template.model.ServiceComponent) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) Component(org.springframework.stereotype.Component) Map(java.util.Map) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) Set(java.util.Set) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView)

Example 69 with HostgroupView

use of com.sequenceiq.cloudbreak.template.views.HostgroupView in project cloudbreak by hortonworks.

the class RangerRazDatalakeConfigProvider method getAdditionalServices.

@Override
public Map<String, ApiClusterTemplateService> getAdditionalServices(CmTemplateProcessor cmTemplateProcessor, TemplatePreparationObject source) {
    if (isConfigurationNeeded(cmTemplateProcessor, source)) {
        ApiClusterTemplateService coreSettings = createTemplate();
        Set<HostgroupView> hostgroupViews = source.getHostgroupViews();
        return hostgroupViews.stream().filter(hg -> hg.getName().toLowerCase().equals("master")).collect(Collectors.toMap(HostgroupView::getName, v -> coreSettings));
    }
    return Map.of();
}
Also used : HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView) Component(org.springframework.stereotype.Component) CMRepositoryVersionUtil(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil) Map(java.util.Map) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) Set(java.util.Set) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) Collectors(java.util.stream.Collectors) ApiClusterTemplateService(com.cloudera.api.swagger.model.ApiClusterTemplateService) HostgroupView(com.sequenceiq.cloudbreak.template.views.HostgroupView)

Example 70 with HostgroupView

use of com.sequenceiq.cloudbreak.template.views.HostgroupView 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

HostgroupView (com.sequenceiq.cloudbreak.template.views.HostgroupView)122 Test (org.junit.jupiter.api.Test)63 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)39 ArrayList (java.util.ArrayList)34 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)26 ApiClusterTemplateService (com.cloudera.api.swagger.model.ApiClusterTemplateService)25 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)23 List (java.util.List)23 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)23 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)19 StorageLocationView (com.sequenceiq.cloudbreak.template.filesystem.StorageLocationView)19 S3FileSystemConfigurationsView (com.sequenceiq.cloudbreak.template.filesystem.s3.S3FileSystemConfigurationsView)18 S3FileSystem (com.sequenceiq.common.api.filesystem.S3FileSystem)18 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)16 DisplayName (org.junit.jupiter.api.DisplayName)16 MethodSource (org.junit.jupiter.params.provider.MethodSource)16 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)15 ApiClusterTemplateRoleConfigGroup (com.cloudera.api.swagger.model.ApiClusterTemplateRoleConfigGroup)8 Map (java.util.Map)8 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)7