Search in sources :

Example 21 with ClusterApi

use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.

the class ClusterBuilderService method startCluster.

public void startCluster(Long stackId) throws CloudbreakException, ClusterClientInitException {
    Stack stack = stackService.getByIdWithTransaction(stackId);
    ClusterApi connector = clusterApiConnectors.getConnector(stack);
    connector.waitForServer(stack, true);
    boolean ldapConfigured = ldapConfigService.isLdapConfigExistsForEnvironment(stack.getEnvironmentCrn(), stack.getName());
    connector.changeOriginalCredentialsAndCreateCloudbreakUser(ldapConfigured);
}
Also used : ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 22 with ClusterApi

use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi 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 23 with ClusterApi

use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.

the class ClusterUpscaleService method installServicesOnNewHosts.

public void installServicesOnNewHosts(Long stackId, Set<String> hostGroupNames, Boolean repair, Boolean restartServices, Map<String, Set<String>> hostGroupsWithHostNames) throws CloudbreakException {
    Stack stack = stackService.getByIdWithClusterInTransaction(stackId);
    LOGGER.debug("Start installing CM services");
    removeUnusedParcelComponents(stack);
    Set<HostGroup> hostGroupSetWithRecipes = hostGroupService.getByClusterWithRecipes(stack.getCluster().getId());
    Set<HostGroup> hostGroupSetWithInstanceMetadas = hostGroupService.getByCluster(stack.getCluster().getId());
    Map<HostGroup, Set<InstanceMetaData>> instanceMetaDatasByHostGroup = hostGroupSetWithInstanceMetadas.stream().filter(hostGroup -> hostGroupNames.contains(hostGroup.getName())).collect(Collectors.toMap(Function.identity(), hostGroup -> hostGroup.getInstanceGroup().getRunningInstanceMetaDataSet()));
    recipeEngine.executePostAmbariStartRecipes(stack, hostGroupSetWithRecipes);
    Set<InstanceMetaData> runningInstanceMetaDataSet = hostGroupSetWithInstanceMetadas.stream().flatMap(hostGroup -> hostGroup.getInstanceGroup().getRunningInstanceMetaDataSet().stream()).collect(Collectors.toSet());
    ClusterApi connector = getClusterConnector(stack);
    List<String> upscaledHosts = connector.upscaleCluster(instanceMetaDatasByHostGroup);
    if (Boolean.TRUE.equals(repair)) {
        recommissionHostsIfNeeded(connector, hostGroupsWithHostNames);
        restartServicesIfNecessary(restartServices, stack, connector);
    }
    setInstanceStatus(runningInstanceMetaDataSet, upscaledHosts);
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) LoggerFactory(org.slf4j.LoggerFactory) HostGroupService(com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService) Function(java.util.function.Function) KerberosConfigService(com.sequenceiq.cloudbreak.kerberos.KerberosConfigService) ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Service(org.springframework.stereotype.Service) Map(java.util.Map) InstanceMetaDataService(com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService) RecipeEngine(com.sequenceiq.cloudbreak.service.cluster.flow.recipe.RecipeEngine) Logger(org.slf4j.Logger) ParcelOperationStatus(com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) Set(java.util.Set) ParcelService(com.sequenceiq.cloudbreak.service.parcel.ParcelService) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) List(java.util.List) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ClusterApiConnectors(com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors) KerberosConfig(com.sequenceiq.cloudbreak.dto.KerberosConfig) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) HashSet(java.util.HashSet) Set(java.util.Set) ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 24 with ClusterApi

use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.

the class ClusterStartPollingHandler method accept.

@Override
public void accept(Event<ClusterStartPollingRequest> event) {
    ClusterStartPollingRequest request = event.getData();
    ClusterStartPollingResult result;
    try {
        Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
        ClusterApi connector = clusterApiConnectors.getConnector(stack);
        connector.waitForServices(request.getRequestId());
        result = new ClusterStartPollingResult(request);
    } catch (Exception e) {
        result = new ClusterStartPollingResult(e.getMessage(), e, request);
    }
    eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
Also used : ClusterStartPollingResult(com.sequenceiq.cloudbreak.reactor.api.event.cluster.ClusterStartPollingResult) ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) ClusterStartPollingRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.ClusterStartPollingRequest) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 25 with ClusterApi

use of com.sequenceiq.cloudbreak.cluster.api.ClusterApi in project cloudbreak by hortonworks.

the class DisableKerberosHandler method accept.

@Override
public void accept(Event<DisableKerberosRequest> event) {
    DisableKerberosResult result;
    try {
        LOGGER.info("Received DisableKerberosRequest event: {}", event.getData());
        ClusterApi clusterApi = clusterApiConnectors.getConnector(stackService.getByIdWithListsInTransaction(event.getData().getResourceId()));
        clusterApi.clusterSecurityService().disableSecurity();
        LOGGER.info("Finished disabling Security");
        result = new DisableKerberosResult(event.getData());
    } catch (Exception e) {
        LOGGER.warn("An error has occured during disabling security", e);
        result = new DisableKerberosResult(e.getMessage(), e, event.getData());
    }
    LOGGER.info("Sending out DisableKerberosResult: {}", result);
    eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
    LOGGER.info("DisableKerberosResult has been sent");
}
Also used : ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) DisableKerberosResult(com.sequenceiq.cloudbreak.reactor.api.event.cluster.DisableKerberosResult)

Aggregations

ClusterApi (com.sequenceiq.cloudbreak.cluster.api.ClusterApi)27 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)20 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)9 Set (java.util.Set)7 ExtendedHostStatuses (com.sequenceiq.cloudbreak.cluster.status.ExtendedHostStatuses)6 ParcelOperationStatus (com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus)5 ClusterApiConnectors (com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors)5 ClusterStatusService (com.sequenceiq.cloudbreak.cluster.api.ClusterStatusService)4 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)4 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)4 InstanceMetaDataService (com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService)4 StackService (com.sequenceiq.cloudbreak.service.stack.StackService)4 Collectors (java.util.stream.Collectors)4 Inject (javax.inject.Inject)4 Test (org.junit.jupiter.api.Test)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 Service (org.springframework.stereotype.Service)4 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)3 HostName (com.sequenceiq.cloudbreak.cloud.model.HostName)3