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;
}
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));
}
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")))))));
}
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");
}
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));
}
Aggregations