Search in sources :

Example 11 with ClouderaManagerV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request in project cloudbreak by hortonworks.

the class ClouderaManagerClusterCreationSetupService method prepareClouderaManagerCluster.

public List<ClusterComponent> prepareClouderaManagerCluster(ClusterV4Request request, Cluster cluster, Optional<Component> stackClouderaManagerRepoConfig, List<Component> stackCdhRepoConfig, Optional<Component> stackImageComponent) throws IOException, CloudbreakImageCatalogException {
    List<ClusterComponent> components = new ArrayList<>();
    long start = System.currentTimeMillis();
    String blueprintCdhVersion = blueprintUtils.getCDHStackVersion(JsonUtil.readTree(cluster.getBlueprint().getBlueprintText()));
    LOGGER.debug("blueprintUtils.getCDHStackVersion took {} ms", System.currentTimeMillis() - start);
    Optional<ClouderaManagerRepositoryV4Request> cmRepoRequest = measure(() -> Optional.ofNullable(request.getCm()).map(ClouderaManagerV4Request::getRepository), LOGGER, "ClouderaManagerV4Request::getRepository {} ms");
    start = System.currentTimeMillis();
    String osType = getOsType(stackImageComponent);
    String imageCatalogName = getImageCatalogName(stackImageComponent);
    LOGGER.debug("getImageCatalogName took {} ms", System.currentTimeMillis() - start);
    start = System.currentTimeMillis();
    ClusterComponent cmRepoConfig = getCmRepoConfiguration(cluster, stackClouderaManagerRepoConfig, components, blueprintCdhVersion, cmRepoRequest, osType);
    LOGGER.debug("getCmRepoConfiguration took {} ms", System.currentTimeMillis() - start);
    start = System.currentTimeMillis();
    checkCmStackRepositories(cmRepoConfig, stackImageComponent.get());
    LOGGER.debug("checkCmStackRepositories took {} ms", System.currentTimeMillis() - start);
    start = System.currentTimeMillis();
    addProductComponentsToCluster(request, cluster, stackCdhRepoConfig, components, blueprintCdhVersion, osType, imageCatalogName);
    LOGGER.debug("addProductComponentsToCluster took {} ms", System.currentTimeMillis() - start);
    return components;
}
Also used : ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) ArrayList(java.util.ArrayList) ClouderaManagerRepositoryV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.repository.ClouderaManagerRepositoryV4Request)

Example 12 with ClouderaManagerV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request in project cloudbreak by hortonworks.

the class StackV4RequestToTemplatePreparationObjectConverterTest method testConvertWhenCmAndProductDetailsPresent.

@Test
public void testConvertWhenCmAndProductDetailsPresent() {
    final String cmBaseUrl = "http://cloudera-build-us-west-1.vpc.cloudera.com/s3/build/1677091/cm7/7.0.2/redhat7/yum/";
    final String cmGpgUrl = "http://cloudera-build-us-west-1.vpc.cloudera.com/s3/build/1677091/cm7/7.0.2/redhat7/yum/RPM-GPG-KEY-cloudera";
    final String cmVersion = "7.0.2";
    ClouderaManagerRepositoryV4Request cmRepo = new ClouderaManagerRepositoryV4Request().withBaseUrl(cmBaseUrl).withGpgKeyUrl(cmGpgUrl).withVersion(cmVersion);
    final String smmName = "STREAMS_MESSAGING_MANAGER";
    final String smmVersion = "2.1.0.3.0.0.0-97";
    final String smmParcel = "http://s3.amazonaws.com/dev.hortonworks.com/CSP/centos7/3.x/BUILDS/3.0.0.0-97/tars/parcel/";
    final String smmCsd = "http://s3.amazonaws.com/dev.hortonworks.com/CSP/centos7/3.x/BUILDS/3.0.0.0-97/tars/parcel/STREAMS_MESSAGING_MANAGER-2.1.0.jar";
    ClouderaManagerProductV4Request smm = new ClouderaManagerProductV4Request().withName(smmName).withVersion(smmVersion).withParcel(smmParcel).withCsd(List.of(smmCsd));
    ClouderaManagerV4Request cm = new ClouderaManagerV4Request().withEnableAutoTls(true).withRepository(cmRepo).withProducts(List.of(smm));
    when(cluster.getCm()).thenReturn(cm);
    TemplatePreparationObject result = underTest.convert(source);
    ProductDetailsView products = result.getProductDetailsView();
    assertNotNull(products);
    assertEquals(cmBaseUrl, products.getCm().getBaseUrl());
    assertEquals(cmVersion, products.getCm().getVersion());
    assertEquals(cmGpgUrl, products.getCm().getGpgKeyUrl());
    assertEquals(1, products.getProducts().size());
    ClouderaManagerProduct smmResult = products.getProducts().get(0);
    assertEquals(smmName, smmResult.getName());
    assertEquals(smmVersion, smmResult.getVersion());
    assertEquals(smmParcel, smmResult.getParcel());
    assertEquals(List.of(smmCsd), smmResult.getCsd());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ClouderaManagerProductV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.product.ClouderaManagerProductV4Request) ProductDetailsView(com.sequenceiq.cloudbreak.template.views.ProductDetailsView) ClouderaManagerRepositoryV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.repository.ClouderaManagerRepositoryV4Request) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ClouderaManagerV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request) Test(org.junit.Test)

Example 13 with ClouderaManagerV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request in project cloudbreak by hortonworks.

the class ClusterV4RequestToClusterConverterTest method testConvertClouderaManagerRequestWithNullProductList.

@Test
public void testConvertClouderaManagerRequestWithNullProductList() {
    ClusterV4Request request = new ClusterV4Request();
    request.setBlueprintName(BLUEPRINT);
    blueprint.setStackType(StackType.CDH.name());
    when(blueprintService.getByNameForWorkspaceAndLoadDefaultsIfNecessary(eq(BLUEPRINT), any())).thenReturn(blueprint);
    ClouderaManagerV4Request cm = new ClouderaManagerV4Request();
    ClouderaManagerRepositoryV4Request repository = new ClouderaManagerRepositoryV4Request();
    repository.setBaseUrl("base.url");
    repository.setVersion("1.0");
    repository.setGpgKeyUrl("gpg.key.url");
    cm.setRepository(repository);
    request.setCm(cm);
    Cluster cluster = underTest.convert(request);
    assertFalse(cluster.getComponents().isEmpty());
    assertEquals(1, cluster.getComponents().size());
    ClusterComponent component = cluster.getComponents().iterator().next();
    assertEquals(ComponentType.CM_REPO_DETAILS, component.getComponentType());
    Json expectedRepoJson = new Json(repository);
    assertEquals(expectedRepoJson.getMap().size() + 1, component.getAttributes().getMap().size());
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) ClouderaManagerRepositoryV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.repository.ClouderaManagerRepositoryV4Request) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Json(com.sequenceiq.cloudbreak.common.json.Json) ClouderaManagerV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request) Test(org.junit.jupiter.api.Test)

Example 14 with ClouderaManagerV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request in project cloudbreak by hortonworks.

the class DistroXClusterToClusterConverterTest method testConvertWithEnvCmConversionShouldHappenIfInputCmIsNotNull.

@Test
void testConvertWithEnvCmConversionShouldHappenIfInputCmIsNotNull() {
    ClouderaManagerV4Request cmConversionResult = new ClouderaManagerV4Request();
    when(cmConverter.convert(distroXV1RequestInput.getCluster().getCm())).thenReturn(cmConversionResult);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    ClusterV4Request result = testConvertDistroXV1RequestWithEnvironment();
    assertNotNull(result);
    assertEquals(cmConversionResult, result.getCm());
    verify(cmConverter, times(1)).convert(any(ClouderaManagerV1Request.class));
    verify(cmConverter, times(1)).convert(distroXV1RequestInput.getCluster().getCm());
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) ClouderaManagerV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request) ClouderaManagerV1Request(com.sequenceiq.distrox.api.v1.distrox.model.cluster.cm.ClouderaManagerV1Request) Test(org.junit.jupiter.api.Test)

Example 15 with ClouderaManagerV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request 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

ClouderaManagerV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request)20 ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)16 ClouderaManagerRepositoryV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.repository.ClouderaManagerRepositoryV4Request)10 Test (org.junit.jupiter.api.Test)10 ClouderaManagerProductV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.product.ClouderaManagerProductV4Request)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 ClusterComponent (com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent)5 ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)4 Json (com.sequenceiq.cloudbreak.common.json.Json)4 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)4 ComponentType (com.sequenceiq.cloudbreak.common.type.ComponentType)3 Set (java.util.Set)3 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)2 GatewayV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)2 ThreadBasedUserCrnProvider (com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider)2 EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)2 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)2 StackType (com.sequenceiq.cloudbreak.cloud.model.component.StackType)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)2 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)2