Search in sources :

Example 61 with Node

use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.

the class StackUtil method collectNodes.

public Set<Node> collectNodes(Stack stack) {
    Set<Node> agents = new HashSet<>();
    for (InstanceGroup instanceGroup : stack.getInstanceGroups()) {
        if (instanceGroup.getNodeCount() != 0) {
            for (InstanceMetaData im : instanceGroup.getNotDeletedInstanceMetaDataSet()) {
                if (im.getDiscoveryFQDN() != null) {
                    String instanceId = im.getInstanceId();
                    String instanceType = instanceGroup.getTemplate().getInstanceType();
                    agents.add(new Node(im.getPrivateIp(), im.getPublicIp(), instanceId, instanceType, im.getDiscoveryFQDN(), im.getInstanceGroupName()));
                }
            }
        }
    }
    return agents;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) HashSet(java.util.HashSet) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 62 with Node

use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.

the class StackUtil method collectReachableAndUnreachableCandidateNodes.

public NodeReachabilityResult collectReachableAndUnreachableCandidateNodes(Stack stack, Collection<String> necessaryNodes) {
    NodeReachabilityResult nodeReachabilityResult = collectReachableAndUnreachableNodes(stack);
    Set<Node> reachableCandidateNodes = nodeReachabilityResult.getReachableNodes().stream().filter(node -> necessaryNodes.contains(node.getHostname())).collect(Collectors.toSet());
    Set<Node> unreachableCandidateNodes = nodeReachabilityResult.getUnreachableNodes().stream().filter(node -> necessaryNodes.contains(node.getHostname())).collect(Collectors.toSet());
    NodeReachabilityResult nodeReachabilityResultWithCandidates = new NodeReachabilityResult(reachableCandidateNodes, unreachableCandidateNodes);
    if (!unreachableCandidateNodes.isEmpty()) {
        LOGGER.warn("Some candidate nodes are unreachable: {}", nodeReachabilityResultWithCandidates.getUnreachableHosts());
    }
    LOGGER.debug("Candidate node reachability result: {}", nodeReachabilityResultWithCandidates);
    return nodeReachabilityResultWithCandidates;
}
Also used : IntStream(java.util.stream.IntStream) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) LoadBalancerConfigService(com.sequenceiq.cloudbreak.service.LoadBalancerConfigService) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) Resource(com.sequenceiq.cloudbreak.domain.Resource) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) AtomicReference(java.util.concurrent.atomic.AtomicReference) StringUtils(org.apache.commons.lang3.StringUtils) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) StringUtils.isNotEmpty(org.apache.commons.lang3.StringUtils.isNotEmpty) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Service(org.springframework.stereotype.Service) Duration(java.time.Duration) Map(java.util.Map) InstanceMetaDataService(com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService) CredentialClientService(com.sequenceiq.cloudbreak.service.environment.credential.CredentialClientService) CredentialToCloudCredentialConverter(com.sequenceiq.cloudbreak.converter.spi.CredentialToCloudCredentialConverter) StringUtils.isEmpty(org.apache.commons.lang3.StringUtils.isEmpty) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) AbstractImmutableEntry(com.gs.collections.impl.tuple.AbstractImmutableEntry) ImmutableEntry(com.gs.collections.impl.tuple.ImmutableEntry) CloudVolumeUsageType(com.sequenceiq.cloudbreak.cloud.model.CloudVolumeUsageType) Logger(org.slf4j.Logger) NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult) ResourceAttributeUtil(com.sequenceiq.cloudbreak.cluster.util.ResourceAttributeUtil) Collection(java.util.Collection) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) Set(java.util.Set) Crn(com.sequenceiq.cloudbreak.auth.crn.Crn) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) VolumeSetAttributes(com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes) Collectors(java.util.stream.Collectors) TemporaryStorage(com.sequenceiq.cloudbreak.common.type.TemporaryStorage) Credential(com.sequenceiq.cloudbreak.dto.credential.Credential) GatewayConfigService(com.sequenceiq.cloudbreak.service.GatewayConfigService) List(java.util.List) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Optional(java.util.Optional) VisibleForTesting(com.google.common.annotations.VisibleForTesting) NodeVolumes(com.sequenceiq.cloudbreak.common.orchestration.NodeVolumes) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Volume(com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes.Volume) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult)

Example 63 with Node

use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.

the class OrchestratorRecipeExecutorTest method preClusterManagerStartRecipesShouldUseReachableNodes.

@Test
public void preClusterManagerStartRecipesShouldUseReachableNodes() throws CloudbreakException, CloudbreakOrchestratorFailedException, CloudbreakOrchestratorTimeoutException {
    when(stack.getId()).thenReturn(1L);
    Cluster cluster = new Cluster();
    cluster.setId(2L);
    when(stack.getCluster()).thenReturn(cluster);
    when(gatewayConfigService.getPrimaryGatewayConfig(any())).thenReturn(gatewayConfig);
    Set<Node> nodes = Set.of(node);
    when(stackUtil.collectReachableNodes(any())).thenReturn(nodes);
    underTest.preClusterManagerStartRecipes(stack);
    verify(gatewayConfigService).getPrimaryGatewayConfig(stack);
    verify(stackUtil).collectReachableNodes(stack);
    verify(hostOrchestrator).preClusterManagerStartRecipes(eq(gatewayConfig), eq(nodes), any());
}
Also used : Node(com.sequenceiq.cloudbreak.common.orchestration.Node) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Test(org.junit.Test)

Example 64 with Node

use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.

the class MountDisks method mountDisksOnNewNodes.

public void mountDisksOnNewNodes(Long stackId, Set<String> upscaleCandidateAddresses, Set<Node> allNodes) throws CloudbreakException {
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    stack.setResources(new HashSet<>(resourceService.getAllByStackId(stackId)));
    if (!StackService.REATTACH_COMPATIBLE_PLATFORMS.contains(stack.getPlatformVariant())) {
        return;
    }
    Set<Node> nodesWithDiskData = stackUtil.collectNewNodesWithDiskData(stack, upscaleCandidateAddresses);
    mountDisks(stack, nodesWithDiskData, allNodes);
}
Also used : Node(com.sequenceiq.cloudbreak.common.orchestration.Node) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 65 with Node

use of com.sequenceiq.cloudbreak.common.orchestration.Node in project cloudbreak by hortonworks.

the class MountDisks method mountAllDisks.

public void mountAllDisks(Long stackId) throws CloudbreakException {
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    stack.setResources(new HashSet<>(resourceService.getAllByStackId(stackId)));
    if (!StackService.REATTACH_COMPATIBLE_PLATFORMS.contains(stack.getPlatformVariant())) {
        return;
    }
    Set<Node> allNodes = stackUtil.collectNodes(stack);
    Set<Node> nodesWithDiskData = stackUtil.collectNodesWithDiskData(stack);
    mountDisks(stack, nodesWithDiskData, allNodes);
}
Also used : Node(com.sequenceiq.cloudbreak.common.orchestration.Node) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

Node (com.sequenceiq.cloudbreak.common.orchestration.Node)126 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)57 HashSet (java.util.HashSet)42 Map (java.util.Map)32 JsonNode (com.fasterxml.jackson.databind.JsonNode)30 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)29 Test (org.junit.Test)29 HashMap (java.util.HashMap)28 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)27 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)26 ArrayList (java.util.ArrayList)26 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)25 ExitCriteriaModel (com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel)25 Set (java.util.Set)25 Test (org.junit.jupiter.api.Test)25 List (java.util.List)22 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)21 IOException (java.io.IOException)21 Collectors (java.util.stream.Collectors)21 BootstrapParams (com.sequenceiq.cloudbreak.orchestrator.model.BootstrapParams)19