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);
}
};
}
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());
}
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);
}
}
Aggregations