Search in sources :

Example 6 with StackFailureEvent

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

the class CreateFullBackupHandlerTest method testDefaultFailureEvent.

@Test
public void testDefaultFailureEvent() {
    Exception e = new Exception();
    StackFailureEvent result = (StackFailureEvent) underTest.defaultFailureEvent(2L, e, new Event<>(new CreateFullBackupEvent(3L)));
    assertEquals(2L, result.getResourceId());
    assertEquals(e, result.getException());
    assertEquals(FullBackupEvent.FULL_BACKUP_FAILED_EVENT.event(), result.selector());
}
Also used : CreateFullBackupEvent(com.sequenceiq.freeipa.flow.freeipa.backup.full.event.CreateFullBackupEvent) StackFailureEvent(com.sequenceiq.freeipa.flow.stack.StackFailureEvent) Event(reactor.bus.Event) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) StackFailureEvent(com.sequenceiq.freeipa.flow.stack.StackFailureEvent) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) CreateFullBackupEvent(com.sequenceiq.freeipa.flow.freeipa.backup.full.event.CreateFullBackupEvent) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) Test(org.junit.jupiter.api.Test)

Example 7 with StackFailureEvent

use of com.sequenceiq.freeipa.flow.stack.StackFailureEvent 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)

Aggregations

StackFailureEvent (com.sequenceiq.freeipa.flow.stack.StackFailureEvent)7 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)5 Map (java.util.Map)4 Bean (org.springframework.context.annotation.Bean)4 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)3 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)3 Stack (com.sequenceiq.freeipa.entity.Stack)3 PrepareImageRequest (com.sequenceiq.cloudbreak.cloud.event.setup.PrepareImageRequest)2 Image (com.sequenceiq.cloudbreak.cloud.model.Image)2 Node (com.sequenceiq.cloudbreak.common.orchestration.Node)2 OrchestratorStateParams (com.sequenceiq.cloudbreak.orchestrator.host.OrchestratorStateParams)2 Flow (com.sequenceiq.flow.core.Flow)2 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)2 ImageConverter (com.sequenceiq.freeipa.converter.image.ImageConverter)2 CreateFullBackupEvent (com.sequenceiq.freeipa.flow.freeipa.backup.full.event.CreateFullBackupEvent)2 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)2 ImageChangeEvent (com.sequenceiq.freeipa.flow.stack.image.change.event.ImageChangeEvent)2 ImageService (com.sequenceiq.freeipa.service.image.ImageService)2 Optional (java.util.Optional)2 Test (org.junit.jupiter.api.Test)2