Search in sources :

Example 11 with StackViewV4Response

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

the class DatahubDeletionService method waitDatahubClustersDeletion.

private void waitDatahubClustersDeletion(PollingConfig pollingConfig, Environment environment, Collection<StackViewV4Response> list, boolean force) {
    DistroXMultiDeleteV1Request multiDeleteRequest = new DistroXMultiDeleteV1Request();
    multiDeleteRequest.setCrns(list.stream().map(StackViewV4Response::getCrn).collect(Collectors.toSet()));
    LOGGER.debug("Calling distroXV1Endpoint.deleteMultiple with crn [{}]", multiDeleteRequest.getCrns());
    datahubService.deleteMultiple(environment.getResourceCrn(), multiDeleteRequest, force);
    LOGGER.debug("Starting poller to check all Datahub stacks for environment {} are deleted", environment.getName());
    try {
        Polling.stopAfterDelay(pollingConfig.getTimeout(), pollingConfig.getTimeoutTimeUnit()).stopIfException(pollingConfig.getStopPollingIfExceptionOccured()).waitPeriodly(pollingConfig.getSleepTime(), pollingConfig.getSleepTimeUnit()).run(() -> periodicCheckForDeletion(environment));
    } catch (PollerStoppedException e) {
        LOGGER.info("Datahub cluster deletion timed out");
        throw new DatahubOperationFailedException("Datahub cluster deletion timed out", e);
    }
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) DistroXMultiDeleteV1Request(com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXMultiDeleteV1Request) DatahubOperationFailedException(com.sequenceiq.environment.exception.DatahubOperationFailedException) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 12 with StackViewV4Response

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

the class StackOperations method listByEnvironmentCrn.

public StackViewV4Responses listByEnvironmentCrn(Long workspaceId, String environmentCrn, List<StackType> stackTypes) {
    Set<StackViewV4Response> stackViewResponses;
    LOGGER.info("List for Stack in workspace {} and environmentCrn {}.", workspaceId, environmentCrn);
    stackViewResponses = stackApiViewService.retrieveStackViewsByWorkspaceIdAndEnvironmentCrn(workspaceId, environmentCrn, stackTypes).stream().map(s -> stackApiViewToStackViewV4ResponseConverter.convert(s)).collect(Collectors.toSet());
    LOGGER.info("Adding environment name and credential to the responses.");
    NameOrCrn nameOrCrn = StringUtils.isEmpty(environmentCrn) ? NameOrCrn.empty() : NameOrCrn.ofCrn(environmentCrn);
    environmentServiceDecorator.prepareEnvironmentsAndCredentialName(stackViewResponses, nameOrCrn);
    LOGGER.info("Adding SDX CRN and name to the responses.");
    sdxServiceDecorator.prepareMultipleSdxAttributes(stackViewResponses);
    return new StackViewV4Responses(stackViewResponses);
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)

Example 13 with StackViewV4Response

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

the class StackOperations method getForInternalCrn.

public StackViewV4Response getForInternalCrn(NameOrCrn nameOrCrn, StackType stackType) {
    LOGGER.info("Validate stack against internal user.");
    StackApiView stackApiView = stackApiViewService.retrieveStackByCrnAndType(nameOrCrn.getCrn(), stackType);
    LOGGER.info("Query Stack (view) successfully finished with crn {}", nameOrCrn.getCrn());
    StackViewV4Response stackViewV4Response = stackApiViewToStackViewV4ResponseConverter.convert(stackApiView);
    LOGGER.info("Adding environment name to the response.");
    environmentServiceDecorator.prepareEnvironment(stackViewV4Response);
    return stackViewV4Response;
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) StackApiView(com.sequenceiq.cloudbreak.domain.view.StackApiView)

Example 14 with StackViewV4Response

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

the class SdxServiceTest method testDeleteSdxWhenSdxHasStoppedDataHubsShouldThrowBadRequest.

@Test
void testDeleteSdxWhenSdxHasStoppedDataHubsShouldThrowBadRequest() {
    SdxCluster sdxCluster = getSdxCluster();
    when(sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNull(anyString(), anyString())).thenReturn(Optional.of(sdxCluster));
    StackViewV4Response stackViewV4Response = new StackViewV4Response();
    stackViewV4Response.setName("existingDistroXCluster");
    stackViewV4Response.setStatus(Status.STOPPED);
    mockCBCallForDistroXClusters(Sets.newHashSet(stackViewV4Response));
    BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.deleteSdx(USER_CRN, "sdx-cluster-name", false));
    assertEquals("The following stopped Data Hubs clusters(s) must be terminated before SDX deleting [existingDistroXCluster]." + " Use --force to skip this check.", badRequestException.getMessage());
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 15 with StackViewV4Response

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

the class SdxServiceTest method testDeleteSdxWhenSdxHasStoppedDataHubsShouldSucceedWhenForced.

@Test
void testDeleteSdxWhenSdxHasStoppedDataHubsShouldSucceedWhenForced() {
    SdxCluster sdxCluster = getSdxCluster();
    when(sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNull(anyString(), anyString())).thenReturn(Optional.of(sdxCluster));
    when(sdxReactorFlowManager.triggerSdxDeletion(any(SdxCluster.class), anyBoolean())).thenReturn(new FlowIdentifier(FlowType.FLOW, "FLOW_ID"));
    StackViewV4Response stackViewV4Response = new StackViewV4Response();
    stackViewV4Response.setName("existingDistroXCluster");
    stackViewV4Response.setStatus(Status.STOPPED);
    mockCBCallForDistroXClusters(Sets.newHashSet(stackViewV4Response));
    underTest.deleteSdx(USER_CRN, "sdx-cluster-name", true);
    verify(sdxReactorFlowManager, times(1)).triggerSdxDeletion(sdxCluster, true);
    ArgumentCaptor<SdxCluster> captor = ArgumentCaptor.forClass(SdxCluster.class);
    verify(sdxClusterRepository, times(1)).save(captor.capture());
    verify(sdxStatusService, times(1)).setStatusForDatalakeAndNotify(DatalakeStatusEnum.DELETE_REQUESTED, "Datalake deletion requested", sdxCluster);
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Aggregations

StackViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)32 StackViewV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)18 Test (org.junit.jupiter.api.Test)13 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)10 Test (org.junit.Test)8 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)6 UpgradeOptionV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeOptionV4Response)3 Image (com.sequenceiq.cloudbreak.cloud.model.Image)3 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)3 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)3 RepairValidation (com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation)3 StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)3 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)3 DistroXMultiDeleteV1Request (com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXMultiDeleteV1Request)3 CredentialResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 ClusterViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.views.ClusterViewV4Response)2 StackApiView (com.sequenceiq.cloudbreak.domain.view.StackApiView)2