Search in sources :

Example 26 with Selectable

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

the class ClusterStartPillarConfigUpdateHandler method doAccept.

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

Example 27 with Selectable

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

the class InstallClusterHandler method accept.

@Override
public void accept(Event<InstallClusterRequest> event) {
    Long stackId = event.getData().getResourceId();
    Selectable response;
    try {
        clusterBuilderService.installCluster(stackId);
        response = new InstallClusterSuccess(stackId);
    } catch (RuntimeException | ClusterClientInitException | CloudbreakException e) {
        LOGGER.error("Failed to Install Cloudera Manager cluster: {}", e.getMessage());
        response = new InstallClusterFailed(stackId, e);
    }
    eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
Also used : InstallClusterFailed(com.sequenceiq.cloudbreak.reactor.api.event.cluster.InstallClusterFailed) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) InstallClusterSuccess(com.sequenceiq.cloudbreak.reactor.api.event.cluster.InstallClusterSuccess)

Example 28 with Selectable

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

the class DatabaseBackupHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<DatabaseBackupRequest> event) {
    DatabaseBackupRequest request = event.getData();
    Selectable result;
    Long stackId = request.getResourceId();
    LOGGER.debug("Backing up database on stack {}, backup id {}", stackId, request.getBackupId());
    try {
        Stack stack = stackService.getByIdWithListsInTransaction(stackId);
        Cluster cluster = stack.getCluster();
        InstanceMetaData gatewayInstance = stack.getPrimaryGatewayInstance();
        GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, gatewayInstance, cluster.hasGateway());
        Set<String> gatewayFQDN = Collections.singleton(gatewayInstance.getDiscoveryFQDN());
        ExitCriteriaModel exitModel = ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel(stackId, cluster.getId());
        String rangerAdminGroup = rangerVirtualGroupService.getRangerVirtualGroup(stack);
        SaltConfig saltConfig = saltConfigGenerator.createSaltConfig(request.getBackupLocation(), request.getBackupId(), rangerAdminGroup, request.getCloseConnections(), stack);
        hostOrchestrator.backupDatabase(gatewayConfig, gatewayFQDN, stackUtil.collectReachableNodes(stack), saltConfig, exitModel);
        result = new DatabaseBackupSuccess(stackId);
    } catch (Exception e) {
        LOGGER.error("Database backup event failed", e);
        result = new DatabaseBackupFailedEvent(stackId, e, DetailedStackStatus.DATABASE_BACKUP_FAILED);
    }
    return result;
}
Also used : ExitCriteriaModel(com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel) ClusterDeletionBasedExitCriteriaModel(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) DatabaseBackupRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.dr.backup.DatabaseBackupRequest) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) DatabaseBackupFailedEvent(com.sequenceiq.cloudbreak.reactor.api.event.cluster.dr.backup.DatabaseBackupFailedEvent) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) DatabaseBackupSuccess(com.sequenceiq.cloudbreak.reactor.api.event.cluster.dr.backup.DatabaseBackupSuccess) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 29 with Selectable

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

the class ClusterManagerConfigureKerberosHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<ClusterManagerConfigureKerberosRequest> event) {
    Long stackId = event.getData().getResourceId();
    Selectable response;
    try {
        clusterBuilderService.configureKerberos(stackId);
        response = new ClusterManagerConfigureKerberosSuccess(stackId);
    } catch (RuntimeException | CloudbreakException e) {
        LOGGER.error("ClusterManagerConfigureKerberosHandler step failed with the following message: {}", e.getMessage());
        response = new ClusterManagerConfigureKerberosFailed(stackId, e);
    }
    return response;
}
Also used : ClusterManagerConfigureKerberosSuccess(com.sequenceiq.cloudbreak.reactor.api.event.cluster.install.ClusterManagerConfigureKerberosSuccess) ClusterManagerConfigureKerberosFailed(com.sequenceiq.cloudbreak.reactor.api.event.cluster.install.ClusterManagerConfigureKerberosFailed) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException)

Example 30 with Selectable

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

the class ConfigureClusterManagerManagementServicesHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<ConfigureClusterManagerManagementServicesRequest> event) {
    Long stackId = event.getData().getResourceId();
    Selectable response;
    try {
        clusterBuilderService.configureManagementServices(stackId);
        response = new ConfigureClusterManagerManagementServicesSuccess(stackId);
    } catch (RuntimeException e) {
        LOGGER.error("ConfigureClusterManagerManagementServicesHandler step failed with the following message: {}", e.getMessage());
        response = new ConfigureClusterManagerManagementServicesFailed(stackId, e);
    }
    return response;
}
Also used : ConfigureClusterManagerManagementServicesFailed(com.sequenceiq.cloudbreak.reactor.api.event.cluster.install.ConfigureClusterManagerManagementServicesFailed) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ConfigureClusterManagerManagementServicesSuccess(com.sequenceiq.cloudbreak.reactor.api.event.cluster.install.ConfigureClusterManagerManagementServicesSuccess)

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