use of com.sequenceiq.cloudbreak.common.type.Versioned in project cloudbreak by hortonworks.
the class CloudResourceAdvisor method recommendAutoscale.
private AutoscaleRecommendation recommendAutoscale(BlueprintTextProcessor blueprintTextProcessor) {
String version = blueprintTextProcessor.getVersion().orElse("");
Versioned blueprintVersion = () -> blueprintTextProcessor.getVersion().get();
if (!isVersionNewerOrEqualThanLimited(version, CLOUDERAMANAGER_VERSION_7_2_1)) {
LOGGER.debug("Autoscale is not supported in this version {}.", version);
return new AutoscaleRecommendation(Set.of(), Set.of());
}
AutoscaleRecommendation autoscaleRecommendation = blueprintTextProcessor.recommendAutoscale(blueprintVersion);
if (autoscaleRecommendation.getTimeBasedHostGroups().isEmpty()) {
Set<String> autoscaleGroups = filterHostGroupByPredicate(blueprintTextProcessor, this::fallbackTimeBasedAutoscaleFilter);
if (!autoscaleGroups.isEmpty()) {
autoscaleRecommendation.setTimeBasedHostGroups(autoscaleGroups);
}
}
if (autoscaleRecommendation.getLoadBasedHostGroups().isEmpty()) {
Set<String> autoscaleGroups = filterHostGroupByPredicate(blueprintTextProcessor, this::fallbackLoadBasedAutoscaleFilter);
if (!autoscaleGroups.isEmpty()) {
autoscaleRecommendation.setLoadBasedHostGroups(autoscaleGroups);
}
}
return autoscaleRecommendation;
}
use of com.sequenceiq.cloudbreak.common.type.Versioned in project cloudbreak by hortonworks.
the class UpdateNodeCountValidator method getComputeHostGroup.
private Set<String> getComputeHostGroup(Stack stack) {
String blueprintText = stack.getCluster().getBlueprint().getBlueprintText();
CmTemplateProcessor templateProcessor = cmTemplateProcessorFactory.get(blueprintText);
Versioned version = () -> templateProcessor.getVersion().get();
return templateProcessor.getComputeHostGroups(version);
}
use of com.sequenceiq.cloudbreak.common.type.Versioned in project cloudbreak by hortonworks.
the class ClouderaManagerModificationService method callPostClouderaRuntimeUpgradeCommandIfCMIsNewerThan751.
private void callPostClouderaRuntimeUpgradeCommandIfCMIsNewerThan751(ClustersResourceApi clustersResourceApi) throws ApiException, CloudbreakException {
ClouderaManagerRepo clouderaManagerRepo = clusterComponentConfigProvider.getClouderaManagerRepoDetails(stack.getCluster().getId());
String currentCMVersion = clouderaManagerRepo.getVersion();
Versioned baseCMVersion = CLOUDERAMANAGER_VERSION_7_5_1;
if (isVersionNewerOrEqualThanLimited(currentCMVersion, baseCMVersion)) {
LOGGER.debug("Cloudera Manager version {} is newer than {} hence calling post runtime upgrade command using /v45 API", currentCMVersion, baseCMVersion.getVersion());
eventService.fireCloudbreakEvent(stack.getId(), UPDATE_IN_PROGRESS.name(), ResourceEvent.CLUSTER_UPGRADE_START_POST_UPGRADE);
waitForRestartCommandIfThereIsAny(clustersResourceApi);
Cluster cluster = stack.getCluster();
String user = cluster.getCloudbreakAmbariUser();
String password = cluster.getCloudbreakAmbariPassword();
try {
ApiClient v45Client = clouderaManagerApiClientProvider.getV45Client(stack.getGatewayPort(), user, password, clientConfig);
ClustersResourceApi clustersResourceV45Api = clouderaManagerApiFactory.getClustersResourceApi(v45Client);
clouderaManagerUpgradeService.callPostRuntimeUpgradeCommand(clustersResourceV45Api, stack, v45Client);
} catch (ClouderaManagerClientInitException e) {
LOGGER.info("Couldn't build CM v45 client", e);
throw new CloudbreakException(e);
}
} else {
LOGGER.debug("Cloudera Manager version {} is older than {} hence NOT calling post runtime upgrade command", currentCMVersion, baseCMVersion.getVersion());
}
}
use of com.sequenceiq.cloudbreak.common.type.Versioned in project cloudbreak by hortonworks.
the class CmTemplateProcessorTest method recommendAutoscale.
@Test
public void recommendAutoscale() {
Versioned blueprintVersion = () -> "7.2.11";
underTest = new CmTemplateProcessor(getBlueprintText("input/clouderamanager-multi-gateway.bp"));
assertEquals(new AutoscaleRecommendation(Set.of(), Set.of()), underTest.recommendAutoscale(blueprintVersion));
underTest = new CmTemplateProcessor(getBlueprintText("input/namenode-ha.bp"));
assertEquals(new AutoscaleRecommendation(Set.of("gateway"), Set.of("gateway")), underTest.recommendAutoscale(blueprintVersion));
underTest = new CmTemplateProcessor(getBlueprintText("input/kafka.bp"));
assertEquals(new AutoscaleRecommendation(Set.of(), Set.of()), underTest.recommendAutoscale(blueprintVersion));
underTest = new CmTemplateProcessor(getBlueprintText("input/de-ha.bp"));
assertEquals(new AutoscaleRecommendation(Set.of("compute"), Set.of("compute")), underTest.recommendAutoscale(blueprintVersion));
}
use of com.sequenceiq.cloudbreak.common.type.Versioned in project cloudbreak by hortonworks.
the class CmTemplateValidator method validateRole.
private void validateRole(String accountId, EntitledForServiceScale role, Optional<ClouderaManagerProduct> cdhProduct, CmTemplateProcessor templateProcessor) {
Versioned blueprintVersion = () -> cdhProduct.isEmpty() ? "7.0.0" : cdhProduct.get().getVersion();
boolean versionEnablesScaling = isVersionEnablesScaling(blueprintVersion, role);
boolean entitledFor = entitlementService.isEntitledFor(accountId, role.getEntitledFor());
if (role.getBlockedUntilCDPVersion().isPresent() && !versionEnablesScaling && !entitledFor) {
throw new BadRequestException(String.format("'%s' service is not enabled to scale until CDP %s", role.name(), role.getBlockedUntilCDPVersion().get()));
} else if (role.getBlockedUntilCDPVersion().isEmpty() && !entitledFor) {
throw new BadRequestException(String.format("'%s' service is not enabled to scale", role.name()));
} else if (role.getRequiredService().isPresent() && !isRequiredServicePresent(role.getRequiredService(), templateProcessor) && versionEnablesScaling) {
throw new BadRequestException(String.format("'%s' service is not presented on the cluster, and that is required", role.getRequiredService().get()));
} else {
LOGGER.info("Account is entitled for {} so scaling is enabled.", role.getEntitledFor());
}
}
Aggregations