Search in sources :

Example 16 with ClusterClientInitException

use of com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException in project cloudbreak by hortonworks.

the class WaitClusterManagerHandler method doAccept.

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

Example 17 with ClusterClientInitException

use of com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException in project cloudbreak by hortonworks.

the class ClusterManagerUpscaleService method upscaleClusterManager.

public void upscaleClusterManager(Long stackId, Map<String, Integer> hostGroupWithAdjustment, boolean primaryGatewayChanged, boolean repair) throws ClusterClientInitException {
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    // we need to fetch the cluster with the details, to avoid the unnecessary DB querying later
    Long clusterId = stack.getCluster().getId();
    Cluster cluster = clusterService.findOneWithLists(clusterId).orElseThrow(NotFoundException.notFound("Cluster", clusterId));
    LOGGER.debug("Adding new nodes for host group {}", hostGroupWithAdjustment);
    NodeReachabilityResult nodeReachabilityResult = hostRunner.addClusterServices(stack, cluster, hostGroupWithAdjustment, repair);
    if (primaryGatewayChanged) {
        clusterServiceRunner.updateAmbariClientConfig(stack, cluster);
    }
    clusterService.updateInstancesToRunning(clusterId, nodeReachabilityResult.getReachableNodes());
    clusterService.updateInstancesToZombie(stackId, nodeReachabilityResult.getUnreachableNodes());
    ClusterApi connector = clusterApiConnectors.getConnector(stack);
    ExtendedPollingResult result;
    if (!repair && !primaryGatewayChanged && targetedUpscaleSupportService.targetedUpscaleOperationSupported(stack)) {
        Set<String> reachableHosts = nodeReachabilityResult.getReachableHosts();
        Set<InstanceMetaData> reachableInstances = stack.getNotDeletedAndNotZombieInstanceMetaDataSet().stream().filter(md -> reachableHosts.contains(md.getDiscoveryFQDN())).collect(Collectors.toSet());
        result = connector.waitForHosts(reachableInstances);
    } else {
        result = connector.waitForHosts(stackService.getByIdWithListsInTransaction(stackId).getRunningInstanceMetaDataSet());
    }
    if (result != null && result.isTimeout()) {
        LOGGER.info("Upscaling cluster manager were not successful for nodes: {}", result.getFailedInstanceIds());
        instanceMetaDataService.updateInstanceStatus(result.getFailedInstanceIds(), InstanceStatus.ZOMBIE, "Upscaling cluster manager were not successful.");
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Logger(org.slf4j.Logger) NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult) ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) LoggerFactory(org.slf4j.LoggerFactory) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) Set(java.util.Set) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) ClusterService(com.sequenceiq.cloudbreak.service.cluster.ClusterService) Collectors(java.util.stream.Collectors) ClusterHostServiceRunner(com.sequenceiq.cloudbreak.core.bootstrap.service.host.ClusterHostServiceRunner) ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) TargetedUpscaleSupportService(com.sequenceiq.cloudbreak.service.stack.TargetedUpscaleSupportService) Inject(javax.inject.Inject) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Service(org.springframework.stereotype.Service) Map(java.util.Map) ClusterApiConnectors(com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors) InstanceMetaDataService(com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService) ClusterServiceRunner(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterServiceRunner) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 18 with ClusterClientInitException

use of com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException in project cloudbreak by hortonworks.

the class AutoConfigureClusterManagerHandler method accept.

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

Example 19 with ClusterClientInitException

use of com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException in project cloudbreak by hortonworks.

the class ClouderaManagerModificationService method initApiClient.

@PostConstruct
public void initApiClient() throws ClusterClientInitException {
    Cluster cluster = stack.getCluster();
    String user = cluster.getCloudbreakAmbariUser();
    String password = cluster.getCloudbreakAmbariPassword();
    try {
        apiClient = clouderaManagerApiClientProvider.getV31Client(stack.getGatewayPort(), user, password, clientConfig);
    } catch (ClouderaManagerClientInitException e) {
        throw new ClusterClientInitException(e);
    }
}
Also used : ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) PostConstruct(javax.annotation.PostConstruct)

Example 20 with ClusterClientInitException

use of com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException in project cloudbreak by hortonworks.

the class ClouderaManagerSetupService method waitForHostsHealthy.

@Override
public void waitForHostsHealthy(Set<InstanceMetaData> hostsInCluster) throws ClusterClientInitException {
    Cluster cluster = stack.getCluster();
    String user = cluster.getCloudbreakAmbariUser();
    String password = cluster.getCloudbreakAmbariPassword();
    ApiClient client;
    try {
        client = clouderaManagerApiClientProvider.getV31Client(stack.getGatewayPort(), user, password, clientConfig);
    } catch (ClouderaManagerClientInitException e) {
        throw new ClusterClientInitException(e);
    }
    clouderaManagerPollingServiceProvider.startPollingCmHostStatusHealthy(stack, client, hostsInCluster.stream().map(x -> x.getDiscoveryFQDN()).collect(Collectors.toUnmodifiableSet()));
}
Also used : ClusterClientInitException(com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException) ApiCluster(com.cloudera.api.swagger.model.ApiCluster) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ClouderaManagerClientInitException(com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException) ApiClient(com.cloudera.api.swagger.client.ApiClient)

Aggregations

ClusterClientInitException (com.sequenceiq.cloudbreak.cluster.service.ClusterClientInitException)24 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)17 ClouderaManagerClientInitException (com.sequenceiq.cloudbreak.cm.client.ClouderaManagerClientInitException)12 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)10 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)9 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)8 ClusterApi (com.sequenceiq.cloudbreak.cluster.api.ClusterApi)8 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)8 ClusterApiConnectors (com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors)8 StackService (com.sequenceiq.cloudbreak.service.stack.StackService)8 Map (java.util.Map)8 Set (java.util.Set)8 Collectors (java.util.stream.Collectors)8 Test (org.junit.jupiter.api.Test)8 EventStatus (com.sequenceiq.cloudbreak.cloud.event.model.EventStatus)7 ClusterCommissionService (com.sequenceiq.cloudbreak.cluster.api.ClusterCommissionService)7 ClusterSetupService (com.sequenceiq.cloudbreak.cluster.api.ClusterSetupService)7 CloudbreakFlowMessageService (com.sequenceiq.cloudbreak.core.flow2.stack.CloudbreakFlowMessageService)7 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)7 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)7