use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxDiagnosticsActions method startDiagnosticsCollection.
@Bean(name = "DIAGNOSTICS_COLLECTION_START_STATE")
public Action<?, ?> startDiagnosticsCollection() {
return new AbstractSdxAction<>(SdxDiagnosticsCollectionEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxDiagnosticsCollectionEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxDiagnosticsCollectionEvent payload, Map<Object, Object> variables) {
LOGGER.debug("Start diagnostics collection for sdx cluster with id: {}", context.getSdxId());
payload.getProperties().put(DIAGNOSTICS_UUID_PARAM, context.getFlowId());
FlowIdentifier flowIdentifier = diagnosticsFlowService.startDiagnosticsCollection(payload.getProperties());
SdxDiagnosticsCollectionEvent event = new SdxDiagnosticsCollectionEvent(payload.getResourceId(), payload.getUserId(), payload.getProperties(), flowIdentifier);
sendEvent(context, SDX_DIAGNOSTICS_COLLECTION_IN_PROGRESS_EVENT.event(), event);
}
@Override
protected Object getFailurePayload(SdxDiagnosticsCollectionEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return SdxDiagnosticsFailedEvent.from(payload, ex);
}
};
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxServiceTest method testCreateNOTInternalSdxClusterFromLightDutyTemplateWhenLocationSpecifiedWithSlashShouldCreateAndSettedUpBaseLocationWithOUTSlash.
@Test
void testCreateNOTInternalSdxClusterFromLightDutyTemplateWhenLocationSpecifiedWithSlashShouldCreateAndSettedUpBaseLocationWithOUTSlash() throws IOException, TransactionExecutionException {
when(transactionService.required(isA(Supplier.class))).thenAnswer(invocation -> invocation.getArgument(0, Supplier.class).get());
String lightDutyJson = FileReaderUtils.readFileFromClasspath("/duties/7.1.0/aws/light_duty.json");
when(cdpConfigService.getConfigForKey(any())).thenReturn(JsonUtil.readValue(lightDutyJson, StackV4Request.class));
SdxClusterRequest sdxClusterRequest = createSdxClusterRequest(null, LIGHT_DUTY);
withCloudStorage(sdxClusterRequest);
long id = 10L;
when(sdxClusterRepository.save(any(SdxCluster.class))).thenAnswer(invocation -> {
SdxCluster sdxWithId = invocation.getArgument(0, SdxCluster.class);
sdxWithId.setId(id);
return sdxWithId;
});
mockEnvironmentCall(sdxClusterRequest, CloudPlatform.AWS, null);
Pair<SdxCluster, FlowIdentifier> result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.createSdx(USER_CRN, CLUSTER_NAME, sdxClusterRequest, null));
SdxCluster createdSdxCluster = result.getLeft();
assertEquals("s3a://some/dir", createdSdxCluster.getCloudStorageBaseLocation());
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxServiceTest method testDeleteSdxWhenSdxHasAttachedDataHubsAndExceptionHappensWhenGettingDatahubsAndForceDeleteShouldInitiateSdxDeletionFlow.
@Test
void testDeleteSdxWhenSdxHasAttachedDataHubsAndExceptionHappensWhenGettingDatahubsAndForceDeleteShouldInitiateSdxDeletionFlow() {
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"));
doThrow(new NotFoundException("nope")).when(distroxService).getAttachedDistroXClusters(anyString());
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);
}
use of com.sequenceiq.flow.api.model.FlowIdentifier 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);
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxServiceTest method testSdxCreateRazEnabled.
@ParameterizedTest(name = "{0}")
@MethodSource("razCloudPlatformAndRuntimeDataProvider")
void testSdxCreateRazEnabled(String testCaseName, CloudPlatform cloudPlatform, String runtime) throws IOException, TransactionExecutionException {
when(transactionService.required(isA(Supplier.class))).thenAnswer(invocation -> invocation.getArgument(0, Supplier.class).get());
String lightDutyJson = FileReaderUtils.readFileFromClasspath("/duties/7.1.0/aws/light_duty.json");
when(cdpConfigService.getConfigForKey(any())).thenReturn(JsonUtil.readValue(lightDutyJson, StackV4Request.class));
when(sdxReactorFlowManager.triggerSdxCreation(any())).thenReturn(new FlowIdentifier(FlowType.FLOW, "FLOW_ID"));
SdxClusterRequest sdxClusterRequest = createSdxClusterRequest(runtime, LIGHT_DUTY);
when(sdxClusterRepository.findByAccountIdAndEnvNameAndDeletedIsNullAndDetachedIsFalse(anyString(), anyString())).thenReturn(new ArrayList<>());
withCloudStorage(sdxClusterRequest);
long id = 10L;
when(sdxClusterRepository.save(any(SdxCluster.class))).thenAnswer(invocation -> {
SdxCluster sdxWithId = invocation.getArgument(0, SdxCluster.class);
sdxWithId.setId(id);
return sdxWithId;
});
when(clock.getCurrentTimeMillis()).thenReturn(1L);
mockEnvironmentCall(sdxClusterRequest, cloudPlatform, null);
sdxClusterRequest.setEnableRangerRaz(true);
Pair<SdxCluster, FlowIdentifier> result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.createSdx(USER_CRN, CLUSTER_NAME, sdxClusterRequest, null));
SdxCluster createdSdxCluster = result.getLeft();
assertEquals(id, createdSdxCluster.getId());
ArgumentCaptor<SdxCluster> captor = ArgumentCaptor.forClass(SdxCluster.class);
verify(sdxClusterRepository, times(1)).save(captor.capture());
SdxCluster capturedSdx = captor.getValue();
assertTrue(capturedSdx.isRangerRazEnabled());
}
Aggregations