Search in sources :

Example 1 with StorageValidationRequest

use of com.sequenceiq.datalake.flow.create.event.StorageValidationRequest in project cloudbreak by hortonworks.

the class StorageValidationHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<StorageValidationRequest> event) {
    StorageValidationRequest storageValidationRequest = event.getData();
    Long sdxId = storageValidationRequest.getResourceId();
    String userId = storageValidationRequest.getUserId();
    try {
        Optional<SdxCluster> sdxCluster = sdxClusterRepository.findById(sdxId);
        if (sdxCluster.isPresent()) {
            DetailedEnvironmentResponse env = environmentService.getDetailedEnvironmentResponseByName(sdxCluster.get().getEnvName());
            stackRequestManifester.configureStackForSdxCluster(sdxCluster.get(), env);
            return new StorageValidationSuccessEvent(sdxId, userId);
        } else {
            throw notFound("SDX cluster", sdxId).get();
        }
    } catch (Exception anotherException) {
        LOGGER.error("Something wrong happened in sdx storage validation phase", anotherException);
        return new SdxCreateFailedEvent(sdxId, userId, anotherException);
    }
}
Also used : SdxCreateFailedEvent(com.sequenceiq.datalake.flow.create.event.SdxCreateFailedEvent) StorageValidationSuccessEvent(com.sequenceiq.datalake.flow.create.event.StorageValidationSuccessEvent) StorageValidationRequest(com.sequenceiq.datalake.flow.create.event.StorageValidationRequest) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)

Example 2 with StorageValidationRequest

use of com.sequenceiq.datalake.flow.create.event.StorageValidationRequest in project cloudbreak by hortonworks.

the class SdxCreateActions method storageValidation.

@Bean(name = "SDX_CREATION_STORAGE_VALIDATION_STATE")
public Action<?, ?> storageValidation() {
    return new AbstractSdxAction<>(SdxEvent.class) {

        @Override
        protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxEvent payload) {
            return SdxContext.from(flowParameters, payload);
        }

        @Override
        protected void doExecute(SdxContext context, SdxEvent payload, Map<Object, Object> variables) throws Exception {
            // When SDX is created as part of re-size flow chain, SDX in payload will not have the correct ID.
            setCorrectSdxIdIfNecessary(context, payload);
            StorageValidationRequest req = new StorageValidationRequest(context);
            sendEvent(context, req.selector(), req);
        }

        @Override
        protected Object getFailurePayload(SdxEvent payload, Optional<SdxContext> flowContext, Exception ex) {
            return SdxCreateFailedEvent.from(payload, ex);
        }
    };
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) AbstractSdxAction(com.sequenceiq.datalake.service.AbstractSdxAction) Optional(java.util.Optional) StateContext(org.springframework.statemachine.StateContext) StorageValidationRequest(com.sequenceiq.datalake.flow.create.event.StorageValidationRequest) SdxEvent(com.sequenceiq.datalake.flow.SdxEvent) Map(java.util.Map) DatalakeStatusUpdateException(com.sequenceiq.datalake.service.sdx.status.DatalakeStatusUpdateException) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Bean(org.springframework.context.annotation.Bean)

Aggregations

StorageValidationRequest (com.sequenceiq.datalake.flow.create.event.StorageValidationRequest)2 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)1 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)1 SdxContext (com.sequenceiq.datalake.flow.SdxContext)1 SdxEvent (com.sequenceiq.datalake.flow.SdxEvent)1 SdxCreateFailedEvent (com.sequenceiq.datalake.flow.create.event.SdxCreateFailedEvent)1 StorageValidationSuccessEvent (com.sequenceiq.datalake.flow.create.event.StorageValidationSuccessEvent)1 AbstractSdxAction (com.sequenceiq.datalake.service.AbstractSdxAction)1 DatalakeStatusUpdateException (com.sequenceiq.datalake.service.sdx.status.DatalakeStatusUpdateException)1 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)1 FlowParameters (com.sequenceiq.flow.core.FlowParameters)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Bean (org.springframework.context.annotation.Bean)1 StateContext (org.springframework.statemachine.StateContext)1