Search in sources :

Example 1 with AbstractExternalDatabaseStopAction

use of com.sequenceiq.cloudbreak.core.flow2.externaldatabase.stop.action.AbstractExternalDatabaseStopAction in project cloudbreak by hortonworks.

the class ExternalDatabaseStopActions method externalDatabaseStopFailureAction.

@Bean(name = "EXTERNAL_DATABASE_STOP_FAILED_STATE")
public Action<?, ?> externalDatabaseStopFailureAction() {
    return new AbstractExternalDatabaseStopAction<>(StopExternalDatabaseFailed.class) {

        @Override
        protected void doExecute(ExternalDatabaseContext context, StopExternalDatabaseFailed payload, Map<Object, Object> variables) {
            stackUpdaterService.updateStatus(context.getStack().getId(), DetailedStackStatus.EXTERNAL_DATABASE_STOP_FAILED, ResourceEvent.CLUSTER_EXTERNAL_DATABASE_STOP_FAILED, payload.getException().getMessage());
            getMetricService().incrementMetricCounter(MetricType.EXTERNAL_DATABASE_STOP_FAILED, context.getStack());
            sendEvent(context);
        }

        @Override
        protected Selectable createRequest(ExternalDatabaseContext context) {
            return new StackEvent(ExternalDatabaseStopEvent.EXTERNAL_DATABASE_STOP_FAILURE_HANDLED_EVENT.event(), context.getStack().getId());
        }

        @Override
        protected void beforeReturnFlowContext(FlowParameters flowParameters, StateContext<ExternalDatabaseStopState, ExternalDatabaseStopEvent> stateContext, StopExternalDatabaseFailed payload) {
            Flow flow = getFlow(flowParameters.getFlowId());
            flow.setFlowFailed(payload.getException());
            super.beforeReturnFlowContext(flowParameters, stateContext, payload);
        }
    };
}
Also used : AbstractExternalDatabaseStopAction(com.sequenceiq.cloudbreak.core.flow2.externaldatabase.stop.action.AbstractExternalDatabaseStopAction) StopExternalDatabaseFailed(com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.StopExternalDatabaseFailed) FlowParameters(com.sequenceiq.flow.core.FlowParameters) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) StateContext(org.springframework.statemachine.StateContext) ExternalDatabaseContext(com.sequenceiq.cloudbreak.core.flow2.externaldatabase.ExternalDatabaseContext) Map(java.util.Map) Flow(com.sequenceiq.flow.core.Flow) Bean(org.springframework.context.annotation.Bean)

Aggregations

ExternalDatabaseContext (com.sequenceiq.cloudbreak.core.flow2.externaldatabase.ExternalDatabaseContext)1 AbstractExternalDatabaseStopAction (com.sequenceiq.cloudbreak.core.flow2.externaldatabase.stop.action.AbstractExternalDatabaseStopAction)1 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)1 StopExternalDatabaseFailed (com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.StopExternalDatabaseFailed)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