Search in sources :

Example 11 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class StackImageUpdateFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(StackImageUpdateTriggerEvent event) {
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    flowEventChain.add(new StackSyncTriggerEvent(StackSyncEvent.STACK_SYNC_EVENT.event(), event.getResourceId(), true, event.accepted()));
    flowEventChain.add(new StackEvent(CLUSTER_SYNC_EVENT.event(), event.getResourceId()));
    flowEventChain.add(new StackImageUpdateTriggerEvent(StackImageUpdateEvent.STACK_IMAGE_UPDATE_EVENT.event(), event.getResourceId(), event.getNewImageId(), event.getImageCatalogName(), event.getImageCatalogUrl()));
    return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Also used : StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) StackSyncTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackSyncTriggerEvent) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) StackImageUpdateTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackImageUpdateTriggerEvent)

Example 12 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class PillarConfigUpdateHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<PillarConfigUpdateRequest> event) {
    PillarConfigUpdateRequest request = event.getData();
    Selectable response;
    try {
        pillarConfigUpdateService.doConfigUpdate(request.getResourceId());
        response = new PillarConfigUpdateSuccess(request.getResourceId());
    } catch (Exception e) {
        LOGGER.warn("Pillar configuration update failed.", e);
        response = new PillarConfigUpdateFailed(request.getResourceId(), e);
    }
    return response;
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PillarConfigUpdateRequest(com.sequenceiq.cloudbreak.core.flow2.cluster.config.update.event.PillarConfigUpdateRequest) PillarConfigUpdateFailed(com.sequenceiq.cloudbreak.core.flow2.cluster.config.update.event.PillarConfigUpdateFailed) PillarConfigUpdateSuccess(com.sequenceiq.cloudbreak.core.flow2.cluster.config.update.event.PillarConfigUpdateSuccess)

Example 13 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class BackupDatalakeDatabaseFlowEventChainFactory method createFlowTriggerEventQueue.

@Override
public FlowTriggerEventQueue createFlowTriggerEventQueue(DatabaseBackupTriggerEvent event) {
    Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>();
    flowEventChain.add(new StackEvent(SaltUpdateEvent.SALT_UPDATE_EVENT.event(), event.getResourceId(), event.accepted()));
    flowEventChain.add(new DatabaseBackupTriggerEvent(DATABASE_BACKUP_EVENT.event(), event.getResourceId(), event.getBackupLocation(), event.getBackupId(), event.getCloseConnections()));
    return new FlowTriggerEventQueue(getName(), event, flowEventChain);
}
Also used : StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) FlowTriggerEventQueue(com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) DatabaseBackupTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.DatabaseBackupTriggerEvent) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue)

Example 14 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class ClusterRepairFlowEventChainFactory method createFlowTriggers.

private Queue<Selectable> createFlowTriggers(ClusterRepairTriggerEvent event, RepairConfig repairConfig) {
    Queue<Selectable> flowTriggers = new ConcurrentLinkedDeque<>();
    flowTriggers.add(new FlowChainInitPayload(getName(), event.getResourceId(), event.accepted()));
    Map<String, Set<String>> repairableGroupsWithHostNames = new HashMap<>();
    boolean singlePrimaryGW = fillRepairableGroupsWithHostNames(repairConfig, repairableGroupsWithHostNames);
    LOGGER.info("Repairable groups with host names: {}", repairableGroupsWithHostNames);
    addDownscaleAndUpscaleEvents(event, flowTriggers, repairableGroupsWithHostNames, singlePrimaryGW);
    flowTriggers.add(rescheduleStatusCheckEvent(event));
    flowTriggers.add(new FlowChainFinalizePayload(getName(), event.getResourceId(), event.accepted()));
    return flowTriggers;
}
Also used : FlowChainInitPayload(com.sequenceiq.flow.core.chain.init.flowevents.FlowChainInitPayload) Set(java.util.Set) HashSet(java.util.HashSet) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) HashMap(java.util.HashMap) FlowChainFinalizePayload(com.sequenceiq.flow.core.chain.finalize.flowevents.FlowChainFinalizePayload) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque)

Example 15 with Selectable

use of com.sequenceiq.cloudbreak.common.event.Selectable in project cloudbreak by hortonworks.

the class StartExternalDatabaseHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<StartExternalDatabaseRequest> event) {
    LOGGER.debug("In StartExternalDatabaseHandler.doAccept");
    StartExternalDatabaseRequest request = event.getData();
    Stack stack = stackService.getById(request.getResourceId());
    DatabaseAvailabilityType externalDatabase = ObjectUtils.defaultIfNull(stack.getExternalDatabaseCreationType(), DatabaseAvailabilityType.NONE);
    LOGGER.debug("External database: {} for stack {}", externalDatabase.name(), stack.getName());
    LOGGER.debug("Getting environment CRN for stack {}", stack.getName());
    DetailedEnvironmentResponse environment = environmentClientService.getByCrn(stack.getEnvironmentCrn());
    Selectable result;
    try {
        if (StackType.WORKLOAD != stack.getType()) {
            LOGGER.debug("External database start in Cloudbreak service is required for WORKLOAD stacks only.");
            result = new StartExternalDatabaseResult(stack.getId(), EXTERNAL_DATABASE_STARTED_EVENT.event(), stack.getName(), null);
        } else if (externalDatabase.isEmbedded()) {
            LOGGER.info("External database for stack {} is not requested. Start is not possible.", stack.getName());
            result = new StartExternalDatabaseResult(stack.getId(), EXTERNAL_DATABASE_STARTED_EVENT.event(), stack.getName(), null);
        } else if (!externalDatabaseConfig.isExternalDatabasePauseSupportedFor(CloudPlatform.valueOf(environment.getCloudPlatform()))) {
            LOGGER.debug("External database pause is not supported for '{}' cloud platform.", environment.getCloudPlatform());
            result = new StartExternalDatabaseResult(stack.getId(), EXTERNAL_DATABASE_STARTED_EVENT.event(), stack.getName(), null);
        } else {
            LOGGER.debug("Updating stack {} status from {} to {}", stack.getName(), stack.getStatus().name(), DetailedStackStatus.EXTERNAL_DATABASE_START_IN_PROGRESS.name());
            stackUpdaterService.updateStatus(stack.getId(), DetailedStackStatus.EXTERNAL_DATABASE_START_IN_PROGRESS, ResourceEvent.CLUSTER_EXTERNAL_DATABASE_START_COMMANCED, "External database start in progress");
            startService.startDatabase(stack.getCluster(), externalDatabase, environment);
            LOGGER.debug("Updating stack {} status from {} to {}", stack.getName(), stack.getStatus().name(), DetailedStackStatus.EXTERNAL_DATABASE_START_FINISHED.name());
            stackUpdaterService.updateStatus(stack.getId(), DetailedStackStatus.EXTERNAL_DATABASE_START_FINISHED, ResourceEvent.CLUSTER_EXTERNAL_DATABASE_START_FINISHED, "External database start finished");
            result = new StartExternalDatabaseResult(stack.getId(), EXTERNAL_DATABASE_STARTED_EVENT.event(), stack.getName(), stack.getCluster().getDatabaseServerCrn());
        }
    } catch (UserBreakException e) {
        LOGGER.error("Database 'start' polling exited before timeout. Cause: ", e);
        result = startFailedEvent(stack, e);
    } catch (PollerStoppedException e) {
        LOGGER.error(String.format("Database 'start' poller stopped for stack: %s", stack.getName()), e);
        result = startFailedEvent(stack, e);
    } catch (PollerException e) {
        LOGGER.error(String.format("Database 'start' polling failed for stack: %s", stack.getName()), e);
        result = startFailedEvent(stack, e);
    }
    return result;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) StartExternalDatabaseResult(com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.StartExternalDatabaseResult) PollerException(com.dyngr.exception.PollerException) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) StartExternalDatabaseRequest(com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.StartExternalDatabaseRequest) PollerStoppedException(com.dyngr.exception.PollerStoppedException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) DatabaseAvailabilityType(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseAvailabilityType)

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