Search in sources :

Example 16 with ClusterV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response in project cloudbreak by hortonworks.

the class SdxUpgradeServiceTest method getStackV4Response.

private StackV4Response getStackV4Response() {
    ClouderaManagerProductV4Response cdp = new ClouderaManagerProductV4Response();
    cdp.setName("CDH");
    cdp.setVersion("7.2.1-1.cdh7.2.0.p0.3758356");
    ClouderaManagerProductV4Response cfm = new ClouderaManagerProductV4Response();
    cfm.setName("CFM");
    cfm.setVersion("2.0.0.0");
    ClouderaManagerProductV4Response spark3 = new ClouderaManagerProductV4Response();
    spark3.setName("SPARK3");
    spark3.setVersion("3.0.0.2.99.7110.0-18-1.p0.3525631");
    ClouderaManagerV4Response cm = new ClouderaManagerV4Response();
    cm.setProducts(List.of(cdp, cfm, spark3));
    ClusterV4Response clusterV4Response = new ClusterV4Response();
    clusterV4Response.setCm(cm);
    StackV4Response stackV4Response = new StackV4Response();
    stackV4Response.setName("test-sdx-cluster");
    stackV4Response.setCluster(clusterV4Response);
    return stackV4Response;
}
Also used : ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) ClouderaManagerProductV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) ClouderaManagerV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerV4Response)

Example 17 with ClusterV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response in project cloudbreak by hortonworks.

the class SdxService method getCdpVersion.

private Optional<String> getCdpVersion(StackV4Response stack) {
    String stackName = stack.getName();
    ClusterV4Response cluster = stack.getCluster();
    if (cluster != null) {
        ClouderaManagerV4Response cm = cluster.getCm();
        if (cm != null) {
            LOGGER.info("Repository details are available for cluster: {}: {}", stackName, cm);
            List<ClouderaManagerProductV4Response> products = cm.getProducts();
            if (products != null && !products.isEmpty()) {
                Optional<ClouderaManagerProductV4Response> cdpOpt = products.stream().filter(p -> "CDH".equals(p.getName())).findFirst();
                if (cdpOpt.isPresent()) {
                    return getRuntimeVersionFromCdpVersion(cdpOpt.get().getVersion());
                }
            }
        }
    }
    return Optional.empty();
}
Also used : SecurityRuleV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.util.requests.SecurityRuleV4Request) AttachRecipeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recipe.AttachRecipeV4Response) RangerRazEnabledV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.RangerRazEnabledV4Response) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException) StringUtils(org.apache.commons.lang3.StringUtils) AwsInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4Parameters) AwsInstanceTemplateV4SpotParameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4SpotParameters) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) Matcher(java.util.regex.Matcher) Pair(org.apache.commons.lang3.tuple.Pair) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) Map(java.util.Map) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) EnumSet(java.util.EnumSet) AzureStackV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters) SdxRecipe(com.sequenceiq.sdx.api.model.SdxRecipe) UpdateRecipesV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recipe.UpdateRecipesV4Response) Set(java.util.Set) Crn(com.sequenceiq.cloudbreak.auth.crn.Crn) VersionComparator(com.sequenceiq.cloudbreak.util.VersionComparator) SdxClusterRequest(com.sequenceiq.sdx.api.model.SdxClusterRequest) Stream(java.util.stream.Stream) CertExpirationState(com.sequenceiq.common.api.type.CertExpirationState) SdxAzureBase(com.sequenceiq.sdx.api.model.SdxAzureBase) SdxClusterResizeRequest(com.sequenceiq.sdx.api.model.SdxClusterResizeRequest) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) OwnerAssignmentService(com.sequenceiq.authorization.service.OwnerAssignmentService) CollectionUtils(org.apache.commons.collections4.CollectionUtils) StringUtils.isNotEmpty(org.apache.commons.lang3.StringUtils.isNotEmpty) ArrayList(java.util.ArrayList) CUSTOM(com.sequenceiq.sdx.api.model.SdxClusterShape.CUSTOM) LinkedHashMap(java.util.LinkedHashMap) Value(org.springframework.beans.factory.annotation.Value) AWS(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.AWS) CrnResourceDescriptor(com.sequenceiq.cloudbreak.auth.crn.CrnResourceDescriptor) SecurityGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.securitygroup.SecurityGroupV4Request) StackResponseEntries(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.StackResponseEntries) EnumUtils(org.apache.commons.lang3.EnumUtils) Service(org.springframework.stereotype.Service) CustomDomainSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.customdomain.CustomDomainSettingsV4Request) InstanceTemplateV4Base(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceTemplateV4Base) LinkedHashSet(java.util.LinkedHashSet) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) InstanceGroupV4Base(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceGroupV4Base) ImageSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request) SdxCustomClusterRequest(com.sequenceiq.sdx.api.model.SdxCustomClusterRequest) IOException(java.io.IOException) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) RecipeV4Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v4.recipes.RecipeV4Endpoint) DetachRecipeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.recipe.DetachRecipeV4Request) FileSystemType(com.sequenceiq.common.model.FileSystemType) ClouderaManagerProductV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) CompactViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.common.CompactViewV4Response) LoggerFactory(org.slf4j.LoggerFactory) FlowCancelService(com.sequenceiq.flow.service.FlowCancelService) JsonUtil(com.sequenceiq.cloudbreak.common.json.JsonUtil) TransactionService(com.sequenceiq.cloudbreak.common.service.TransactionService) CloudbreakInternalCrnClient(com.sequenceiq.cloudbreak.client.CloudbreakInternalCrnClient) AuthorizationResourceType(com.sequenceiq.authorization.resource.AuthorizationResourceType) SdxCloudStorageRequest(com.sequenceiq.sdx.api.model.SdxCloudStorageRequest) HierarchyAuthResourcePropertyProvider(com.sequenceiq.authorization.service.HierarchyAuthResourcePropertyProvider) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) ResourceWithId(com.sequenceiq.authorization.service.list.ResourceWithId) PayloadContext(com.sequenceiq.cloudbreak.common.event.PayloadContext) StackV4Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint) RecipeViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.recipes.responses.RecipeViewV4Responses) Versioned(com.sequenceiq.cloudbreak.common.type.Versioned) Collection(java.util.Collection) CDPConfigService(com.sequenceiq.datalake.configuration.CDPConfigService) Collectors(java.util.stream.Collectors) SdxAwsSpotParameters(com.sequenceiq.sdx.api.model.SdxAwsSpotParameters) RegionAwareInternalCrnGeneratorFactory(com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory) Json(com.sequenceiq.cloudbreak.common.json.Json) SdxStatusService(com.sequenceiq.datalake.service.sdx.status.SdxStatusService) List(java.util.List) AttachRecipeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.recipe.AttachRecipeV4Request) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) SdxInstanceGroupRequest(com.sequenceiq.sdx.api.model.SdxInstanceGroupRequest) Clock(com.sequenceiq.cloudbreak.common.service.Clock) ClouderaManagerV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerV4Response) DatalakeStatusEnum(com.sequenceiq.datalake.entity.DatalakeStatusEnum) SdxClusterShape(com.sequenceiq.sdx.api.model.SdxClusterShape) SdxReactorFlowManager(com.sequenceiq.datalake.flow.SdxReactorFlowManager) ImageCatalogService(com.sequenceiq.datalake.service.imagecatalog.ImageCatalogService) MDCBuilder(com.sequenceiq.cloudbreak.logger.MDCBuilder) HashMap(java.util.HashMap) SdxClusterRepository(com.sequenceiq.datalake.repository.SdxClusterRepository) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) HashSet(java.util.HashSet) Inject(javax.inject.Inject) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) Nonnull(javax.annotation.Nonnull) NotFoundException.notFound(com.sequenceiq.cloudbreak.common.exception.NotFoundException.notFound) SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) Logger(org.slf4j.Logger) Benchmark.measure(com.sequenceiq.cloudbreak.util.Benchmark.measure) PayloadContextProvider(com.sequenceiq.flow.core.PayloadContextProvider) RegionAwareCrnGenerator(com.sequenceiq.cloudbreak.auth.crn.RegionAwareCrnGenerator) EnvironmentClientService(com.sequenceiq.datalake.service.EnvironmentClientService) SdxAwsBase(com.sequenceiq.sdx.api.model.SdxAwsBase) ImageV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response) UpdateRecipesV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.recipe.UpdateRecipesV4Request) StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) DetachRecipeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recipe.DetachRecipeV4Response) CrnParseException(com.sequenceiq.cloudbreak.auth.crn.CrnParseException) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) ResourceIdProvider(com.sequenceiq.flow.core.ResourceIdProvider) AZURE(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.AZURE) ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) Comparator(java.util.Comparator) Collections(java.util.Collections) InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) ClouderaManagerProductV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response) ClouderaManagerV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerV4Response)

Example 18 with ClusterV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response in project cloudbreak by hortonworks.

the class ClusterToClusterV4ResponseConverterTest method testConvertWithoutMasterComponent.

@Test
public void testConvertWithoutMasterComponent() {
    // GIVEN
    given(proxyConfigDtoService.getByCrn(anyString())).willReturn(ProxyConfig.builder().withCrn("crn").withName("name").build());
    // WHEN
    ClusterV4Response result = underTest.convert(getSource());
    // THEN
    assertEquals(1L, (long) result.getId());
}
Also used : ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) AbstractEntityConverterTest(com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest) Test(org.junit.Test)

Example 19 with ClusterV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response in project cloudbreak by hortonworks.

the class ClusterToClusterV4ResponseConverter method convertContainerConfig.

private void convertContainerConfig(Cluster source, ClusterV4Response clusterResponse) {
    Json customContainerDefinition = source.getCustomContainerDefinition();
    if (customContainerDefinition != null && StringUtils.isNotEmpty(customContainerDefinition.getValue())) {
        try {
            Map<String, String> map = customContainerDefinition.get(Map.class);
            Map<String, String> result = new HashMap<>();
            for (Entry<String, String> stringStringEntry : map.entrySet()) {
                result.put(stringStringEntry.getKey(), stringStringEntry.getValue());
            }
            CustomContainerV4Response customContainers = new CustomContainerV4Response();
            customContainers.setDefinitions(result);
            clusterResponse.setCustomContainers(customContainers);
        } catch (IOException e) {
            LOGGER.info("Failed to add customContainerDefinition to response", e);
            throw new CloudbreakApiException("Failed to add customContainerDefinition to response", e);
        }
    }
}
Also used : CustomContainerV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.customcontainer.CustomContainerV4Response) HashMap(java.util.HashMap) Json(com.sequenceiq.cloudbreak.common.json.Json) IOException(java.io.IOException) CloudbreakApiException(com.sequenceiq.cloudbreak.exception.CloudbreakApiException)

Example 20 with ClusterV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response in project cloudbreak by hortonworks.

the class ProvisionerService method waitCloudbreakClusterDeletion.

public void waitCloudbreakClusterDeletion(Long id, PollingConfig pollingConfig) {
    SdxCluster sdxCluster = sdxService.getById(id);
    AtomicInteger deleteFailedCount = new AtomicInteger(1);
    Polling.waitPeriodly(pollingConfig.getSleepTime(), pollingConfig.getSleepTimeUnit()).stopIfException(pollingConfig.getStopPollingIfExceptionOccurred()).stopAfterDelay(pollingConfig.getDuration(), pollingConfig.getDurationTimeUnit()).run(() -> {
        LOGGER.info("Deletion polling cloudbreak for stack status: '{}' in '{}' env", sdxCluster.getClusterName(), sdxCluster.getEnvName());
        try {
            StackV4Response stackV4Response = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.get(0L, sdxCluster.getClusterName(), Collections.emptySet(), sdxCluster.getAccountId()));
            LOGGER.info("Stack status of SDX {} by response from cloudbreak: {}", sdxCluster.getClusterName(), stackV4Response.getStatus().name());
            LOGGER.debug("Response from cloudbreak: {}", JsonUtil.writeValueAsString(stackV4Response));
            ClusterV4Response cluster = stackV4Response.getCluster();
            if (cluster != null) {
                if (StatusKind.PROGRESS.equals(cluster.getStatus().getStatusKind())) {
                    return AttemptResults.justContinue();
                }
                if (Status.DELETE_FAILED.equals(cluster.getStatus())) {
                    // if it is implemented, please remove this
                    if (deleteFailedCount.getAndIncrement() >= DELETE_FAILED_RETRY_COUNT) {
                        LOGGER.error("Cluster deletion failed '" + sdxCluster.getClusterName() + "', " + stackV4Response.getCluster().getStatusReason());
                        return AttemptResults.breakFor("Data Lake deletion failed '" + sdxCluster.getClusterName() + "', " + stackV4Response.getCluster().getStatusReason());
                    } else {
                        return AttemptResults.justContinue();
                    }
                }
            }
            if (Status.DELETE_FAILED.equals(stackV4Response.getStatus())) {
                // if it is implemented, please remove this
                if (deleteFailedCount.getAndIncrement() >= DELETE_FAILED_RETRY_COUNT) {
                    LOGGER.error("Stack deletion failed '" + sdxCluster.getClusterName() + "', " + stackV4Response.getStatusReason());
                    return AttemptResults.breakFor("Data Lake deletion failed '" + sdxCluster.getClusterName() + "', " + stackV4Response.getStatusReason());
                } else {
                    return AttemptResults.justContinue();
                }
            } else {
                return AttemptResults.justContinue();
            }
        } catch (NotFoundException e) {
            return AttemptResults.finishWith(null);
        }
    });
    sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.STACK_DELETED, "Datalake stack deleted", sdxCluster);
}
Also used : ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) NotFoundException(javax.ws.rs.NotFoundException)

Aggregations

ClusterV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response)19 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)14 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)6 Json (com.sequenceiq.cloudbreak.common.json.Json)4 AbstractEntityConverterTest (com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest)4 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 ClouderaManagerProductV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerProductV4Response)3 ClouderaManagerV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.clouderamanager.ClouderaManagerV4Response)3 Test (org.junit.jupiter.api.Test)3 BlueprintV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4Response)2 CustomContainerV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.customcontainer.CustomContainerV4Response)2 GatewayV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.GatewayV4Response)2 ClusterExposedServiceV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.gateway.topology.ClusterExposedServiceV4Response)2 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)2 IOException (java.io.IOException)2 Collection (java.util.Collection)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 AuthorizationResourceType (com.sequenceiq.authorization.resource.AuthorizationResourceType)1