Search in sources :

Example 1 with StackFailureContext

use of com.sequenceiq.freeipa.flow.stack.StackFailureContext in project cloudbreak by hortonworks.

the class StackProvisionActions method stackCreationFailureAction.

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

        @Override
        protected StackFailureContext createFlowContext(FlowParameters flowParameters, StateContext<StackProvisionState, StackProvisionEvent> stateContext, StackFailureEvent payload) {
            Flow flow = getFlow(flowParameters.getFlowId());
            Stack stack = stackService.getStackById(payload.getResourceId());
            MDCBuilder.buildMdcContext(stack);
            flow.setFlowFailed(payload.getException());
            return new StackFailureContext(flowParameters, stack);
        }

        @Override
        protected void doExecute(StackFailureContext context, StackFailureEvent payload, Map<Object, Object> variables) {
            stackProvisionService.handleStackCreationFailure(context.getStack(), payload.getException());
            sendEvent(context);
        }

        @Override
        protected Selectable createRequest(StackFailureContext context) {
            return new StackEvent(StackProvisionEvent.STACKCREATION_FAILURE_HANDLED_EVENT.event(), context.getStack().getId());
        }
    };
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) AbstractStackFailureAction(com.sequenceiq.freeipa.flow.stack.AbstractStackFailureAction) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) StackFailureEvent(com.sequenceiq.freeipa.flow.stack.StackFailureEvent) StateContext(org.springframework.statemachine.StateContext) StackFailureContext(com.sequenceiq.freeipa.flow.stack.StackFailureContext) Map(java.util.Map) Flow(com.sequenceiq.flow.core.Flow) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Stack(com.sequenceiq.freeipa.entity.Stack) Bean(org.springframework.context.annotation.Bean)

Example 2 with StackFailureContext

use of com.sequenceiq.freeipa.flow.stack.StackFailureContext in project cloudbreak by hortonworks.

the class StackTerminationFailureAction method createFlowContext.

@Override
protected StackFailureContext createFlowContext(FlowParameters flowParameters, StateContext<StackTerminationState, StackTerminationEvent> stateContext, StackFailureEvent payload) {
    Flow flow = getFlow(flowParameters.getFlowId());
    Stack stack = stackService.getStackById(payload.getResourceId());
    MDCBuilder.buildMdcContext(stack);
    flow.setFlowFailed(payload.getException());
    return new StackFailureContext(flowParameters, stack);
}
Also used : StackFailureContext(com.sequenceiq.freeipa.flow.stack.StackFailureContext) Flow(com.sequenceiq.flow.core.Flow) Stack(com.sequenceiq.freeipa.entity.Stack)

Aggregations

Flow (com.sequenceiq.flow.core.Flow)2 Stack (com.sequenceiq.freeipa.entity.Stack)2 StackFailureContext (com.sequenceiq.freeipa.flow.stack.StackFailureContext)2 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)1 FlowParameters (com.sequenceiq.flow.core.FlowParameters)1 AbstractStackFailureAction (com.sequenceiq.freeipa.flow.stack.AbstractStackFailureAction)1 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)1 StackFailureEvent (com.sequenceiq.freeipa.flow.stack.StackFailureEvent)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1 StateContext (org.springframework.statemachine.StateContext)1