Search in sources :

Example 16 with HostGroup

use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.

the class ClusterHostServiceRunner method saveSharedRangerService.

private void saveSharedRangerService(Stack stack, Map<String, SaltPillarProperties> servicePillar) {
    Long datalakeId = stack.getDatalakeId();
    if (datalakeId != null) {
        Stack dataLakeStack = stackRepository.findOne(datalakeId);
        Cluster dataLakeCluster = dataLakeStack.getCluster();
        Set<String> groupNames = blueprintProcessorFactory.get(dataLakeCluster.getBlueprint().getBlueprintText()).getHostGroupsWithComponent("RANGER_ADMIN");
        List<HostGroup> groups = dataLakeCluster.getHostGroups().stream().filter(hg -> groupNames.contains(hg.getName())).collect(Collectors.toList());
        Set<String> hostNames = new HashSet<>();
        groups.forEach(hg -> hostNames.addAll(hg.getHostMetadata().stream().map(HostMetadata::getHostName).collect(Collectors.toList())));
        Map<String, Object> rangerMap = new HashMap<>();
        rangerMap.put("servers", hostNames);
        rangerMap.put("port", "6080");
        servicePillar.put("datalake-services", new SaltPillarProperties("/datalake/init.sls", singletonMap("datalake-services", singletonMap("ranger", rangerMap))));
    }
}
Also used : CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) KerberosConfig(com.sequenceiq.cloudbreak.domain.KerberosConfig) AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo) InstanceMetaDataRepository(com.sequenceiq.cloudbreak.repository.InstanceMetaDataRepository) KerberosDetailService(com.sequenceiq.cloudbreak.blueprint.kerberos.KerberosDetailService) CloudbreakOrchestratorCancelledException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException) StringUtils(org.apache.commons.lang3.StringUtils) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) RdsConfigService(com.sequenceiq.cloudbreak.service.rdsconfig.RdsConfigService) Map(java.util.Map) AmbariSecurityConfigProvider(com.sequenceiq.cloudbreak.service.cluster.ambari.AmbariSecurityConfigProvider) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) RdsView(com.sequenceiq.cloudbreak.blueprint.template.views.RdsView) Transactional(javax.transaction.Transactional) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) Set(java.util.Set) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) Collectors(java.util.stream.Collectors) GatewayConfigService(com.sequenceiq.cloudbreak.service.GatewayConfigService) ProxyConfigProvider(com.sequenceiq.cloudbreak.service.proxy.ProxyConfigProvider) List(java.util.List) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) Node(com.sequenceiq.cloudbreak.orchestrator.model.Node) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Optional(java.util.Optional) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) SmartSenseCredentialConfigService(com.sequenceiq.cloudbreak.service.SmartSenseCredentialConfigService) StackRepository(com.sequenceiq.cloudbreak.repository.StackRepository) RdsType(com.sequenceiq.cloudbreak.api.model.rds.RdsType) HashMap(java.util.HashMap) HostGroupRepository(com.sequenceiq.cloudbreak.repository.HostGroupRepository) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata) StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) Collections.singletonMap(java.util.Collections.singletonMap) RDSConfig(com.sequenceiq.cloudbreak.domain.RDSConfig) Json(com.sequenceiq.cloudbreak.domain.json.Json) ClusterComponentConfigProvider(com.sequenceiq.cloudbreak.service.ClusterComponentConfigProvider) Stack(com.sequenceiq.cloudbreak.domain.Stack) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel(com.sequenceiq.cloudbreak.core.bootstrap.service.ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) ExposedServices(com.sequenceiq.cloudbreak.domain.ExposedServices) IOException(java.io.IOException) PostgresConfigService(com.sequenceiq.cloudbreak.core.bootstrap.service.container.postgres.PostgresConfigService) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) ExecutorType(com.sequenceiq.cloudbreak.api.model.ExecutorType) Component(org.springframework.stereotype.Component) ExposedService(com.sequenceiq.cloudbreak.api.model.ExposedService) BlueprintProcessorFactory(com.sequenceiq.cloudbreak.blueprint.BlueprintProcessorFactory) AmbariDatabaseMapper(com.sequenceiq.cloudbreak.converter.mapper.AmbariDatabaseMapper) ComponentLocatorService(com.sequenceiq.cloudbreak.service.blueprint.ComponentLocatorService) Comparator(java.util.Comparator) Collections(java.util.Collections) LdapConfig(com.sequenceiq.cloudbreak.domain.LdapConfig) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) HashMap(java.util.HashMap) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) Stack(com.sequenceiq.cloudbreak.domain.Stack) HashSet(java.util.HashSet)

Example 17 with HostGroup

use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.

the class DependecyDeletionService method deleteDependencies.

public void deleteDependencies(Stack stack) {
    deleteNetwork(stack.getNetwork());
    deleteCredential(stack.getCredential());
    for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
        deleteSecurityGroup(instanceGroup.getSecurityGroup());
        deleteTemplate(instanceGroup.getTemplate());
    }
    if (stack.getCluster() != null) {
        Cluster cluster = stack.getCluster();
        deleteBlueprint(cluster.getBlueprint());
        Set<HostGroup> hostGroupsInCluster = hostGroupRepository.findHostGroupsInCluster(cluster.getId());
        for (HostGroup hostGroup : hostGroupsInCluster) {
            hostGroup.getRecipes().forEach(this::deleteRecipe);
        }
    }
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Example 18 with HostGroup

use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.

the class AmbariClusterService method hostGroupCounter.

private void hostGroupCounter(Long clusterId, Map<String, Integer> hostGroupCounter) {
    LOGGER.info("Counted hostgroups: {}", hostGroupCounter);
    Set<HostGroup> hostGroups = hostGroupService.getByCluster(clusterId);
    for (HostGroup hostGroup : hostGroups) {
        Integer hgCounter = hostGroupCounter.getOrDefault(hostGroup.getName(), 0);
        if (!hgCounter.equals(hostGroup.getConstraint().getHostCount())) {
            hostGroup.getConstraint().setHostCount(hgCounter);
            constraintRepository.save(hostGroup.getConstraint());
            LOGGER.info("Updated HostCount for hostgroup: {}, counter: {}", hostGroup.getName(), hgCounter);
        }
    }
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup)

Example 19 with HostGroup

use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.

the class AmbariClusterService method failureReport.

@Override
public void failureReport(Long stackId, List<String> failedNodes) {
    Stack stack = stackService.get(stackId);
    Cluster cluster = stack.getCluster();
    Map<String, List<String>> autoRecoveryNodesMap = new HashMap<>();
    Map<String, HostMetadata> autoRecoveryHostMetadata = new HashMap<>();
    Map<String, HostMetadata> failedHostMetadata = new HashMap<>();
    for (String failedNode : failedNodes) {
        HostMetadata hostMetadata = hostMetadataRepository.findHostInClusterByName(cluster.getId(), failedNode);
        if (hostMetadata == null) {
            throw new BadRequestException("No metadata information for the node: " + failedNode);
        }
        HostGroup hostGroup = hostMetadata.getHostGroup();
        if (hostGroup.getRecoveryMode() == RecoveryMode.AUTO) {
            validateRepair(stack, hostMetadata);
        }
        String hostGroupName = hostGroup.getName();
        if (hostGroup.getRecoveryMode() == RecoveryMode.AUTO) {
            List<String> nodeList = autoRecoveryNodesMap.get(hostGroupName);
            if (nodeList == null) {
                validateComponentsCategory(stack, hostGroupName);
                nodeList = new ArrayList<>();
                autoRecoveryNodesMap.put(hostGroupName, nodeList);
            }
            nodeList.add(failedNode);
            autoRecoveryHostMetadata.put(failedNode, hostMetadata);
        } else if (hostGroup.getRecoveryMode() == RecoveryMode.MANUAL) {
            failedHostMetadata.put(failedNode, hostMetadata);
        }
    }
    if (!autoRecoveryNodesMap.isEmpty()) {
        flowManager.triggerClusterRepairFlow(stackId, autoRecoveryNodesMap, false);
        String recoveryMessage = cloudbreakMessagesService.getMessage(Msg.AMBARI_CLUSTER_AUTORECOVERY_REQUESTED.code(), Collections.singletonList(autoRecoveryNodesMap));
        updateChangedHosts(cluster, autoRecoveryHostMetadata, HostMetadataState.HEALTHY, HostMetadataState.WAITING_FOR_REPAIR, recoveryMessage);
    }
    if (!failedHostMetadata.isEmpty()) {
        String recoveryMessage = cloudbreakMessagesService.getMessage(Msg.AMBARI_CLUSTER_FAILED_NODES_REPORTED.code(), Collections.singletonList(failedHostMetadata.keySet()));
        updateChangedHosts(cluster, failedHostMetadata, HostMetadataState.HEALTHY, HostMetadataState.UNHEALTHY, recoveryMessage);
    }
}
Also used : HashMap(java.util.HashMap) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) ArrayList(java.util.ArrayList) List(java.util.List) Stack(com.sequenceiq.cloudbreak.domain.Stack) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata)

Example 20 with HostGroup

use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.

the class AmbariClusterService method repairCluster.

@Override
public void repairCluster(Long stackId, List<String> repairedHostGroups, boolean removeOnly) {
    Stack stack = stackService.get(stackId);
    Cluster cluster = stack.getCluster();
    Set<HostGroup> hostGroups = hostGroupService.getByCluster(cluster.getId());
    Map<String, List<String>> failedNodeMap = new HashMap<>();
    for (HostGroup hg : hostGroups) {
        List<String> failedNodes = new ArrayList<>();
        if (repairedHostGroups.contains(hg.getName()) && hg.getRecoveryMode() == RecoveryMode.MANUAL) {
            for (HostMetadata hmd : hg.getHostMetadata()) {
                if (hmd.getHostMetadataState() == HostMetadataState.UNHEALTHY) {
                    validateRepair(stack, hmd);
                    if (!failedNodeMap.containsKey(hg.getName())) {
                        failedNodeMap.put(hg.getName(), failedNodes);
                    }
                    failedNodes.add(hmd.getHostName());
                }
            }
        }
    }
    if (!failedNodeMap.isEmpty()) {
        flowManager.triggerClusterRepairFlow(stackId, failedNodeMap, removeOnly);
        String recoveryMessage = cloudbreakMessagesService.getMessage(Msg.AMBARI_CLUSTER_MANUALRECOVERY_REQUESTED.code(), Collections.singletonList(repairedHostGroups));
        LOGGER.info(recoveryMessage);
        eventService.fireCloudbreakEvent(stack.getId(), "RECOVERY", recoveryMessage);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) ArrayList(java.util.ArrayList) List(java.util.List) Stack(com.sequenceiq.cloudbreak.domain.Stack) HostMetadata(com.sequenceiq.cloudbreak.domain.HostMetadata)

Aggregations

HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)94 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)33 Test (org.junit.Test)33 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)31 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)29 HashSet (java.util.HashSet)22 JsonNode (com.fasterxml.jackson.databind.JsonNode)20 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)20 List (java.util.List)20 HashMap (java.util.HashMap)19 Stack (com.sequenceiq.cloudbreak.domain.Stack)18 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)16 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)15 Map (java.util.Map)14 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)13 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)12 Constraint (com.sequenceiq.cloudbreak.domain.Constraint)11 ArrayList (java.util.ArrayList)11 Set (java.util.Set)11 Inject (javax.inject.Inject)11