Search in sources :

Example 1 with KerberosConfigValidationEvent

use of com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.config.KerberosConfigValidationEvent in project cloudbreak by hortonworks.

the class KerberosConfigValidationActions method kerberosConfigValidationFailureAction.

@Bean(name = "VALIDATE_KERBEROS_CONFIG_FAILED_STATE")
public Action<?, ?> kerberosConfigValidationFailureAction() {
    return new AbstractStackFailureAction<KerberosConfigValidationState, KerberosConfigValidationEvent>() {

        @Override
        protected StackFailureContext createFlowContext(FlowParameters flowParameters, StateContext<KerberosConfigValidationState, KerberosConfigValidationEvent> stateContext, StackFailureEvent payload) {
            Flow flow = getFlow(flowParameters.getFlowId());
            StackView stackView = stackService.getViewByIdWithoutAuth(payload.getResourceId());
            MDCBuilder.buildMdcContext(stackView);
            flow.setFlowFailed(payload.getException());
            return new StackFailureContext(flowParameters, stackView);
        }

        @Override
        protected void doExecute(StackFailureContext context, StackFailureEvent payload, Map<Object, Object> variables) {
            stackUpdaterService.updateStatusAndSendEventWithArgs(context.getStackView().getId(), DetailedStackStatus.PROVISION_FAILED, ResourceEvent.KERBEROS_CONFIG_VALIDATION_FAILED, payload.getException().getMessage(), payload.getException().getMessage());
            sendEvent(context);
        }

        @Override
        protected Selectable createRequest(StackFailureContext context) {
            return new StackEvent(KerberosConfigValidationEvent.VALIDATE_KERBEROS_CONFIG_FAILURE_HANDLED_EVENT.selector(), context.getStackView().getId());
        }
    };
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) 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.flow.core.Flow) Bean(org.springframework.context.annotation.Bean)

Aggregations

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 Flow (com.sequenceiq.flow.core.Flow)1 FlowParameters (com.sequenceiq.flow.core.FlowParameters)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1 StateContext (org.springframework.statemachine.StateContext)1