Search in sources :

Example 1 with AutoscaleStackV4Response

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

the class StackService method getAllForAutoscale.

public Set<AutoscaleStackV4Response> getAllForAutoscale() {
    try {
        return transactionService.required(() -> {
            Set<AutoscaleStack> aliveOnes = stackRepository.findAliveOnesWithClusterManager();
            Set<AutoscaleStack> aliveNotUnderDeletion = Optional.ofNullable(aliveOnes).orElse(Set.of()).stream().filter(stack -> !DELETE_IN_PROGRESS.equals(stack.getStackStatus())).collect(Collectors.toSet());
            return aliveNotUnderDeletion.stream().map(a -> autoscaleStackToAutoscaleStackResponseJsonConverter.convert(a)).collect(Collectors.toSet());
        });
    } catch (TransactionExecutionException e) {
        throw new TransactionRuntimeExecutionException(e);
    }
}
Also used : CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) FluentClusterType(com.sequenceiq.cloudbreak.telemetry.fluent.FluentClusterType) StackToStackV4RequestConverter(com.sequenceiq.cloudbreak.converter.v4.stacks.cli.StackToStackV4RequestConverter) GetPlatformTemplateRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformTemplateRequest) ComponentConfigProviderService(com.sequenceiq.cloudbreak.service.ComponentConfigProviderService) Measure(com.sequenceiq.cloudbreak.aspect.Measure) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException) StringUtils(org.apache.commons.lang3.StringUtils) Orchestrator(com.sequenceiq.cloudbreak.domain.Orchestrator) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) StackClusterStatusView(com.sequenceiq.cloudbreak.domain.projection.StackClusterStatusView) Duration(java.time.Duration) Map(java.util.Map) EnumSet(java.util.EnumSet) Component(com.sequenceiq.cloudbreak.domain.stack.Component) AccountTagClientService(com.sequenceiq.cloudbreak.service.environment.tag.AccountTagClientService) StackIdViewToStackResponseConverter(com.sequenceiq.cloudbreak.converter.stack.StackIdViewToStackResponseConverter) Set(java.util.Set) JobResource(com.sequenceiq.cloudbreak.quartz.model.JobResource) Crn(com.sequenceiq.cloudbreak.auth.crn.Crn) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) StackRepository(com.sequenceiq.cloudbreak.repository.StackRepository) LocalDateTime(java.time.LocalDateTime) Supplier(java.util.function.Supplier) Value(org.springframework.beans.factory.annotation.Value) Strings(com.google.common.base.Strings) CrnResourceDescriptor(com.sequenceiq.cloudbreak.auth.crn.CrnResourceDescriptor) AccountTagValidationFailed(com.sequenceiq.cloudbreak.tag.AccountTagValidationFailed) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) Service(org.springframework.stereotype.Service) OrchestrationCredential(com.sequenceiq.cloudbreak.orchestrator.model.OrchestrationCredential) StackResponseDecorator(com.sequenceiq.cloudbreak.service.decorator.StackResponseDecorator) CDH_PRODUCT_DETAILS(com.sequenceiq.cloudbreak.common.type.ComponentType.CDH_PRODUCT_DETAILS) CloudConstants(com.sequenceiq.cloudbreak.common.type.CloudConstants) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) AutoscaleStack(com.sequenceiq.cloudbreak.domain.projection.AutoscaleStack) StackTtlView(com.sequenceiq.cloudbreak.domain.projection.StackTtlView) IOException(java.io.IOException) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) SdxClientService(com.sequenceiq.cloudbreak.service.datalake.SdxClientService) CostTagging(com.sequenceiq.cloudbreak.tag.CostTagging) NetworkConfigurationValidator(com.sequenceiq.cloudbreak.controller.validation.network.NetworkConfigurationValidator) StackToStackV4ResponseConverter(com.sequenceiq.cloudbreak.converter.v4.stacks.StackToStackV4ResponseConverter) StackIdView(com.sequenceiq.cloudbreak.domain.projection.StackIdView) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) ComponentType(com.sequenceiq.cloudbreak.common.type.ComponentType) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) CDPTagGenerationRequest(com.sequenceiq.cloudbreak.tag.request.CDPTagGenerationRequest) AutoscaleStackToAutoscaleStackResponseJsonConverter(com.sequenceiq.cloudbreak.converter.stack.AutoscaleStackToAutoscaleStackResponseJsonConverter) LoggerFactory(org.slf4j.LoggerFactory) AccountTelemetryClientService(com.sequenceiq.cloudbreak.service.environment.telemetry.AccountTelemetryClientService) ServiceProviderConnectorAdapter(com.sequenceiq.cloudbreak.service.stack.connector.adapter.ServiceProviderConnectorAdapter) PlatformParametersConsts(com.sequenceiq.cloudbreak.cloud.PlatformParametersConsts) ImageService(com.sequenceiq.cloudbreak.service.image.ImageService) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) TransactionService(com.sequenceiq.cloudbreak.common.service.TransactionService) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) OpenSshPublicKeyValidator(com.sequenceiq.cloudbreak.service.environment.credential.OpenSshPublicKeyValidator) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) Tunnel(com.sequenceiq.common.api.type.Tunnel) ResourceWithId(com.sequenceiq.authorization.service.list.ResourceWithId) PayloadContext(com.sequenceiq.cloudbreak.common.event.PayloadContext) StackStatusView(com.sequenceiq.cloudbreak.domain.projection.StackStatusView) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) StackTemplate(com.sequenceiq.cloudbreak.cloud.model.StackTemplate) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) StackTags(com.sequenceiq.cloudbreak.cloud.model.StackTags) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) WorkspaceService(com.sequenceiq.cloudbreak.service.workspace.WorkspaceService) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) StackCrnView(com.sequenceiq.cloudbreak.domain.projection.StackCrnView) Objects(java.util.Objects) Json(com.sequenceiq.cloudbreak.common.json.Json) List(java.util.List) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) Optional(java.util.Optional) OrchestratorService(com.sequenceiq.cloudbreak.service.orchestrator.OrchestratorService) Network(com.sequenceiq.cloudbreak.domain.Network) ContainerOrchestratorResolver(com.sequenceiq.cloudbreak.core.bootstrap.service.container.ContainerOrchestratorResolver) AutoscaleStackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response) MDCBuilder(com.sequenceiq.cloudbreak.logger.MDCBuilder) HashMap(java.util.HashMap) Image(com.sequenceiq.cloudbreak.cloud.model.Image) StackPlatformVariantView(com.sequenceiq.cloudbreak.domain.projection.StackPlatformVariantView) StackStatusService(com.sequenceiq.cloudbreak.service.stackstatus.StackStatusService) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ResourceService(com.sequenceiq.cloudbreak.service.resource.ResourceService) AuthorizationResourceNamesProvider(com.sequenceiq.authorization.service.AuthorizationResourceNamesProvider) CloudStorageFolderResolverService(com.sequenceiq.cloudbreak.telemetry.fluent.cloud.CloudStorageFolderResolverService) CloudbreakApiException(com.sequenceiq.cloudbreak.exception.CloudbreakApiException) NotFoundException.notFound(com.sequenceiq.cloudbreak.common.exception.NotFoundException.notFound) Logger(org.slf4j.Logger) ContainerOrchestrator(com.sequenceiq.cloudbreak.orchestrator.container.ContainerOrchestrator) CloudbreakDetails(com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails) Benchmark.measure(com.sequenceiq.cloudbreak.util.Benchmark.measure) PayloadContextProvider(com.sequenceiq.flow.core.PayloadContextProvider) RegionAwareCrnGenerator(com.sequenceiq.cloudbreak.auth.crn.RegionAwareCrnGenerator) StackValidation(com.sequenceiq.cloudbreak.domain.stack.StackValidation) ShowTerminatedClustersAfterConfig(com.sequenceiq.cloudbreak.service.stack.ShowTerminatedClusterConfigService.ShowTerminatedClustersAfterConfig) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) User(com.sequenceiq.cloudbreak.workspace.model.User) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) ResourceBasicView(com.sequenceiq.cloudbreak.common.dal.ResourceBasicView) DELETE_IN_PROGRESS(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.DELETE_IN_PROGRESS) ResourceIdProvider(com.sequenceiq.flow.core.ResourceIdProvider) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) VisibleForTesting(com.google.common.annotations.VisibleForTesting) StringUtils.substringBefore(org.apache.commons.lang3.StringUtils.substringBefore) Collections(java.util.Collections) StackListItem(com.sequenceiq.cloudbreak.domain.projection.StackListItem) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) AutoscaleStack(com.sequenceiq.cloudbreak.domain.projection.AutoscaleStack) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)

Example 2 with AutoscaleStackV4Response

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

the class RejectedThreadServiceTest method testCreateWhenAutoscaleStackResponse.

@Test
public void testCreateWhenAutoscaleStackResponse() {
    AutoscaleStackV4Response response = new AutoscaleStackV4Response();
    response.setStackId(1L);
    EvaluatorExecutor task = new TestEvaluatorExecutor(getContext(response));
    underTest.create(task);
    List<RejectedThread> allRejectedCluster = underTest.getAllRejectedCluster();
    Assert.assertFalse(allRejectedCluster.isEmpty());
    Assert.assertEquals(1L, allRejectedCluster.get(0).getId());
}
Also used : RejectedThread(com.sequenceiq.periscope.model.RejectedThread) AutoscaleStackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response) EvaluatorExecutor(com.sequenceiq.periscope.monitor.evaluator.EvaluatorExecutor) Test(org.junit.Test)

Example 3 with AutoscaleStackV4Response

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

the class RejectedThreadService method create.

public void create(EvaluatorExecutor task) {
    Object data = task.getContext().getData();
    RejectedThread rejectedThread;
    if (data instanceof AutoscaleStackV4Response) {
        Long stackId = ((AutoscaleStackV4Response) data).getStackId();
        rejectedThread = createOrUpdateRejectedThread(data, stackId);
    } else if (data instanceof Long) {
        rejectedThread = createOrUpdateRejectedThread(Collections.singletonMap("id", data), (Long) data);
    } else {
        throw new IllegalArgumentException("The given data is not match to AutoscaleStackResponse or Long, not possible to create");
    }
    LOGGER.debug("Rejected task: {}, count: {}", rejectedThread.getJson(), rejectedThread.getRejectedCount());
    rejectedThread.setType(task.getClass().getName());
    save(rejectedThread);
}
Also used : RejectedThread(com.sequenceiq.periscope.model.RejectedThread) AutoscaleStackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response)

Example 4 with AutoscaleStackV4Response

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

the class StackToAutoscaleStackV4ResponseConverter method convert.

public AutoscaleStackV4Response convert(Stack source) {
    AutoscaleStackV4Response result = new AutoscaleStackV4Response();
    result.setTenant(source.getWorkspace().getTenant().getName());
    result.setWorkspaceId(source.getWorkspace().getId());
    result.setUserId(source.getCreator().getUserId());
    result.setStackId(source.getId());
    result.setName(source.getName());
    result.setGatewayPort(source.getGatewayPort());
    result.setCreated(source.getCreated());
    result.setStatus(source.getStatus());
    result.setStackCrn(source.getResourceCrn());
    result.setTunnel(source.getTunnel());
    result.setCloudPlatform(source.getCloudPlatform());
    result.setUserCrn(source.getCreator().getUserCrn());
    result.setStackType(source.getType());
    result.setEnvironmentCrn(source.getEnvironmentCrn());
    if (source.getCluster() != null) {
        Cluster cluster = source.getCluster();
        result.setClusterManagerIp(cluster.getClusterManagerIp());
        result.setUserNamePath(cluster.getCloudbreakAmbariUserSecret());
        result.setPasswordPath(cluster.getCloudbreakAmbariPasswordSecret());
        result.setClusterStatus(source.getStatus());
    }
    return result;
}
Also used : AutoscaleStackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)

Example 5 with AutoscaleStackV4Response

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

the class AutoscaleStackToAutoscaleStackResponseJsonConverter method convert.

public AutoscaleStackV4Response convert(AutoscaleStack source) {
    AutoscaleStackV4Response result = new AutoscaleStackV4Response();
    result.setTenant(source.getTenantName());
    result.setWorkspaceId(source.getWorkspaceId());
    result.setUserId(source.getUserId());
    result.setUserCrn(source.getUserCrn());
    result.setStackId(source.getId());
    result.setName(source.getName());
    result.setGatewayPort(source.getGatewayPort());
    result.setCreated(source.getCreated());
    result.setStatus(source.getStackStatus());
    result.setStackCrn(source.getCrn());
    result.setCloudPlatform(source.getCloudPlatform());
    result.setStackType(source.getType());
    result.setTunnel(source.getTunnel());
    if (source.getClusterStatus() != null) {
        String gatewayIp = gatewayConfigService.getPrimaryGatewayIp(source);
        result.setClusterManagerIp(gatewayIp);
        result.setUserNamePath(source.getCloudbreakAmbariUser().getSecret());
        result.setPasswordPath(source.getCloudbreakAmbariPassword().getSecret());
        result.setClusterStatus(source.getClusterStatus());
        result.setClusterManagerVariant(source.getClusterManagerVariant());
    }
    return result;
}
Also used : AutoscaleStackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response)

Aggregations

AutoscaleStackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response)12 Test (org.junit.Test)7 RejectedThread (com.sequenceiq.periscope.model.RejectedThread)4 Cluster (com.sequenceiq.periscope.domain.Cluster)3 AutoscaleStack (com.sequenceiq.cloudbreak.domain.projection.AutoscaleStack)2 EvaluatorExecutor (com.sequenceiq.periscope.monitor.evaluator.EvaluatorExecutor)2 Supplier (java.util.function.Supplier)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Strings (com.google.common.base.Strings)1 AuthorizationResourceNamesProvider (com.sequenceiq.authorization.service.AuthorizationResourceNamesProvider)1 ResourceWithId (com.sequenceiq.authorization.service.list.ResourceWithId)1 StackType (com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType)1 Status (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status)1 DELETE_IN_PROGRESS (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.DELETE_IN_PROGRESS)1 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)1 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)1 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)1 StackStatusV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)1 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)1 Measure (com.sequenceiq.cloudbreak.aspect.Measure)1