use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class RecoverySetupHandlerTest method testDoAcceptWhenRecoveryThenSuccess.
@Test
void testDoAcceptWhenRecoveryThenSuccess() throws CloudbreakOrchestratorFailedException {
Selectable nextFlowStepSelector = underTest.doAccept(getHandlerEvent(ProvisionType.RECOVERY));
assertEquals(EventSelectorUtil.selector(SetupRecoverySuccess.class), nextFlowStepSelector.selector());
verify(rdsRecoverySetupService).addRecoverRole(STACK_ID);
}
use of com.sequenceiq.cloudbreak.common.event.Selectable 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());
}
use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class PostInstallFreeIpaHandler method accept.
@Override
public void accept(Event<PostInstallFreeIpaRequest> event) {
PostInstallFreeIpaRequest request = event.getData();
Selectable response;
try {
freeIpaPostInstallService.postInstallFreeIpa(request.getResourceId(), request.isFullPostInstall());
response = new PostInstallFreeIpaSuccess(request.getResourceId());
} catch (Exception e) {
LOGGER.error("Post install tasks have failed", e);
response = new PostInstallFreeIpaFailed(request.getResourceId(), e);
}
eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class ValidateCloudStorageHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<ValidateCloudStorageRequest> event) {
ValidateCloudStorageRequest request = event.getData();
Selectable response;
try {
Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
freeIpaCloudStorageValidationService.validate(stack);
response = new ValidateCloudStorageSuccess(request.getResourceId());
} catch (Exception e) {
LOGGER.error("FreeIPA cloud storage validation failed", e);
response = new ValidateCloudStorageFailed(request.getResourceId(), e);
}
return response;
}
use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.
the class ChangePrimaryGatewayActions method healthCheckAction.
@Bean(name = "CHANGE_PRIMARY_GATEWAY_HEALTH_CHECK_STATE")
public Action<?, ?> healthCheckAction() {
return new AbstractChangePrimaryGatewayAction<>(StackEvent.class) {
@Override
protected void doExecute(ChangePrimaryGatewayContext context, StackEvent payload, Map<Object, Object> variables) {
Stack stack = context.getStack();
Selectable request;
if (isFinalChain(variables)) {
stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.REPAIR_IN_PROGRESS, "Checking the health");
request = new HealthCheckRequest(stack.getId(), false);
} else {
LOGGER.debug("Repair in progress, skipping the health check");
request = new HealthCheckSuccess(stack.getId(), null);
}
sendEvent(context, request.selector(), request);
}
};
}
Aggregations