Search in sources :

Example 1 with AbstractExternalDatabaseStartAction

use of com.sequenceiq.cloudbreak.core.flow2.externaldatabase.start.action.AbstractExternalDatabaseStartAction in project cloudbreak by hortonworks.

the class ExternalDatabaseStartActions method externalDatabaseStartFailureAction.

@Bean(name = "EXTERNAL_DATABASE_START_FAILED_STATE")
public Action<?, ?> externalDatabaseStartFailureAction() {
    return new AbstractExternalDatabaseStartAction<>(StartExternalDatabaseFailed.class) {

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

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

        @Override
        protected void beforeReturnFlowContext(FlowParameters flowParameters, StateContext<ExternalDatabaseStartState, ExternalDatabaseStartEvent> stateContext, StartExternalDatabaseFailed payload) {
            Flow flow = getFlow(flowParameters.getFlowId());
            flow.setFlowFailed(payload.getException());
            super.beforeReturnFlowContext(flowParameters, stateContext, payload);
        }
    };
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) AbstractExternalDatabaseStartAction(com.sequenceiq.cloudbreak.core.flow2.externaldatabase.start.action.AbstractExternalDatabaseStartAction) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) StateContext(org.springframework.statemachine.StateContext) ExternalDatabaseContext(com.sequenceiq.cloudbreak.core.flow2.externaldatabase.ExternalDatabaseContext) StartExternalDatabaseFailed(com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.StartExternalDatabaseFailed) 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 AbstractExternalDatabaseStartAction (com.sequenceiq.cloudbreak.core.flow2.externaldatabase.start.action.AbstractExternalDatabaseStartAction)1 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)1 StartExternalDatabaseFailed (com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.StartExternalDatabaseFailed)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