use of com.sequenceiq.datalake.service.sdx.CDPConfigKey in project cloudbreak by hortonworks.
the class CDPConfigServiceTest method cdpStackRequests.
@Test
void cdpStackRequests() {
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
when(supportedRuntimes.isEmpty()).thenReturn(true);
cdpConfigService.initCdpStackRequests();
assertNotNull(cdpConfigService.getConfigForKey(new CDPConfigKey(CloudPlatform.AWS, SdxClusterShape.LIGHT_DUTY, RUNTIME_7212)));
assertNotNull(cdpConfigService.getConfigForKey(new CDPConfigKey(CloudPlatform.AWS, SdxClusterShape.LIGHT_DUTY, RUNTIME_710)));
assertNotNull(cdpConfigService.getConfigForKey(new CDPConfigKey(CloudPlatform.AZURE, SdxClusterShape.LIGHT_DUTY, RUNTIME_7212)));
assertNotNull(cdpConfigService.getConfigForKey(new CDPConfigKey(CloudPlatform.AZURE, SdxClusterShape.LIGHT_DUTY, RUNTIME_7212)));
assertNotNull(cdpConfigService.getConfigForKey(new CDPConfigKey(CloudPlatform.YARN, SdxClusterShape.LIGHT_DUTY, RUNTIME_7212)));
assertNotNull(cdpConfigService.getConfigForKey(new CDPConfigKey(CloudPlatform.YARN, SdxClusterShape.LIGHT_DUTY, RUNTIME_710)));
assertNotNull(cdpConfigService.getConfigForKey(new CDPConfigKey(CloudPlatform.MOCK, SdxClusterShape.LIGHT_DUTY, RUNTIME_7212)));
assertNotNull(cdpConfigService.getConfigForKey(new CDPConfigKey(CloudPlatform.MOCK, SdxClusterShape.LIGHT_DUTY, RUNTIME_710)));
assertTrue(cdpConfigService.getConfigForKey(new CDPConfigKey(CloudPlatform.AWS, SdxClusterShape.MEDIUM_DUTY_HA, RUNTIME_7214)).getCluster().getBlueprintName().contains("Profiler"));
assertFalse(cdpConfigService.getConfigForKey(new CDPConfigKey(CloudPlatform.AWS, SdxClusterShape.MEDIUM_DUTY_HA, RUNTIME_7212)).getCluster().getBlueprintName().contains("Profiler"));
assertFalse(cdpConfigService.getConfigForKey(new CDPConfigKey(CloudPlatform.AWS, SdxClusterShape.LIGHT_DUTY, RUNTIME_7214)).getCluster().getBlueprintName().contains("Profiler"));
lenient().when(entitlementService.isEntitledFor(anyString(), eq(Entitlement.CDP_DATA_LAKE_MEDIUM_DUTY_WITH_PROFILER))).thenReturn(Boolean.FALSE);
assertFalse(cdpConfigService.getConfigForKey(new CDPConfigKey(CloudPlatform.AWS, SdxClusterShape.MEDIUM_DUTY_HA, RUNTIME_7214)).getCluster().getBlueprintName().contains("Profiler"));
});
}
use of com.sequenceiq.datalake.service.sdx.CDPConfigKey in project cloudbreak by hortonworks.
the class CDPConfigService method initCdpStackRequests.
@PostConstruct
public void initCdpStackRequests() {
PathMatchingResourcePatternResolver pathMatchingResourcePatternResolver = new PathMatchingResourcePatternResolver();
try {
Resource[] resources = pathMatchingResourcePatternResolver.getResources("classpath:duties/*/**/*.json");
for (Resource resource : resources) {
Matcher matcher = RESOURCE_TEMPLATE_PATTERN.matcher(resource.getURL().getPath());
if (matcher.find()) {
String runtimeVersion = matcher.group(RUNTIME_GROUP);
if (supportedRuntimes.isEmpty() || supportedRuntimes.contains(runtimeVersion)) {
CloudPlatform cloudPlatform = CloudPlatform.valueOf(matcher.group(CLOUDPLATFORM_GROUP).toUpperCase());
SdxClusterShape sdxClusterShape = SdxClusterShape.valueOf(matcher.group(CLUSTERSHAPE_GROUP).toUpperCase());
CDPConfigKey cdpConfigKey = new CDPConfigKey(cloudPlatform, sdxClusterShape, runtimeVersion);
String entitlementString = matcher.group(ENTITLEMENT_GROUP) != null ? StringUtils.substring(matcher.group(ENTITLEMENT_GROUP), 1) : null;
Optional<Entitlement> entitlementOptional = Arrays.stream(Entitlement.values()).filter(entitlement -> StringUtils.equals(entitlement.name().toLowerCase(), entitlementString)).findFirst();
String templateString = IOUtils.toString(resource.getInputStream(), StandardCharsets.UTF_8.name());
if (!cdpStackRequests.containsKey(cdpConfigKey)) {
cdpStackRequests.put(cdpConfigKey, Maps.newHashMap());
}
cdpStackRequests.get(cdpConfigKey).putIfAbsent(entitlementOptional, templateString);
}
}
}
LOGGER.info("Cdp configs for datalakes: {}", cdpStackRequests);
} catch (IOException e) {
LOGGER.error("Can't read CDP template files", e);
throw new IllegalStateException("Can't read CDP template files", e);
}
}
Aggregations