Search in sources :

Example 1 with DatalakeRecoverySetupNewInstancesFailedEvent

use of com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.recovery.bringup.DatalakeRecoverySetupNewInstancesFailedEvent in project cloudbreak by hortonworks.

the class DatalakeRecoveryBringupActions method datalakeRecoveryBringupFailedAction.

@Bean(name = "RECOVERY_BRINGUP_FAILED_STATE")
public Action<?, ?> datalakeRecoveryBringupFailedAction() {
    return new AbstractDatalakeRecoveryBringupAction<>(DatalakeRecoverySetupNewInstancesFailedEvent.class) {

        @Override
        protected DatalakeRecoveryBringupContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatalakeRecoverySetupNewInstancesFailedEvent payload) {
            Exception exception = payload.getException();
            Long stackId = payload.getResourceId();
            Flow flow = getFlow(flowParameters.getFlowId());
            StackView stackView = stackService.getViewByIdWithoutAuth(stackId);
            MDCBuilder.buildMdcContext(stackView);
            flow.setFlowFailed(exception);
            LOGGER.error("Datalake recovery failed for stack with id: {}", stackId, exception);
            return DatalakeRecoveryBringupContext.from(flowParameters, payload);
        }

        @Override
        protected void doExecute(DatalakeRecoveryBringupContext context, DatalakeRecoverySetupNewInstancesFailedEvent payload, Map<Object, Object> variables) {
            datalakeRecoveryBringupStatusService.handleDatalakeRecoveryBringupFailure(context.getStackId(), payload.getException().getMessage(), payload.getDetailedStatus());
            sendEvent(context, RECOVERY_BRINGUP_FAIL_HANDLED_EVENT.event(), payload);
        }
    };
}
Also used : DatalakeRecoverySetupNewInstancesFailedEvent(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.recovery.bringup.DatalakeRecoverySetupNewInstancesFailedEvent) FlowParameters(com.sequenceiq.flow.core.FlowParameters) StateContext(org.springframework.statemachine.StateContext) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) Map(java.util.Map) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Flow(com.sequenceiq.flow.core.Flow) Bean(org.springframework.context.annotation.Bean)

Example 2 with DatalakeRecoverySetupNewInstancesFailedEvent

use of com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.recovery.bringup.DatalakeRecoverySetupNewInstancesFailedEvent in project cloudbreak by hortonworks.

the class DatalakeRecoverySetupNewInstancesHandlerTest method testDoAcceptWhenExceptionThenFailure.

@Test
void testDoAcceptWhenExceptionThenFailure() {
    when(stackService.getByIdWithClusterInTransaction(STACK_ID)).thenThrow(new NotFoundException(EXCEPTION_MESSAGE));
    Selectable nextFlowStepSelector = underTest.doAccept(getHandlerEvent());
    assertEquals(EventSelectorUtil.selector(DatalakeRecoverySetupNewInstancesFailedEvent.class), nextFlowStepSelector.selector());
    DatalakeRecoverySetupNewInstancesFailedEvent failureEvent = (DatalakeRecoverySetupNewInstancesFailedEvent) nextFlowStepSelector;
    assertEquals(EXCEPTION_MESSAGE, failureEvent.getException().getMessage());
}
Also used : DatalakeRecoverySetupNewInstancesFailedEvent(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.recovery.bringup.DatalakeRecoverySetupNewInstancesFailedEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) Test(org.junit.jupiter.api.Test)

Example 3 with DatalakeRecoverySetupNewInstancesFailedEvent

use of com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.recovery.bringup.DatalakeRecoverySetupNewInstancesFailedEvent in project cloudbreak by hortonworks.

the class DatalakeRecoverySetupNewInstancesHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<DatalakeRecoverySetupNewInstancesRequest> event) {
    DatalakeRecoverySetupNewInstancesRequest request = event.getData();
    Long stackId = request.getResourceId();
    LOGGER.debug("Setting up new instances for stack {}", stackId);
    try {
        Stack stack = stackService.getByIdWithClusterInTransaction(stackId);
        setupNewInstances(stack);
        clusterService.updateClusterStatusByStackId(stackId, DetailedStackStatus.CLUSTER_RECOVERY_IN_PROGRESS);
        return new DatalakeRecoverySetupNewInstancesSuccess(stackId);
    } catch (Exception e) {
        LOGGER.error("Setting up new instances for stack failed", e);
        return new DatalakeRecoverySetupNewInstancesFailedEvent(stackId, e, DetailedStackStatus.CLUSTER_RECOVERY_FAILED);
    }
}
Also used : DatalakeRecoverySetupNewInstancesFailedEvent(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.recovery.bringup.DatalakeRecoverySetupNewInstancesFailedEvent) DatalakeRecoverySetupNewInstancesSuccess(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.recovery.bringup.DatalakeRecoverySetupNewInstancesSuccess) DatalakeRecoverySetupNewInstancesRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.recovery.bringup.DatalakeRecoverySetupNewInstancesRequest) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

DatalakeRecoverySetupNewInstancesFailedEvent (com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.recovery.bringup.DatalakeRecoverySetupNewInstancesFailedEvent)3 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)1 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)1 DatalakeRecoverySetupNewInstancesRequest (com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.recovery.bringup.DatalakeRecoverySetupNewInstancesRequest)1 DatalakeRecoverySetupNewInstancesSuccess (com.sequenceiq.cloudbreak.reactor.api.event.cluster.upgrade.recovery.bringup.DatalakeRecoverySetupNewInstancesSuccess)1 Flow (com.sequenceiq.flow.core.Flow)1 FlowParameters (com.sequenceiq.flow.core.FlowParameters)1 Map (java.util.Map)1 Test (org.junit.jupiter.api.Test)1 Bean (org.springframework.context.annotation.Bean)1 StateContext (org.springframework.statemachine.StateContext)1