Search in sources :

Example 1 with SetupRecoveryFailed

use of com.sequenceiq.cloudbreak.reactor.api.event.orchestration.SetupRecoveryFailed in project cloudbreak by hortonworks.

the class RecoverySetupHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<SetupRecoveryRequest> event) {
    Long stackId = event.getData().getResourceId();
    try {
        if (event.getData().getProvisionType() == ProvisionType.RECOVERY) {
            LOGGER.debug("Provision type is recovery, so running recovery setup state.");
            rdsRecoverySetupService.addRecoverRole(stackId);
        } else {
            LOGGER.debug("Provision type is not recovery, skipping recovery specific logic..");
        }
        return new SetupRecoverySuccess(stackId);
    } catch (Exception e) {
        LOGGER.error("Recovery setup failed", e);
        return new SetupRecoveryFailed(stackId, e);
    }
}
Also used : SetupRecoverySuccess(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.SetupRecoverySuccess) SetupRecoveryFailed(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.SetupRecoveryFailed)

Example 2 with SetupRecoveryFailed

use of com.sequenceiq.cloudbreak.reactor.api.event.orchestration.SetupRecoveryFailed in project cloudbreak by hortonworks.

the class RecoverySetupHandlerTest method testDoAcceptWhenExceptionThenFailure.

@Test
void testDoAcceptWhenExceptionThenFailure() throws CloudbreakOrchestratorFailedException {
    doThrow(new CloudbreakOrchestratorFailedException(EXCEPTION_MESSAGE)).when(rdsRecoverySetupService).addRecoverRole(STACK_ID);
    Selectable nextFlowStepSelector = underTest.doAccept(getHandlerEvent(ProvisionType.RECOVERY));
    assertEquals(EventSelectorUtil.selector(SetupRecoveryFailed.class), nextFlowStepSelector.selector());
    SetupRecoveryFailed failureEvent = (SetupRecoveryFailed) nextFlowStepSelector;
    assertEquals(EXCEPTION_MESSAGE, failureEvent.getException().getMessage());
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) SetupRecoveryFailed(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.SetupRecoveryFailed) Test(org.junit.jupiter.api.Test)

Aggregations

SetupRecoveryFailed (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.SetupRecoveryFailed)2 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)1 SetupRecoverySuccess (com.sequenceiq.cloudbreak.reactor.api.event.orchestration.SetupRecoverySuccess)1 Test (org.junit.jupiter.api.Test)1