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);
}
}
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);
}
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;
}
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());
}
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);
}
Aggregations