Search in sources :

Example 16 with Node

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

the class SshKeyService method createSshStateParams.

private OrchestratorStateParams createSshStateParams(Stack stack, String user, KeyPair keyPair, String authKeysComment, String saltState) {
    Cluster cluster = stack.getCluster();
    Set<Node> nodes = stackUtil.collectReachableNodes(stack);
    OrchestratorStateParams stateParams = new OrchestratorStateParams();
    stateParams.setState(saltState);
    stateParams.setPrimaryGatewayConfig(gatewayConfigService.getGatewayConfig(stack, stack.getPrimaryGatewayInstance(), stack.getCluster().hasGateway()));
    stateParams.setTargetHostNames(nodes.stream().map(Node::getHostname).collect(Collectors.toSet()));
    stateParams.setAllNodes(nodes);
    stateParams.setExitCriteriaModel(ClusterDeletionBasedExitCriteriaModel.clusterDeletionBasedModel(stack.getId(), cluster.getId()));
    stateParams.setStateParams(createSshParams(user, keyPair, authKeysComment));
    OrchestratorStateRetryParams retryParams = new OrchestratorStateRetryParams();
    retryParams.setMaxRetry(SSH_KEY_OPERATION_RETRY_COUNT);
    stateParams.setStateRetryParams(retryParams);
    return stateParams;
}
Also used : OrchestratorStateRetryParams(com.sequenceiq.cloudbreak.orchestrator.host.OrchestratorStateRetryParams) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) OrchestratorStateParams(com.sequenceiq.cloudbreak.orchestrator.host.OrchestratorStateParams)

Example 17 with Node

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

the class ClusterHostServiceRunnerTest method testRedeployGatewayPillarOnly.

@Test
@MockitoSettings(strictness = Strictness.LENIENT)
void testRedeployGatewayPillarOnly() throws CloudbreakOrchestratorFailedException {
    setupMocksForRunClusterServices();
    Set<Node> nodes = Sets.newHashSet(node("fqdn1"), node("fqdn2"), node("fqdn3"), node("gateway1"), node("gateway3"));
    when(stackUtil.collectNodes(any())).thenReturn(nodes);
    underTest.redeployGatewayPillarOnly(stack, cluster);
    ArgumentCaptor<SaltConfig> saltConfigCaptor = ArgumentCaptor.forClass(SaltConfig.class);
    verify(hostOrchestrator).uploadGatewayPillar(any(), allNodesCaptor.capture(), any(), saltConfigCaptor.capture());
    Set<Node> allNodes = allNodesCaptor.getValue();
    assertEquals(5, allNodes.size());
    SaltConfig saltConfig = saltConfigCaptor.getValue();
    assertTrue(saltConfig.getServicePillarConfig().keySet().stream().allMatch(Objects::nonNull));
}
Also used : Node(com.sequenceiq.cloudbreak.common.orchestration.Node) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) Test(org.junit.jupiter.api.Test) MockitoSettings(org.mockito.junit.jupiter.MockitoSettings)

Example 18 with Node

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

the class GrainPropertiesServiceTest method testAllInOne.

@Test
public void testAllInOne() {
    when(componentLocator.getComponentLocationByHostname(eq(cluster), argThat(namenodeMatcher))).thenReturn(Map.of("NAMENODE", List.of("NMHOST")));
    when(componentLocator.getComponentLocationByHostname(eq(cluster), argThat(knoxGatewayMatcher))).thenReturn(Map.of("KNOX_GATEWAY", List.of("KWGHOST")));
    GatewayConfig gwconfig = mock(GatewayConfig.class);
    when(gwconfig.getPublicAddress()).thenReturn("GWPUBADDR");
    when(gwconfig.getHostname()).thenReturn("GWHOSTNAME");
    Node node1 = new Node("", "", "", "", "node1fqdn", "");
    InstanceMetaData im1 = new InstanceMetaData();
    im1.setDiscoveryFQDN(node1.getHostname());
    InstanceGroup logIg = new InstanceGroup();
    logIg.setAttributes(new Json("{}"));
    logIg.setCloudIdentityType(CloudIdentityType.LOG);
    im1.setInstanceGroup(logIg);
    when(instanceMetaDataService.getAllInstanceMetadataByStackId(1L)).thenReturn(Set.of(im1));
    List<GrainProperties> result = underTest.createGrainProperties(List.of(gwconfig), cluster, Set.of(node1));
    assertThat(result, hasItem(allOf(hasProperty("properties", allOf(hasEntry("GWHOSTNAME", Map.of("gateway-address", "GWPUBADDR")))))));
    assertThat(result, hasItem(allOf(hasProperty("properties", allOf(hasEntry("NMHOST", Map.of("roles", "namenode")))))));
    assertThat(result, hasItem(allOf(hasProperty("properties", allOf(hasEntry("KWGHOST", Map.of("roles", "knox")))))));
    assertThat(result, hasItem(allOf(hasProperty("properties", allOf(hasEntry("node1fqdn", Map.of("roles", "LOG_CLOUD_IDENTITY_ROLE")))))));
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) GrainProperties(com.sequenceiq.cloudbreak.orchestrator.model.GrainProperties) Json(com.sequenceiq.cloudbreak.common.json.Json) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Test(org.junit.jupiter.api.Test)

Example 19 with Node

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

the class StackUtilTest method testCollectGatewayNodes.

@Test
void testCollectGatewayNodes() {
    Stack stack = createStack();
    Set<Node> result = stackUtil.collectGatewayNodes(stack);
    assertThat(result).hasSize(1);
    Node node = result.stream().findFirst().get();
    assertThat(node.getHostname()).isEqualTo("node3.example.com");
}
Also used : Node(com.sequenceiq.cloudbreak.common.orchestration.Node) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 20 with Node

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

the class MountDisksTest method mountDisksOnNewNodesShouldUseReachableNodes.

@Test
public void mountDisksOnNewNodesShouldUseReachableNodes() throws CloudbreakException, CloudbreakOrchestratorFailedException {
    Set<String> newNodeAddresses = Set.of("node-1");
    when(stackService.getByIdWithListsInTransaction(1L)).thenReturn(stack);
    when(stack.getPlatformVariant()).thenReturn(CloudConstants.MOCK);
    when(stack.getCluster()).thenReturn(new Cluster());
    CloudbreakDetails cloudbreakDetails = new CloudbreakDetails();
    cloudbreakDetails.setVersion("2.34.0");
    when(componentConfigProviderService.getCloudbreakDetails(any())).thenReturn(cloudbreakDetails);
    Node node1 = new Node("1.1.1.1", "1.1.1.1", "id1", "m5.xlarge", "node-1", "worker");
    Node node2 = new Node("1.1.1.2", "1.1.1.2", "id2", "m5.xlarge", "node-2", "worker");
    Set<Node> reachableNodes = new HashSet<>();
    reachableNodes.add(node1);
    reachableNodes.add(node2);
    Set<Node> newNodesWithDiskData = new HashSet<>();
    newNodesWithDiskData.add(node1);
    when(stackUtil.collectNewNodesWithDiskData(stack, newNodeAddresses)).thenReturn(newNodesWithDiskData);
    underTest.mountDisksOnNewNodes(1L, newNodeAddresses, reachableNodes);
    verify(stackUtil).collectNewNodesWithDiskData(stack, newNodeAddresses);
    verify(hostOrchestrator).formatAndMountDisksOnNodes(any(), any(), targetsCaptor.capture(), allNodesCaptor.capture(), any(), eq(CloudConstants.MOCK));
    Set<Node> capturedTargets = targetsCaptor.getValue();
    Set<Node> capturedAllNode = allNodesCaptor.getValue();
    assertTrue(capturedTargets.contains(node1));
    assertFalse(capturedTargets.contains(node2));
    assertTrue(capturedAllNode.contains(node1));
    assertTrue(capturedAllNode.contains(node2));
}
Also used : CloudbreakDetails(com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) HashSet(java.util.HashSet) Test(org.junit.Test)

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