Search in sources :

Example 41 with Selectable

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

the class ValidateClusterLicenceHandler method doAccept.

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

Example 42 with Selectable

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

the class LdapSSOConfigurationHandler method accept.

@Override
public void accept(Event<LdapSSOConfigurationRequest> ldapConfigurationRequestEvent) {
    Long stackId = ldapConfigurationRequestEvent.getData().getResourceId();
    Selectable response;
    try {
        Stack stack = stackService.getByIdWithListsInTransaction(stackId);
        GatewayConfig primaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
        LdapView ldapView = ldapConfigService.get(stack.getEnvironmentCrn(), stack.getName()).orElse(null);
        String environmentCrnForVirtualGroups = environmentConfigProvider.getParentEnvironmentCrn(stack.getEnvironmentCrn());
        VirtualGroupRequest virtualGroupRequest = new VirtualGroupRequest(environmentCrnForVirtualGroups, ldapView != null ? ldapView.getAdminGroup() : "");
        clusterApiConnectors.getConnector(stack).clusterSecurityService().setupLdapAndSSO(primaryGatewayConfig.getPublicAddress(), ldapView, virtualGroupRequest);
        response = new LdapSSOConfigurationSuccess(stackId);
    } catch (Exception e) {
        LOGGER.info("Error during LDAP configuration, stackId: " + stackId, e);
        response = new LdapSSOConfigurationFailed(stackId, e);
    }
    eventBus.notify(response.selector(), new Event<>(ldapConfigurationRequestEvent.getHeaders(), response));
}
Also used : LdapSSOConfigurationFailed(com.sequenceiq.cloudbreak.reactor.api.event.ldap.LdapSSOConfigurationFailed) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) LdapView(com.sequenceiq.cloudbreak.dto.LdapView) LdapSSOConfigurationSuccess(com.sequenceiq.cloudbreak.reactor.api.event.ldap.LdapSSOConfigurationSuccess) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 43 with Selectable

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

the class BootstrapMachineHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<BootstrapMachinesRequest> event) {
    BootstrapMachinesRequest request = event.getData();
    Selectable response;
    try {
        if (request.isReBootstrap()) {
            LOGGER.info("RE-Bootstrap machines");
            clusterBootstrapper.reBootstrapMachines(request.getResourceId());
            clusterProxyService.reRegisterCluster(request.getResourceId());
        } else {
            LOGGER.info("Bootstrap machines");
            clusterBootstrapper.bootstrapMachines(request.getResourceId());
        }
        response = new BootstrapMachinesSuccess(request.getResourceId());
    } catch (Exception e) {
        LOGGER.warn("Bootstrap machines failed (rebootstrap:{})", request.isReBootstrap(), e);
        response = new BootstrapMachinesFailed(request.getResourceId(), e);
    }
    return response;
}
Also used : BootstrapMachinesFailed(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.BootstrapMachinesFailed) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) BootstrapMachinesSuccess(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.BootstrapMachinesSuccess) BootstrapMachinesRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.BootstrapMachinesRequest)

Example 44 with Selectable

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

the class ClusterProxyGatewayRegistrationHandler method accept.

@Override
public void accept(Event<ClusterProxyGatewayRegistrationRequest> event) {
    ClusterProxyGatewayRegistrationRequest request = event.getData();
    Selectable response;
    try {
        if (clusterProxyEnablementService.isClusterProxyApplicable(request.getCloudPlatform())) {
            clusterProxyService.registerGatewayConfiguration(request.getResourceId());
            response = new ClusterProxyGatewayRegistrationSuccess(request.getResourceId());
        } else {
            LOGGER.info("Cluster Proxy integration is DISABLED, skipping registering gateway configuration with Cluster Proxy service.");
            response = new ClusterProxyGatewayRegistrationSuccess(request.getResourceId());
        }
    } catch (Exception e) {
        LOGGER.error("Error occurred when registering gateway config with cluster proxy", e);
        response = new ClusterProxyGatewayRegistrationFailed(request.getResourceId(), e);
    }
    eventBus.notify(response.selector(), new Event<>(event.getHeaders(), response));
}
Also used : ClusterProxyGatewayRegistrationFailed(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyGatewayRegistrationFailed) ClusterProxyGatewayRegistrationSuccess(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyGatewayRegistrationSuccess) ClusterProxyGatewayRegistrationRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.ClusterProxyGatewayRegistrationRequest) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable)

Example 45 with Selectable

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

the class RemoveHostsHandler method accept.

@Override
public void accept(Event<RemoveHostsRequest> removeHostsRequestEvent) {
    RemoveHostsRequest request = removeHostsRequestEvent.getData();
    Set<String> hostNames = request.getHostNames();
    Selectable result;
    try {
        Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
        if (stack.getPrimaryGatewayInstance() != null && stack.getPrimaryGatewayInstance().isReachable()) {
            List<GatewayConfig> allGatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
            PollingResult orchestratorRemovalPollingResult = removeHostsFromOrchestrator(stack, new ArrayList<>(hostNames), hostOrchestrator, allGatewayConfigs);
            if (!orchestratorRemovalPollingResult.isSuccess()) {
                LOGGER.warn("Can not remove hosts from orchestrator: {}", hostNames);
            }
        } else {
            LOGGER.warn("Primary gateway is not reachable, can't remove hosts from orchestrator");
        }
        result = new RemoveHostsSuccess(request.getResourceId(), request.getHostGroupNames(), hostNames);
    } catch (Exception e) {
        result = new RemoveHostsFailed(removeHostsRequestEvent.getData().getResourceId(), e, request.getHostGroupNames(), hostNames);
    }
    eventBus.notify(result.selector(), new Event<>(removeHostsRequestEvent.getHeaders(), result));
}
Also used : RemoveHostsSuccess(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsSuccess) RemoveHostsFailed(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsFailed) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) RemoveHostsRequest(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.RemoveHostsRequest) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollingResult(com.sequenceiq.cloudbreak.polling.PollingResult) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

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