Search in sources :

Example 1 with CloudbreakOrchestratorCancelledException

use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException in project cloudbreak by hortonworks.

the class ClusterHostServiceRunner method runAmbariServices.

@Transactional
public void runAmbariServices(Stack stack, Cluster cluster) throws CloudbreakException {
    try {
        Set<Node> nodes = collectNodes(stack);
        HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
        GatewayConfig primaryGatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
        List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
        SaltConfig saltConfig = createSaltConfig(stack, cluster, primaryGatewayConfig, gatewayConfigs);
        hostOrchestrator.runService(gatewayConfigs, nodes, saltConfig, clusterDeletionBasedModel(stack.getId(), cluster.getId()));
    } catch (CloudbreakOrchestratorCancelledException e) {
        throw new CancellationException(e.getMessage());
    } catch (CloudbreakOrchestratorException | IOException e) {
        throw new CloudbreakException(e);
    }
}
Also used : CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) CloudbreakOrchestratorCancelledException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) Node(com.sequenceiq.cloudbreak.orchestrator.model.Node) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) IOException(java.io.IOException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Transactional(javax.transaction.Transactional)

Example 2 with CloudbreakOrchestratorCancelledException

use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException in project cloudbreak by hortonworks.

the class ClusterContainerRunner method addClusterContainers.

public Map<String, List<Container>> addClusterContainers(Long stackId, String hostGroupName, Integer scalingAdjustment) throws CloudbreakException {
    try {
        Stack stack = stackRepository.findOneWithLists(stackId);
        String cloudPlatform = StringUtils.isNotEmpty(stack.cloudPlatform()) ? stack.cloudPlatform() : NONE;
        return addClusterContainers(stack, cloudPlatform, hostGroupName, scalingAdjustment);
    } catch (CloudbreakOrchestratorCancelledException e) {
        throw new CancellationException(e.getMessage());
    } catch (CloudbreakOrchestratorException e) {
        throw new CloudbreakException(e);
    }
}
Also used : CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorCancelledException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 3 with CloudbreakOrchestratorCancelledException

use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException in project cloudbreak by hortonworks.

the class ClusterBootstrapper method bootstrapNewNodes.

public void bootstrapNewNodes(Long stackId, Set<String> upscaleCandidateAddresses, Collection<String> recoveryHostNames) throws CloudbreakException {
    Stack stack = stackRepository.findOneWithLists(stackId);
    Set<Node> nodes = new HashSet<>();
    Set<Node> allNodes = new HashSet<>();
    boolean recoveredNodes = Integer.valueOf(recoveryHostNames.size()).equals(upscaleCandidateAddresses.size());
    Set<InstanceMetaData> metaDataSet = stack.getRunningInstanceMetaData().stream().filter(im -> im.getPrivateIp() != null && im.getPublicIpWrapper() != null).collect(Collectors.toSet());
    String clusterDomain = metaDataSet.stream().filter(im -> isNoneBlank(im.getDiscoveryFQDN())).findAny().get().getDomain();
    for (InstanceMetaData im : metaDataSet) {
        Node node = createNode(stack.getCustomHostname(), im, clusterDomain, stack.isHostgroupNameAsHostname());
        if (upscaleCandidateAddresses.contains(im.getPrivateIp())) {
            // but only when we would have generated a hostname, otherwise use the cloud provider's default mechanism
            if (recoveredNodes && isNoneBlank(node.getHostname())) {
                Iterator<String> iterator = recoveryHostNames.iterator();
                node.setHostname(iterator.next().split("\\.")[0]);
                iterator.remove();
                LOGGER.info("Set the hostname to {} for address: {}", node.getHostname(), im.getPrivateIp());
            }
            nodes.add(node);
        }
        allNodes.add(node);
    }
    try {
        String stackOrchestratorType = stack.getOrchestrator().getType();
        OrchestratorType orchestratorType = orchestratorTypeResolver.resolveType(stack.getOrchestrator().getType());
        if (orchestratorType.hostOrchestrator()) {
            List<GatewayConfig> allGatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
            bootstrapNewNodesOnHost(stack, allGatewayConfigs, nodes, allNodes);
        } else if (orchestratorType.containerOrchestrator()) {
            LOGGER.info("Skipping bootstrap of the new machines because the stack's orchestrator type is '{}'.", stackOrchestratorType);
        } else {
            LOGGER.error("Orchestrator not found: {}", stackOrchestratorType);
            throw new CloudbreakException("HostOrchestrator not found: " + stackOrchestratorType);
        }
    } catch (CloudbreakOrchestratorCancelledException e) {
        throw new CancellationException(e.getMessage());
    } catch (CloudbreakOrchestratorException e) {
        throw new CloudbreakException(e);
    }
}
Also used : CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) ComponentType(com.sequenceiq.cloudbreak.common.type.ComponentType) CloudbreakOrchestratorCancelledException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException) LoggerFactory(org.slf4j.LoggerFactory) HostDiscoveryService(com.sequenceiq.cloudbreak.common.service.HostDiscoveryService) Orchestrator(com.sequenceiq.cloudbreak.domain.Orchestrator) Base64(org.apache.commons.codec.binary.Base64) TIMEOUT(com.sequenceiq.cloudbreak.service.PollingResult.TIMEOUT) OrchestratorRepository(com.sequenceiq.cloudbreak.repository.OrchestratorRepository) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) ContainerOrchestratorClusterContext(com.sequenceiq.cloudbreak.core.bootstrap.service.container.context.ContainerOrchestratorClusterContext) Collection(java.util.Collection) Set(java.util.Set) EXIT(com.sequenceiq.cloudbreak.service.PollingResult.EXIT) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) Collectors(java.util.stream.Collectors) HostOrchestratorClusterContext(com.sequenceiq.cloudbreak.core.bootstrap.service.host.context.HostOrchestratorClusterContext) GatewayConfigService(com.sequenceiq.cloudbreak.service.GatewayConfigService) List(java.util.List) ContainerClusterAvailabilityCheckerTask(com.sequenceiq.cloudbreak.core.bootstrap.service.container.ContainerClusterAvailabilityCheckerTask) HostOrchestratorResolver(com.sequenceiq.cloudbreak.core.bootstrap.service.host.HostOrchestratorResolver) Node(com.sequenceiq.cloudbreak.orchestrator.model.Node) ContainerBootstrapApiContext(com.sequenceiq.cloudbreak.core.bootstrap.service.container.context.ContainerBootstrapApiContext) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) StringUtils.isNoneBlank(org.apache.commons.lang3.StringUtils.isNoneBlank) PollingService(com.sequenceiq.cloudbreak.service.PollingService) StackRepository(com.sequenceiq.cloudbreak.repository.StackRepository) ContainerOrchestratorResolver(com.sequenceiq.cloudbreak.core.bootstrap.service.container.ContainerOrchestratorResolver) ContainerBootstrapApiCheckerTask(com.sequenceiq.cloudbreak.core.bootstrap.service.container.ContainerBootstrapApiCheckerTask) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) HostBootstrapApiContext(com.sequenceiq.cloudbreak.core.bootstrap.service.host.context.HostBootstrapApiContext) ClusterComponent(com.sequenceiq.cloudbreak.domain.ClusterComponent) Collections.singletonMap(java.util.Collections.singletonMap) Json(com.sequenceiq.cloudbreak.domain.json.Json) ClusterComponentConfigProvider(com.sequenceiq.cloudbreak.service.ClusterComponentConfigProvider) PollingResult(com.sequenceiq.cloudbreak.service.PollingResult) Stack(com.sequenceiq.cloudbreak.domain.Stack) HostClusterAvailabilityCheckerTask(com.sequenceiq.cloudbreak.core.bootstrap.service.host.HostClusterAvailabilityCheckerTask) ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) HostBootstrapApiCheckerTask(com.sequenceiq.cloudbreak.core.bootstrap.service.host.HostBootstrapApiCheckerTask) Component(org.springframework.stereotype.Component) OrchestratorType(com.sequenceiq.cloudbreak.common.model.OrchestratorType) Node(com.sequenceiq.cloudbreak.orchestrator.model.Node) OrchestratorType(com.sequenceiq.cloudbreak.common.model.OrchestratorType) Stack(com.sequenceiq.cloudbreak.domain.Stack) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorCancelledException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) HashSet(java.util.HashSet) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 4 with CloudbreakOrchestratorCancelledException

use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException in project cloudbreak by hortonworks.

the class ClusterHostServiceRunner method addAmbariServices.

@Transactional
public Map<String, String> addAmbariServices(Long stackId, String hostGroupName, Integer scalingAdjustment) throws CloudbreakException {
    Map<String, String> candidates;
    try {
        Stack stack = stackRepository.findOneWithLists(stackId);
        Cluster cluster = stack.getCluster();
        candidates = collectUpscaleCandidates(cluster.getId(), hostGroupName, scalingAdjustment);
        Set<Node> allNodes = collectNodes(stack);
        HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
        List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
        SaltConfig saltConfig = createSaltConfig(stack, cluster, gatewayConfigService.getPrimaryGatewayConfig(stack), gatewayConfigs);
        hostOrchestrator.runService(gatewayConfigs, allNodes, saltConfig, clusterDeletionBasedModel(stack.getId(), cluster.getId()));
    } catch (CloudbreakOrchestratorCancelledException e) {
        throw new CancellationException(e.getMessage());
    } catch (CloudbreakOrchestratorException | IOException e) {
        throw new CloudbreakException(e);
    }
    return candidates;
}
Also used : HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) Node(com.sequenceiq.cloudbreak.orchestrator.model.Node) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) IOException(java.io.IOException) Stack(com.sequenceiq.cloudbreak.domain.Stack) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorCancelledException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Transactional(javax.transaction.Transactional)

Example 5 with CloudbreakOrchestratorCancelledException

use of com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException in project cloudbreak by hortonworks.

the class OrchestratorBootstrapRunner method doCall.

private ImmutablePair<Boolean, Exception> doCall() throws CloudbreakOrchestratorCancelledException, InterruptedException {
    Boolean success = null;
    int retryCount = 1;
    Exception actualException = null;
    String type = orchestratorBootstrap.getClass().getSimpleName().replace("Bootstrap", "");
    long initialStartTime = System.currentTimeMillis();
    while (success == null && retryCount <= maxRetryCount) {
        if (isExitNeeded()) {
            LOGGER.error(exitCriteria.exitMessage());
            throw new CloudbreakOrchestratorCancelledException(exitCriteria.exitMessage());
        }
        long startTime = System.currentTimeMillis();
        try {
            LOGGER.info("Calling orchestrator bootstrap: {}, additional info: {}", type, orchestratorBootstrap);
            orchestratorBootstrap.call();
            long elapsedTime = System.currentTimeMillis() - startTime;
            long totalElapsedTime = System.currentTimeMillis() - initialStartTime;
            success = true;
            LOGGER.info("Orchestrator component {} successfully started! Elapsed time: {} ms, Total elapsed time: {} ms, " + "additional info: {}", type, elapsedTime, totalElapsedTime, orchestratorBootstrap);
        } catch (CloudbreakOrchestratorTerminateException te) {
            actualException = te;
            long elapsedTime = System.currentTimeMillis() - startTime;
            long totalElapsedTime = System.currentTimeMillis() - initialStartTime;
            success = false;
            LOGGER.info("Failed to execute orchestrator component {}! Elapsed time: {} ms, Total elapsed time: {} ms, " + "additional info: {}", type, elapsedTime, totalElapsedTime, orchestratorBootstrap);
        } catch (Exception ex) {
            actualException = ex;
            long elapsedTime = System.currentTimeMillis() - startTime;
            long totalElapsedTime = System.currentTimeMillis() - initialStartTime;
            LOGGER.warn("Orchestrator component {} failed to start, retrying [{}/{}] Elapsed time: {} ms, " + "Total elapsed time: {} ms, Reason: {}, additional info: {}", type, retryCount, maxRetryCount, elapsedTime, totalElapsedTime, actualException.getMessage(), orchestratorBootstrap);
            retryCount++;
            if (retryCount <= maxRetryCount) {
                Thread.sleep(sleepTime);
            } else {
                success = Boolean.FALSE;
            }
        }
    }
    return new ImmutablePair<>(success, actualException);
}
Also used : CloudbreakOrchestratorCancelledException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) CloudbreakOrchestratorTerminateException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTerminateException) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) CloudbreakOrchestratorCancelledException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException) CloudbreakOrchestratorTerminateException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTerminateException)

Aggregations

CloudbreakOrchestratorCancelledException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException)5 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)4 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)4 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)4 Stack (com.sequenceiq.cloudbreak.domain.Stack)3 HostOrchestrator (com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator)3 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)3 Node (com.sequenceiq.cloudbreak.orchestrator.model.Node)3 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)2 SaltConfig (com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig)2 IOException (java.io.IOException)2 OrchestratorType (com.sequenceiq.cloudbreak.common.model.OrchestratorType)1 HostDiscoveryService (com.sequenceiq.cloudbreak.common.service.HostDiscoveryService)1 ComponentType (com.sequenceiq.cloudbreak.common.type.ComponentType)1 ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel (com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel)1 ContainerBootstrapApiCheckerTask (com.sequenceiq.cloudbreak.core.bootstrap.service.container.ContainerBootstrapApiCheckerTask)1 ContainerClusterAvailabilityCheckerTask (com.sequenceiq.cloudbreak.core.bootstrap.service.container.ContainerClusterAvailabilityCheckerTask)1 ContainerOrchestratorResolver (com.sequenceiq.cloudbreak.core.bootstrap.service.container.ContainerOrchestratorResolver)1 ContainerBootstrapApiContext (com.sequenceiq.cloudbreak.core.bootstrap.service.container.context.ContainerBootstrapApiContext)1 ContainerOrchestratorClusterContext (com.sequenceiq.cloudbreak.core.bootstrap.service.container.context.ContainerOrchestratorClusterContext)1