use of com.sequenceiq.cloudbreak.core.flow2.externaldatabase.ExternalDatabaseContext 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);
}
};
}
use of com.sequenceiq.cloudbreak.core.flow2.externaldatabase.ExternalDatabaseContext in project cloudbreak by hortonworks.
the class AbstractExternalDatabaseStopAction method createFlowContext.
@Override
protected ExternalDatabaseContext createFlowContext(FlowParameters flowParameters, StateContext<ExternalDatabaseStopState, ExternalDatabaseStopEvent> stateContext, P payload) {
Stack stack = stackService.getByIdWithClusterInTransaction(payload.getResourceId());
MDCBuilder.buildMdcContext(stack);
beforeReturnFlowContext(flowParameters, stateContext, payload);
return new ExternalDatabaseContext(flowParameters, stack);
}
use of com.sequenceiq.cloudbreak.core.flow2.externaldatabase.ExternalDatabaseContext in project cloudbreak by hortonworks.
the class ExternalDatabaseTerminationActions method externalDatabaseTerminationFailureAction.
@Bean(name = "EXTERNAL_DATABASE_TERMINATION_FAILED_STATE")
public Action<?, ?> externalDatabaseTerminationFailureAction() {
return new AbstractExternalDatabaseTerminationAction<>(TerminateExternalDatabaseFailed.class) {
@Override
protected void doExecute(ExternalDatabaseContext context, TerminateExternalDatabaseFailed payload, Map<Object, Object> variables) {
stackUpdaterService.updateStatus(context.getStack().getId(), DetailedStackStatus.DELETE_FAILED, ResourceEvent.CLUSTER_EXTERNAL_DATABASE_DELETION_FAILED, payload.getException().getMessage());
getMetricService().incrementMetricCounter(MetricType.EXTERNAL_DATABASE_TERMINATION_FAILED, context.getStack());
sendEvent(context);
}
@Override
protected Selectable createRequest(ExternalDatabaseContext context) {
return new StackEvent(ExternalDatabaseTerminationEvent.EXTERNAL_DATABASE_TERMINATION_FAILURE_HANDLED_EVENT.event(), context.getStack().getId());
}
@Override
protected void beforeReturnFlowContext(FlowParameters flowParameters, StateContext<ExternalDatabaseTerminationState, ExternalDatabaseTerminationEvent> stateContext, TerminateExternalDatabaseFailed payload) {
Flow flow = getFlow(flowParameters.getFlowId());
flow.setFlowFailed(payload.getException());
super.beforeReturnFlowContext(flowParameters, stateContext, payload);
}
};
}
use of com.sequenceiq.cloudbreak.core.flow2.externaldatabase.ExternalDatabaseContext in project cloudbreak by hortonworks.
the class ExternalDatabaseTerminationActions method externalDatabaseTermination.
@Bean(name = "WAIT_FOR_EXTERNAL_DATABASE_TERMINATION_STATE")
public Action<?, ?> externalDatabaseTermination() {
return new AbstractExternalDatabaseTerminationAction<>(TerminationEvent.class) {
@Override
protected void doExecute(ExternalDatabaseContext context, TerminationEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
TerminateExternalDatabaseRequest request = new TerminateExternalDatabaseRequest(stack.getId(), "TerminateExternalDatabaseRequest", stack.getName(), stack.getResourceCrn(), payload.getTerminationType().isForced());
sendEvent(context, request);
}
};
}
use of com.sequenceiq.cloudbreak.core.flow2.externaldatabase.ExternalDatabaseContext in project cloudbreak by hortonworks.
the class AbstractExternalDatabaseStartAction method createFlowContext.
@Override
protected ExternalDatabaseContext createFlowContext(FlowParameters flowParameters, StateContext<ExternalDatabaseStartState, ExternalDatabaseStartEvent> stateContext, P payload) {
Stack stack = stackService.getByIdWithClusterInTransaction(payload.getResourceId());
MDCBuilder.buildMdcContext(stack);
beforeReturnFlowContext(flowParameters, stateContext, payload);
return new ExternalDatabaseContext(flowParameters, stack);
}
Aggregations