Search in sources :

Example 1 with ClouderaManagerRepositoryV4RequestToClouderaManagerRepoConverter

use of com.sequenceiq.cloudbreak.converter.v4.stacks.cluster.clouderamanager.ClouderaManagerRepositoryV4RequestToClouderaManagerRepoConverter in project cloudbreak by hortonworks.

the class ClusterV4RequestToClusterConverter method extractClusterManagerAndHdpRepoConfig.

private void extractClusterManagerAndHdpRepoConfig(Cluster cluster, ClusterV4Request clusterRequest) {
    Set<ClusterComponent> components = new HashSet<>();
    ClouderaManagerV4Request clouderaManagerRequest = clusterRequest.getCm();
    if (Objects.nonNull(clouderaManagerRequest) && cluster.getBlueprint() != null && !StackType.CDH.name().equals(cluster.getBlueprint().getStackType())) {
        throw new BadRequestException("Cannot process the provided Ambari blueprint with Cloudera Manager");
    }
    Optional.ofNullable(clouderaManagerRequest).map(ClouderaManagerV4Request::getRepository).map(ClouderaManagerRepositoryV4RequestToClouderaManagerRepoConverter::convert).map(toJsonWrapException()).map(cmRepoJson -> new ClusterComponent(ComponentType.CM_REPO_DETAILS, cmRepoJson, cluster)).ifPresent(components::add);
    Optional.ofNullable(clouderaManagerRequest).map(ClouderaManagerV4Request::getProducts).orElseGet(List::of).stream().map(this::convertCMProductRequestToCMProduct).map(product -> {
        Json json = toJsonWrapException().apply(product);
        return new ClusterComponent(ComponentType.CDH_PRODUCT_DETAILS, product.getName(), json, cluster);
    }).forEach(components::add);
    cluster.setComponents(components);
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ComponentType(com.sequenceiq.cloudbreak.common.type.ComponentType) REQUESTED(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.REQUESTED) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) Function(java.util.function.Function) StringUtils(org.apache.commons.lang3.StringUtils) HashSet(java.util.HashSet) Inject(javax.inject.Inject) GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) CustomConfigurationsService(com.sequenceiq.cloudbreak.service.customconfigs.CustomConfigurationsService) RdsConfigService(com.sequenceiq.cloudbreak.service.rdsconfig.RdsConfigService) Map(java.util.Map) ClouderaManagerProductV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.product.ClouderaManagerProductV4Request) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) CloudbreakApiException(com.sequenceiq.cloudbreak.exception.CloudbreakApiException) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Logger(org.slf4j.Logger) ClouderaManagerRepositoryV4RequestToClouderaManagerRepoConverter(com.sequenceiq.cloudbreak.converter.v4.stacks.cluster.clouderamanager.ClouderaManagerRepositoryV4RequestToClouderaManagerRepoConverter) CustomContainerV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.customcontainer.CustomContainerV4Request) CustomConfigurations(com.sequenceiq.cloudbreak.domain.CustomConfigurations) Set(java.util.Set) WorkspaceService(com.sequenceiq.cloudbreak.service.workspace.WorkspaceService) StackType(com.sequenceiq.cloudbreak.cloud.model.component.StackType) GatewayV4RequestToGatewayConverter(com.sequenceiq.cloudbreak.converter.v4.stacks.cluster.gateway.GatewayV4RequestToGatewayConverter) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) Objects(java.util.Objects) Json(com.sequenceiq.cloudbreak.common.json.Json) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) List(java.util.List) Component(org.springframework.stereotype.Component) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) CollectionUtils(org.springframework.util.CollectionUtils) Optional(java.util.Optional) BlueprintService(com.sequenceiq.cloudbreak.service.blueprint.BlueprintService) CloudStorageValidationUtil(com.sequenceiq.cloudbreak.converter.util.CloudStorageValidationUtil) ClouderaManagerV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request) Collections(java.util.Collections) ClusterAttributes(com.sequenceiq.cloudbreak.domain.ClusterAttributes) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) List(java.util.List) Json(com.sequenceiq.cloudbreak.common.json.Json) HashSet(java.util.HashSet) ClouderaManagerV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request)

Aggregations

REQUESTED (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.REQUESTED)1 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)1 ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)1 ClouderaManagerV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request)1 ClouderaManagerProductV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.product.ClouderaManagerProductV4Request)1 CustomContainerV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.customcontainer.CustomContainerV4Request)1 GatewayV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)1 ThreadBasedUserCrnProvider (com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider)1 EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)1 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)1 StackType (com.sequenceiq.cloudbreak.cloud.model.component.StackType)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1 ComponentType (com.sequenceiq.cloudbreak.common.type.ComponentType)1 CloudStorageValidationUtil (com.sequenceiq.cloudbreak.converter.util.CloudStorageValidationUtil)1 ClouderaManagerRepositoryV4RequestToClouderaManagerRepoConverter (com.sequenceiq.cloudbreak.converter.v4.stacks.cluster.clouderamanager.ClouderaManagerRepositoryV4RequestToClouderaManagerRepoConverter)1 GatewayV4RequestToGatewayConverter (com.sequenceiq.cloudbreak.converter.v4.stacks.cluster.gateway.GatewayV4RequestToGatewayConverter)1 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)1 ClusterAttributes (com.sequenceiq.cloudbreak.domain.ClusterAttributes)1