Search in sources :

Example 11 with RedbeamsEvent

use of com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsEvent in project cloudbreak by hortonworks.

the class StartDatabaseServerHandler method accept.

@Override
public void accept(Event<StartDatabaseServerRequest> event) {
    LOGGER.debug("Received event: {}", event);
    StartDatabaseServerRequest request = event.getData();
    CloudContext cloudContext = request.getCloudContext();
    try {
        CloudConnector<Object> connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
        AuthenticatedContext ac = connector.authentication().authenticate(cloudContext, request.getCloudCredential());
        ExternalDatabaseStatus status = connector.resources().getDatabaseServerStatus(ac, request.getDbStack());
        if (status != null && status.isTransient()) {
            LOGGER.debug("Database server '{}' is in '{}' status. Start waiting for a permanent status.", request.getDbStack(), status);
            PollTask<ExternalDatabaseStatus> task = statusCheckFactory.newPollPermanentExternalDatabaseStateTask(ac, request.getDbStack());
            status = externalDatabaseStatusPollingScheduler.schedule(task);
        }
        if (status != STARTED) {
            LOGGER.debug("Database server '{}' is in '{}' status. Calling for '{}' status.", request.getDbStack(), status, STARTED);
            connector.resources().startDatabaseServer(ac, request.getDbStack());
        } else {
            LOGGER.debug("Database server '{}' is already in '{}' status.", request.getDbStack(), STARTED);
        }
        RedbeamsEvent success = new StartDatabaseServerSuccess(request.getResourceId());
        eventBus.notify(success.selector(), new Event<>(event.getHeaders(), success));
        LOGGER.debug("Starting the database server successfully finished for {}", cloudContext);
    } catch (Exception e) {
        StartDatabaseServerFailed failure = new StartDatabaseServerFailed(request.getResourceId(), e);
        LOGGER.warn("Error starting the database server:", e);
        eventBus.notify(failure.selector(), new Event<>(event.getHeaders(), failure));
    }
}
Also used : StartDatabaseServerSuccess(com.sequenceiq.redbeams.flow.redbeams.start.event.StartDatabaseServerSuccess) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) StartDatabaseServerRequest(com.sequenceiq.redbeams.flow.redbeams.start.event.StartDatabaseServerRequest) Event(reactor.bus.Event) RedbeamsEvent(com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsEvent) RedbeamsEvent(com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsEvent) StartDatabaseServerFailed(com.sequenceiq.redbeams.flow.redbeams.start.event.StartDatabaseServerFailed) ExternalDatabaseStatus(com.sequenceiq.cloudbreak.cloud.model.ExternalDatabaseStatus)

Example 12 with RedbeamsEvent

use of com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsEvent in project cloudbreak by hortonworks.

the class RedbeamsProvisionActionsTest method allocateDatabaseServerTestPrepareExecution.

@Test
void allocateDatabaseServerTestPrepareExecution() {
    RedbeamsEvent payload = new RedbeamsEvent(RESOURCE_ID);
    new AbstractActionTestSupport<>(getAllocateDatabaseServerAction()).prepareExecution(payload, Map.of());
    verify(dbStackStatusUpdater).updateStatus(RESOURCE_ID, DetailedDBStackStatus.CREATING_INFRASTRUCTURE);
}
Also used : RedbeamsEvent(com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsEvent) Test(org.junit.jupiter.api.Test)

Example 13 with RedbeamsEvent

use of com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsEvent in project cloudbreak by hortonworks.

the class StartDatabaseServerActionTest method shouldUpdateStatusOnPrepare.

@Test
public void shouldUpdateStatusOnPrepare() {
    RedbeamsEvent event = new RedbeamsEvent(RESOURCE_ID);
    victim.prepareExecution(event, null);
    verify(dbStackStatusUpdater).updateStatus(RESOURCE_ID, DetailedDBStackStatus.START_IN_PROGRESS);
}
Also used : RedbeamsEvent(com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsEvent) Test(org.junit.jupiter.api.Test)

Example 14 with RedbeamsEvent

use of com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsEvent in project cloudbreak by hortonworks.

the class StartDatabaseServerFinishedActionTest method shouldIncrementMetricOnCreateRequest.

@Test
public void shouldIncrementMetricOnCreateRequest() {
    RedbeamsStartContext context = new RedbeamsStartContext(flowParameters, cloudContext, cloudCredential, databaseStack);
    RedbeamsEvent redbeamsEvent = (RedbeamsEvent) victim.createRequest(context);
    assertEquals(RedbeamsStartEvent.REDBEAMS_START_FINISHED_EVENT.name(), redbeamsEvent.selector());
}
Also used : RedbeamsStartContext(com.sequenceiq.redbeams.flow.redbeams.start.RedbeamsStartContext) RedbeamsEvent(com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsEvent) Test(org.junit.jupiter.api.Test)

Example 15 with RedbeamsEvent

use of com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsEvent in project cloudbreak by hortonworks.

the class StopDatabaseServerFailedActionTest method shouldCreateRequest.

@Test
public void shouldCreateRequest() {
    RedbeamsEvent request = (RedbeamsEvent) victim.createRequest(null);
    assertEquals(RedbeamsStopEvent.REDBEAMS_STOP_FAILURE_HANDLED_EVENT.event(), request.selector());
}
Also used : RedbeamsEvent(com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsEvent) Test(org.junit.jupiter.api.Test)

Aggregations

RedbeamsEvent (com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsEvent)17 Test (org.junit.jupiter.api.Test)8 DBStack (com.sequenceiq.redbeams.domain.stack.DBStack)6 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)2 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)2 ExternalDatabaseStatus (com.sequenceiq.cloudbreak.cloud.model.ExternalDatabaseStatus)2 DatabaseServerConfig (com.sequenceiq.redbeams.domain.DatabaseServerConfig)2 RedbeamsContext (com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsContext)2 Event (reactor.bus.Event)2 Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)1 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 Flow (com.sequenceiq.flow.core.Flow)1 FlowParameters (com.sequenceiq.flow.core.FlowParameters)1 RedbeamsFailureEvent (com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsFailureEvent)1 AbstractRedbeamsProvisionAction (com.sequenceiq.redbeams.flow.redbeams.provision.AbstractRedbeamsProvisionAction)1 RedbeamsStartContext (com.sequenceiq.redbeams.flow.redbeams.start.RedbeamsStartContext)1 StartDatabaseServerFailed (com.sequenceiq.redbeams.flow.redbeams.start.event.StartDatabaseServerFailed)1 StartDatabaseServerRequest (com.sequenceiq.redbeams.flow.redbeams.start.event.StartDatabaseServerRequest)1