Search in sources :

Example 1 with StackFailureEvent

use of com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent in project cloudbreak by hortonworks.

the class StackCreationActions method stackCreationFailureAction.

@Bean(name = "STACK_CREATION_FAILED_STATE")
public Action<?, ?> stackCreationFailureAction() {
    return new AbstractStackFailureAction<StackCreationState, StackCreationEvent>() {

        @Override
        protected StackFailureContext createFlowContext(String flowId, StateContext<StackCreationState, StackCreationEvent> stateContext, StackFailureEvent payload) {
            Flow flow = getFlow(flowId);
            StackView stackView = stackService.getByIdView(payload.getStackId());
            MDCBuilder.buildMdcContext(stackView);
            flow.setFlowFailed(payload.getException());
            return new StackFailureContext(flowId, stackView);
        }

        @Override
        protected void doExecute(StackFailureContext context, StackFailureEvent payload, Map<Object, Object> variables) {
            stackCreationService.handleStackCreationFailure(context.getStackView(), payload.getException());
            metricService.incrementMetricCounter(MetricType.STACK_CREATION_FAILED, context.getStackView());
            sendEvent(context);
        }

        @Override
        protected Selectable createRequest(StackFailureContext context) {
            return new StackEvent(StackCreationEvent.STACKCREATION_FAILURE_HANDLED_EVENT.event(), context.getStackView().getId());
        }
    };
}
Also used : AbstractStackFailureAction(com.sequenceiq.cloudbreak.core.flow2.stack.AbstractStackFailureAction) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) StateContext(org.springframework.statemachine.StateContext) StackFailureContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackFailureContext) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) Map(java.util.Map) Flow(com.sequenceiq.cloudbreak.core.flow2.Flow) Bean(org.springframework.context.annotation.Bean)

Aggregations

Flow (com.sequenceiq.cloudbreak.core.flow2.Flow)1 AbstractStackFailureAction (com.sequenceiq.cloudbreak.core.flow2.stack.AbstractStackFailureAction)1 StackFailureContext (com.sequenceiq.cloudbreak.core.flow2.stack.StackFailureContext)1 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)1 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)1 StackFailureEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1 StateContext (org.springframework.statemachine.StateContext)1