Search in sources :

Example 1 with ClouderaManagerProduct

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.

the class ClouderaManagerClusterCreationSetupService method filterParcelsIfNecessary.

private Set<ClouderaManagerProduct> filterParcelsIfNecessary(Cluster cluster, Set<ClouderaManagerProduct> products) {
    Stack stack = cluster.getStack();
    if (stack.isDatalake()) {
        return Set.of(clouderaManagerProductsProvider.getCdhProducts(products));
    } else {
        LOGGER.info("Product list before filter out products by blueprint: {}", products);
        Set<ClouderaManagerProduct> filteredProducts = parcelFilterService.filterParcelsByBlueprint(stack.getId(), products, cluster.getBlueprint());
        LOGGER.info("Product list after filter out products by blueprint: {}", filteredProducts);
        return filteredProducts;
    }
}
Also used : ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 2 with ClouderaManagerProduct

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.

the class ClouderaManagerClusterCreationSetupService method determineCdhRepoConfig.

private Set<ClouderaManagerProduct> determineCdhRepoConfig(Cluster cluster, List<Component> stackCdhRepoConfig, String osType, String blueprintCdhVersion, String imageCatalogName) throws CloudbreakImageCatalogException {
    if (Objects.isNull(stackCdhRepoConfig) || stackCdhRepoConfig.isEmpty()) {
        DefaultCDHInfo defaultCDHInfo = getDefaultCDHInfo(cluster, blueprintCdhVersion, osType, imageCatalogName);
        Map<String, String> stack = defaultCDHInfo.getRepo().getStack();
        Set<ClouderaManagerProduct> cdhProduct = Set.of(new ClouderaManagerProduct().withVersion(defaultCDHInfo.getVersion()).withName(stack.get("repoid").split("-")[0]).withParcel(stack.get(osType)));
        LOGGER.debug("Determined CDH product: {}", cdhProduct);
        return cdhProduct;
    } else {
        Set<ClouderaManagerProduct> products = stackCdhRepoConfig.stream().map(Component::getAttributes).map(json -> json.getSilent(ClouderaManagerProduct.class)).collect(Collectors.toSet());
        return filterParcelsIfNecessary(cluster, products);
    }
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ComponentType(com.sequenceiq.cloudbreak.common.type.ComponentType) LoggerFactory(org.slf4j.LoggerFactory) ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) JsonUtil(com.sequenceiq.cloudbreak.common.json.JsonUtil) DefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo) Image(com.sequenceiq.cloudbreak.cloud.model.Image) ClouderaManagerProductsProvider(com.sequenceiq.cloudbreak.cluster.service.ClouderaManagerProductsProvider) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) Service(org.springframework.stereotype.Service) Map(java.util.Map) ClouderaManagerProductV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.product.ClouderaManagerProductV4Request) CDH_PRODUCT_DETAILS(com.sequenceiq.cloudbreak.common.type.ComponentType.CDH_PRODUCT_DETAILS) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Component(com.sequenceiq.cloudbreak.domain.stack.Component) NotFoundException.notFound(com.sequenceiq.cloudbreak.common.exception.NotFoundException.notFound) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) PlatformStringTransformer(com.sequenceiq.cloudbreak.service.image.PlatformStringTransformer) ClouderaManagerRepositoryV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.repository.ClouderaManagerRepositoryV4Request) Logger(org.slf4j.Logger) Benchmark.measure(com.sequenceiq.cloudbreak.util.Benchmark.measure) Set(java.util.Set) StackMatrixV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.StackMatrixV4Response) ImageCatalogPlatform(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform) IOException(java.io.IOException) ClouderaManagerStackDescriptorV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerStackDescriptorV4Response) StackType(com.sequenceiq.cloudbreak.cloud.model.component.StackType) ParcelFilterService(com.sequenceiq.cloudbreak.service.parcel.ParcelFilterService) Collectors(java.util.stream.Collectors) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) Objects(java.util.Objects) Json(com.sequenceiq.cloudbreak.common.json.Json) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) List(java.util.List) BlueprintUtils(com.sequenceiq.cloudbreak.cmtemplate.utils.BlueprintUtils) Optional(java.util.Optional) ClouderaManagerV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request) ImageBasedDefaultCDHEntries(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHEntries) Collections(java.util.Collections) ImageBasedDefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.ImageBasedDefaultCDHInfo) DefaultCDHInfo(com.sequenceiq.cloudbreak.cloud.model.component.DefaultCDHInfo) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) Component(com.sequenceiq.cloudbreak.domain.stack.Component) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent)

Example 3 with ClouderaManagerProduct

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.

the class StackMatrixService method getImageBasedCMStackDescriptor.

private ClouderaManagerStackDescriptorV4Response getImageBasedCMStackDescriptor(DefaultCDHInfo stackInfo, Image image) {
    ClouderaManagerStackDescriptorV4Response stackDescriptorV4 = stackInfoToClouderaManagerStackDescriptorV4ResponseConverter.convert(stackInfo);
    RepositoryInfo cmInfo = new RepositoryInfo();
    cmInfo.setVersion(image.getPackageVersion(ImagePackageVersion.CM));
    cmInfo.setRepo(image.getRepo().entrySet().stream().collect(Collectors.toMap(Entry::getKey, e -> {
        RepositoryDetails repo = new RepositoryDetails();
        repo.setBaseurl(e.getValue());
        return repo;
    })));
    ClouderaManagerInfoV4Response cmInfoJson = repositoryInfoToClouderaManagerInfoV4ResponseConverter.convert(cmInfo);
    stackDescriptorV4.setClouderaManager(cmInfoJson);
    for (ClouderaManagerProduct parcel : stackInfo.getParcels()) {
        stackDescriptorV4.getProducts().add(ClouderaManagerProductToClouderaManagerProductV4Response.convert(parcel));
    }
    stackDescriptorV4.setProductDefinitions(stackInfo.getCsd());
    return stackDescriptorV4;
}
Also used : RepositoryDetails(com.sequenceiq.cloudbreak.cloud.model.component.RepositoryDetails) ClouderaManagerInfoV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerInfoV4Response) Entry(java.util.Map.Entry) RepositoryInfo(com.sequenceiq.cloudbreak.cloud.model.component.RepositoryInfo) ClouderaManagerStackDescriptorV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ClouderaManagerStackDescriptorV4Response) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)

Example 4 with ClouderaManagerProduct

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.

the class ParcelFilterService method filterParcels.

private Set<ClouderaManagerProduct> filterParcels(Long stackId, Set<ClouderaManagerProduct> parcels, Set<String> requiredServicesInBlueprint) {
    Set<ClouderaManagerProduct> requiredParcels = new HashSet<>();
    Set<ClouderaManagerProduct> notAccessibleParcels = new HashSet<>();
    Iterator<ClouderaManagerProduct> parcelIterator = parcels.iterator();
    while (!requiredServicesInBlueprint.isEmpty() && parcelIterator.hasNext()) {
        ClouderaManagerProduct parcel = parcelIterator.next();
        ImmutablePair<ManifestStatus, Manifest> manifest = manifestRetrieverService.readRepoManifest(parcel.getParcel());
        if (manifestAvailable(manifest)) {
            Set<String> servicesInParcel = getAllServiceNameInParcel(manifest.right);
            LOGGER.debug("The {} parcel contains the following services: {}", parcel.getName(), servicesInParcel);
            if (servicesArePresentInTheBlueprint(requiredServicesInBlueprint, servicesInParcel, parcel) || isCustomParcel(stackId, parcel)) {
                requiredParcels.add(parcel);
                LOGGER.debug("Removing {} from the remaining required services because these services are found in {} parcel.", servicesInParcel, parcel);
                requiredServicesInBlueprint.removeAll(servicesInParcel);
            } else {
                LOGGER.info("Skip parcel '{}' as there isn't any service both in the manifest and in the blueprint.", parcel);
            }
        } else {
            LOGGER.info("Add parcel '{}' as we were unable to check parcel's manifest.", parcel);
            notAccessibleParcels.add(parcel);
        }
    }
    if (!requiredServicesInBlueprint.isEmpty()) {
        LOGGER.debug("Add {} not accessible parcels to the required parcel list because the {} required services are not found in the accessible parcels.", notAccessibleParcels, requiredServicesInBlueprint);
        requiredParcels.addAll(notAccessibleParcels);
    }
    return requiredParcels;
}
Also used : ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) HashSet(java.util.HashSet)

Example 5 with ClouderaManagerProduct

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.

the class ParcelService method getParcelComponentsByBlueprint.

public Set<ClusterComponent> getParcelComponentsByBlueprint(Stack stack) {
    Set<ClusterComponent> components = getComponents(stack);
    LOGGER.debug("The following components are available in the cluster {}", components);
    if (stack.isDatalake()) {
        return getDataLakeClusterComponents(components);
    } else {
        Map<String, ClusterComponent> cmProductMap = new HashMap<>();
        Set<ClouderaManagerProduct> cmProducts = new HashSet<>();
        for (ClusterComponent clusterComponent : components) {
            ClouderaManagerProduct product = clusterComponent.getAttributes().getSilent(ClouderaManagerProduct.class);
            cmProductMap.put(product.getName(), clusterComponent);
            cmProducts.add(product);
        }
        cmProducts = filterParcelsByBlueprint(stack.getId(), cmProducts, stack.getCluster().getBlueprint());
        Set<ClusterComponent> componentsByRequiredProducts = getComponentsByRequiredProducts(cmProductMap, cmProducts);
        LOGGER.debug("The following components are required for cluster {}", componentsByRequiredProducts);
        return componentsByRequiredProducts;
    }
}
Also used : ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) HashMap(java.util.HashMap) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) HashSet(java.util.HashSet)

Aggregations

ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)91 Test (org.junit.Test)34 Test (org.junit.jupiter.api.Test)23 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)23 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)20 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)14 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)10 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)9 ClusterComponent (com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent)9 ParcelInfo (com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo)9 HashSet (java.util.HashSet)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)7 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)7 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)6 IdBroker (com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker)6 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)6 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)6 BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)6 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)5