Search in sources :

Example 1 with StartDatahubFailedEvent

use of com.sequenceiq.datalake.flow.datahub.event.StartDatahubFailedEvent in project cloudbreak by hortonworks.

the class StartDatahubActions method failedAction.

@Bean(name = "START_DATAHUB_FAILED_STATE")
public Action<?, ?> failedAction() {
    return new AbstractSdxAction<>(StartDatahubFailedEvent.class) {

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

        @Override
        protected void doExecute(SdxContext context, StartDatahubFailedEvent payload, Map<Object, Object> variables) throws Exception {
            Exception exception = payload.getException();
            DatalakeStatusEnum failedStatus = DatalakeStatusEnum.START_FAILED;
            LOGGER.info("Update SDX status to {} for resource: {}", failedStatus, payload.getResourceId(), exception);
            String statusReason = "Datahub start failed";
            if (exception.getMessage() != null) {
                statusReason = exception.getMessage();
            }
            Flow flow = getFlow(context.getFlowParameters().getFlowId());
            flow.setFlowFailed(payload.getException());
            sdxStatusService.setStatusForDatalakeAndNotify(failedStatus, statusReason, payload.getResourceId());
            sendEvent(context, START_DATAHUB_HANDLED_EVENT.event(), payload);
        }

        @Override
        protected Object getFailurePayload(StartDatahubFailedEvent payload, Optional<SdxContext> flowContext, Exception ex) {
            return null;
        }
    };
}
Also used : DatalakeStatusEnum(com.sequenceiq.datalake.entity.DatalakeStatusEnum) FlowParameters(com.sequenceiq.flow.core.FlowParameters) AbstractSdxAction(com.sequenceiq.datalake.service.AbstractSdxAction) Optional(java.util.Optional) StateContext(org.springframework.statemachine.StateContext) StartDatahubFailedEvent(com.sequenceiq.datalake.flow.datahub.event.StartDatahubFailedEvent) Map(java.util.Map) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Flow(com.sequenceiq.flow.core.Flow) Bean(org.springframework.context.annotation.Bean)

Aggregations

DatalakeStatusEnum (com.sequenceiq.datalake.entity.DatalakeStatusEnum)1 SdxContext (com.sequenceiq.datalake.flow.SdxContext)1 StartDatahubFailedEvent (com.sequenceiq.datalake.flow.datahub.event.StartDatahubFailedEvent)1 AbstractSdxAction (com.sequenceiq.datalake.service.AbstractSdxAction)1 Flow (com.sequenceiq.flow.core.Flow)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