Search in sources :

Example 1 with Versioned

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;
}
Also used : AutoscaleRecommendation(com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation) Versioned(com.sequenceiq.cloudbreak.common.type.Versioned)

Example 2 with Versioned

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);
}
Also used : Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)

Example 3 with Versioned

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());
    }
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) ApiClient(com.cloudera.api.swagger.client.ApiClient) ClustersResourceApi(com.cloudera.api.swagger.ClustersResourceApi)

Example 4 with Versioned

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));
}
Also used : AutoscaleRecommendation(com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation) Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) Test(org.junit.jupiter.api.Test)

Example 5 with Versioned

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());
    }
}
Also used : Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException)

Aggregations

Versioned (com.sequenceiq.cloudbreak.common.type.Versioned)15 Test (org.junit.jupiter.api.Test)4 VersionComparator (com.sequenceiq.cloudbreak.util.VersionComparator)3 AutoscaleRecommendation (com.sequenceiq.cloudbreak.cloud.model.AutoscaleRecommendation)2 ResizeRecommendation (com.sequenceiq.cloudbreak.cloud.model.ResizeRecommendation)2 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ClustersResourceApi (com.cloudera.api.swagger.ClustersResourceApi)1 ApiClient (com.cloudera.api.swagger.client.ApiClient)1 CloudStorageSupportedV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.CloudStorageSupportedV4Response)1 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)1 Image (com.sequenceiq.cloudbreak.cloud.model.Image)1 CloudbreakImageCatalogV3 (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3)1 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)1 ClouderaManagerClientInitException (com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 Node (com.sequenceiq.cloudbreak.common.orchestration.Node)1 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)1 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)1