Search in sources :

Example 61 with Selectable

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);
}
Also used : SetupRecoverySuccess(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.SetupRecoverySuccess) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) Test(org.junit.jupiter.api.Test)

Example 62 with Selectable

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

Example 63 with Selectable

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));
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PostInstallFreeIpaFailed(com.sequenceiq.freeipa.flow.freeipa.provision.event.postinstall.PostInstallFreeIpaFailed) PostInstallFreeIpaSuccess(com.sequenceiq.freeipa.flow.freeipa.provision.event.postinstall.PostInstallFreeIpaSuccess) PostInstallFreeIpaRequest(com.sequenceiq.freeipa.flow.freeipa.provision.event.postinstall.PostInstallFreeIpaRequest)

Example 64 with Selectable

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;
}
Also used : ValidateCloudStorageRequest(com.sequenceiq.freeipa.flow.freeipa.provision.event.cloudstorage.ValidateCloudStorageRequest) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ValidateCloudStorageFailed(com.sequenceiq.freeipa.flow.freeipa.provision.event.cloudstorage.ValidateCloudStorageFailed) ValidateCloudStorageSuccess(com.sequenceiq.freeipa.flow.freeipa.provision.event.cloudstorage.ValidateCloudStorageSuccess) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 65 with Selectable

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);
        }
    };
}
Also used : StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) HealthCheckSuccess(com.sequenceiq.freeipa.flow.stack.HealthCheckSuccess) ChangePrimaryGatewayContext(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayContext) HealthCheckRequest(com.sequenceiq.freeipa.flow.stack.HealthCheckRequest) Map(java.util.Map) Stack(com.sequenceiq.freeipa.entity.Stack) Bean(org.springframework.context.annotation.Bean)

Aggregations

Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)283 Test (org.junit.jupiter.api.Test)93 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)48 Map (java.util.Map)47 List (java.util.List)36 FlowTriggerEventQueue (com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue)35 Collectors (java.util.stream.Collectors)35 PollerException (com.dyngr.exception.PollerException)32 PollerStoppedException (com.dyngr.exception.PollerStoppedException)32 UserBreakException (com.dyngr.exception.UserBreakException)32 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)30 Optional (java.util.Optional)30 Set (java.util.Set)30 Bean (org.springframework.context.annotation.Bean)28 Event (reactor.bus.Event)28 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)27 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)27 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)27 Inject (javax.inject.Inject)24 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)23