@Test public void defaultRangerHdfsAuditUrlWithNamenodeHA() { CmTemplateProcessor templateProcessor = mock(CmTemplateProcessor.class); BlueprintView blueprintView = mock(BlueprintView.class); when(blueprintView.getProcessor()).thenReturn(templateProcessor); when(templateProcessor.getHostGroupsWithComponent(HdfsRoles.NAMENODE)).thenReturn(Set.of("master")); when(templateProcessor.getRoleConfig(HdfsRoles.HDFS, HdfsRoles.NAMENODE, "dfs_federation_namenode_nameservice")) .thenReturn(Optional.of(config("dfs_federation_namenode_nameservice", "ns"))); TemplatePreparationObject preparationObject = getTemplatePreparationObjectForAws(false, false) .withBlueprintView(blueprintView) .withProductDetails(new ClouderaManagerRepo().withVersion("7.2.0"), List.of()) .build(); List<ApiClusterTemplateConfig> serviceConfigs = underTest.getServiceConfigs(templateProcessor, preparationObject); assertEquals(1, serviceConfigs.size()); assertEquals("ranger_plugin_hdfs_audit_url", serviceConfigs.get(0).getName()); assertEquals("hdfs: }
@Override public List<ApiClusterTemplateConfig> getServiceConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject templatePreparationObject) { String cmVersion = templatePreparationObject.getProductDetailsView().getCm().getVersion(); CloudPlatform cloudPlatform = templatePreparationObject.getCloudPlatform(); if (CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited(cmVersion, CLOUDERAMANAGER_VERSION_7_2_2) && (cloudPlatform.equals(CloudPlatform.AWS) || cloudPlatform.equals(CloudPlatform.AZURE))) { List<String> cloudPaths = new ArrayList<>(); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, HIVE_METASTORE_DIR) .ifPresent(location -> cloudPaths.add(HIVE_METASTORE_WAREHOUSE.name() + "=" + location.getValue())); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, HIVE_REPLICA_DIR) .ifPresent(location -> cloudPaths.add(HIVE_REPLICA_WAREHOUSE.name() + "=" + location.getValue())); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, HIVE_METASTORE_EXTERNAL_DIR) .ifPresent(location -> cloudPaths.add(HIVE_METASTORE_EXTERNAL_WAREHOUSE.name() + "=" + location.getValue())); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, RANGER_HDFS_AUDIT_URL) .map(location -> cloudPaths.add(RANGER_AUDIT.name() + "=" + location.getValue())) .orElseGet(() -> cloudPaths.add(RANGER_AUDIT.name() + "=" + getDefaultRangerAuditUrl(templateProcessor, templatePreparationObject))); String cloudPath = cloudPaths.stream().collect(Collectors.joining(",")); return List.of(getRangerAuditConfig(templateProcessor, templatePreparationObject), config(CLOUD_STORAGE_PATHS, cloudPath)); } else { return List.of(getRangerAuditConfig(templateProcessor, templatePreparationObject)); } }
RangerCloudStorageServiceConfigProvider implements CmTemplateComponentConfigProvider { @Override public List<ApiClusterTemplateConfig> getServiceConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject templatePreparationObject) { String cmVersion = templatePreparationObject.getProductDetailsView().getCm().getVersion(); CloudPlatform cloudPlatform = templatePreparationObject.getCloudPlatform(); if (CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited(cmVersion, CLOUDERAMANAGER_VERSION_7_2_2) && (cloudPlatform.equals(CloudPlatform.AWS) || cloudPlatform.equals(CloudPlatform.AZURE))) { List<String> cloudPaths = new ArrayList<>(); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, HIVE_METASTORE_DIR) .ifPresent(location -> cloudPaths.add(HIVE_METASTORE_WAREHOUSE.name() + "=" + location.getValue())); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, HIVE_REPLICA_DIR) .ifPresent(location -> cloudPaths.add(HIVE_REPLICA_WAREHOUSE.name() + "=" + location.getValue())); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, HIVE_METASTORE_EXTERNAL_DIR) .ifPresent(location -> cloudPaths.add(HIVE_METASTORE_EXTERNAL_WAREHOUSE.name() + "=" + location.getValue())); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, RANGER_HDFS_AUDIT_URL) .map(location -> cloudPaths.add(RANGER_AUDIT.name() + "=" + location.getValue())) .orElseGet(() -> cloudPaths.add(RANGER_AUDIT.name() + "=" + getDefaultRangerAuditUrl(templateProcessor, templatePreparationObject))); String cloudPath = cloudPaths.stream().collect(Collectors.joining(",")); return List.of(getRangerAuditConfig(templateProcessor, templatePreparationObject), config(CLOUD_STORAGE_PATHS, cloudPath)); } else { return List.of(getRangerAuditConfig(templateProcessor, templatePreparationObject)); } } }
RangerCloudStorageServiceConfigProvider implements CmTemplateComponentConfigProvider { @Override public List<ApiClusterTemplateConfig> getServiceConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject templatePreparationObject) { String cmVersion = templatePreparationObject.getProductDetailsView().getCm().getVersion(); CloudPlatform cloudPlatform = templatePreparationObject.getCloudPlatform(); if (CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited(cmVersion, CLOUDERAMANAGER_VERSION_7_2_2) && (cloudPlatform.equals(CloudPlatform.AWS) || cloudPlatform.equals(CloudPlatform.AZURE))) { List<String> cloudPaths = new ArrayList<>(); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, HIVE_METASTORE_DIR) .ifPresent(location -> cloudPaths.add(HIVE_METASTORE_WAREHOUSE.name() + "=" + location.getValue())); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, HIVE_REPLICA_DIR) .ifPresent(location -> cloudPaths.add(HIVE_REPLICA_WAREHOUSE.name() + "=" + location.getValue())); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, HIVE_METASTORE_EXTERNAL_DIR) .ifPresent(location -> cloudPaths.add(HIVE_METASTORE_EXTERNAL_WAREHOUSE.name() + "=" + location.getValue())); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, RANGER_HDFS_AUDIT_URL) .map(location -> cloudPaths.add(RANGER_AUDIT.name() + "=" + location.getValue())) .orElseGet(() -> cloudPaths.add(RANGER_AUDIT.name() + "=" + getDefaultRangerAuditUrl(templateProcessor, templatePreparationObject))); String cloudPath = cloudPaths.stream().collect(Collectors.joining(",")); return List.of(getRangerAuditConfig(templateProcessor, templatePreparationObject), config(CLOUD_STORAGE_PATHS, cloudPath)); } else { return List.of(getRangerAuditConfig(templateProcessor, templatePreparationObject)); } }  }
RangerCloudStorageServiceConfigProvider implements CmTemplateComponentConfigProvider { @Override public List<ApiClusterTemplateConfig> getServiceConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject templatePreparationObject) { String cmVersion = templatePreparationObject.getProductDetailsView().getCm().getVersion(); CloudPlatform cloudPlatform = templatePreparationObject.getCloudPlatform(); if (CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited(cmVersion, CLOUDERAMANAGER_VERSION_7_2_2) && (cloudPlatform.equals(CloudPlatform.AWS) || cloudPlatform.equals(CloudPlatform.AZURE))) { List<String> cloudPaths = new ArrayList<>(); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, HIVE_METASTORE_DIR) .ifPresent(location -> cloudPaths.add(HIVE_METASTORE_WAREHOUSE.name() + "=" + location.getValue())); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, HIVE_REPLICA_DIR) .ifPresent(location -> cloudPaths.add(HIVE_REPLICA_WAREHOUSE.name() + "=" + location.getValue())); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, HIVE_METASTORE_EXTERNAL_DIR) .ifPresent(location -> cloudPaths.add(HIVE_METASTORE_EXTERNAL_WAREHOUSE.name() + "=" + location.getValue())); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, RANGER_HDFS_AUDIT_URL) .map(location -> cloudPaths.add(RANGER_AUDIT.name() + "=" + location.getValue())) .orElseGet(() -> cloudPaths.add(RANGER_AUDIT.name() + "=" + getDefaultRangerAuditUrl(templateProcessor, templatePreparationObject))); String cloudPath = cloudPaths.stream().collect(Collectors.joining(",")); return List.of(getRangerAuditConfig(templateProcessor, templatePreparationObject), config(CLOUD_STORAGE_PATHS, cloudPath)); } else { return List.of(getRangerAuditConfig(templateProcessor, templatePreparationObject)); } }  @Override List<ApiClusterTemplateConfig> getServiceConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject templatePreparationObject); @Override String getServiceType(); @Override List<String> getRoleTypes(); @Override boolean isConfigurationNeeded(CmTemplateProcessor cmTemplateProcessor, TemplatePreparationObject source); }
RangerCloudStorageServiceConfigProvider implements CmTemplateComponentConfigProvider { @Override public List<ApiClusterTemplateConfig> getServiceConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject templatePreparationObject) { String cmVersion = templatePreparationObject.getProductDetailsView().getCm().getVersion(); CloudPlatform cloudPlatform = templatePreparationObject.getCloudPlatform(); if (CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited(cmVersion, CLOUDERAMANAGER_VERSION_7_2_2) && (cloudPlatform.equals(CloudPlatform.AWS) || cloudPlatform.equals(CloudPlatform.AZURE))) { List<String> cloudPaths = new ArrayList<>(); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, HIVE_METASTORE_DIR) .ifPresent(location -> cloudPaths.add(HIVE_METASTORE_WAREHOUSE.name() + "=" + location.getValue())); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, HIVE_REPLICA_DIR) .ifPresent(location -> cloudPaths.add(HIVE_REPLICA_WAREHOUSE.name() + "=" + location.getValue())); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, HIVE_METASTORE_EXTERNAL_DIR) .ifPresent(location -> cloudPaths.add(HIVE_METASTORE_EXTERNAL_WAREHOUSE.name() + "=" + location.getValue())); ConfigUtils.getStorageLocationForServiceProperty(templatePreparationObject, RANGER_HDFS_AUDIT_URL) .map(location -> cloudPaths.add(RANGER_AUDIT.name() + "=" + location.getValue())) .orElseGet(() -> cloudPaths.add(RANGER_AUDIT.name() + "=" + getDefaultRangerAuditUrl(templateProcessor, templatePreparationObject))); String cloudPath = cloudPaths.stream().collect(Collectors.joining(",")); return List.of(getRangerAuditConfig(templateProcessor, templatePreparationObject), config(CLOUD_STORAGE_PATHS, cloudPath)); } else { return List.of(getRangerAuditConfig(templateProcessor, templatePreparationObject)); } }  @Override List<ApiClusterTemplateConfig> getServiceConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject templatePreparationObject); @Override String getServiceType(); @Override List<String> getRoleTypes(); @Override boolean isConfigurationNeeded(CmTemplateProcessor cmTemplateProcessor, TemplatePreparationObject source);  }