use of com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult in project cloudbreak by hortonworks.
the class StackUtilTest method collectAndCheckReachableNodes.
@Test
void collectAndCheckReachableNodes() throws NodesUnreachableException {
Stack stack = createStack();
ArrayList<String> necessaryNodes = new ArrayList<>();
necessaryNodes.add("node1.example.com");
necessaryNodes.add("node3.example.com");
Set<Node> nodes = new HashSet<>();
nodes.add(new Node("1.1.1.1", "1.1.1.1", "1", "m5.xlarge", "node1.example.com", "worker"));
nodes.add(new Node("1.1.1.3", "1.1.1.3", "3", "m5.xlarge", "node3.example.com", "worker"));
when(hostOrchestrator.getResponsiveNodes(nodesCaptor.capture(), any())).thenReturn(new NodeReachabilityResult(nodes, Set.of()));
stackUtil.collectAndCheckReachableNodes(stack, necessaryNodes);
verify(hostOrchestrator).getResponsiveNodes(nodesCaptor.capture(), any());
List<String> fqdns = nodesCaptor.getValue().stream().map(Node::getHostname).collect(Collectors.toList());
assertTrue(fqdns.contains("node1.example.com"));
assertFalse("Terminated node should be filtered out", fqdns.contains("node2.example.com"));
assertTrue(fqdns.contains("node3.example.com"));
}
use of com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult 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.");
}
}
use of com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method runClusterServices.
public NodeReachabilityResult runClusterServices(@Nonnull Stack stack, @Nonnull Cluster cluster, Map<String, String> candidateAddresses) {
try {
Set<Node> allNodes = stackUtil.collectNodes(stack);
Set<Node> reachableNodes = stackUtil.collectAndCheckReachableNodes(stack, candidateAddresses.keySet());
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
List<GrainProperties> grainsProperties = grainPropertiesService.createGrainProperties(gatewayConfigs, cluster, reachableNodes);
executeRunClusterServices(stack, cluster, candidateAddresses, allNodes, reachableNodes, gatewayConfigs, grainsProperties);
return new NodeReachabilityResult(reachableNodes, Set.of());
} catch (CloudbreakOrchestratorCancelledException e) {
throw new CancellationException(e.getMessage());
} catch (CloudbreakOrchestratorException | IOException | CloudbreakException e) {
throw new CloudbreakServiceException(e.getMessage(), e);
} catch (NodesUnreachableException e) {
String errorMessage = "Can not run cluster services on new nodes because the configuration management service is not responding on these nodes: " + e.getUnreachableNodes();
LOGGER.error(errorMessage);
throw new CloudbreakServiceException(errorMessage, e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method runTargetedClusterServices.
public NodeReachabilityResult runTargetedClusterServices(@Nonnull Stack stack, @Nonnull Cluster cluster, Map<String, String> candidateAddresses) {
try {
NodeReachabilityResult nodeReachabilityResult = stackUtil.collectReachableAndUnreachableCandidateNodes(stack, candidateAddresses.keySet());
addGatewaysToCandidatesIfNeeded(stack.getNotTerminatedAndNotZombieGatewayInstanceMetadata(), nodeReachabilityResult);
Set<Node> reachableCandidates = nodeReachabilityResult.getReachableNodes();
List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
List<GrainProperties> grainsProperties = grainPropertiesService.createGrainPropertiesForTargetedUpscale(gatewayConfigs, cluster, reachableCandidates);
Set<String> reachableCandidateHostNames = nodeReachabilityResult.getReachableHosts();
LOGGER.debug("We are about to execute cluster services (salt highstate, pre cluster manager recipe execution, mount disks, etc.) " + "for reachable candidates (targeted operation): {}", Joiner.on(",").join(reachableCandidateHostNames));
executeRunClusterServices(stack, cluster, candidateAddresses, reachableCandidates, reachableCandidates, gatewayConfigs, grainsProperties);
return nodeReachabilityResult;
} catch (CloudbreakOrchestratorCancelledException e) {
throw new CancellationException(e.getMessage());
} catch (CloudbreakOrchestratorException | IOException | CloudbreakException e) {
throw new CloudbreakServiceException(e.getMessage(), e);
}
}
Aggregations