private NavigableSet<NodeRank> getNodeRanks() { NavigableSet<NodeRank> nodes = new TreeSet<>(); graph.keySet().forEach(node -> { int numConnected = graph.get(node).getConnected(); nodes.add(new NodeRank(node, numConnected)); }); return nodes; }
/** * See if the node is fully connected. * * @param endpoint local node name * @param unresponsiveNodes list of unresponsive nodes in the layout * @return local node rank */ public Optional<NodeRank> findFullyConnectedNode(String endpoint, List<String> unresponsiveNodes) { log.trace("Find responsive node. Unresponsive nodes: {}", unresponsiveNodes); NodeConnectivity node = getNodeConnectivity(endpoint); for (String adjacent : node.getConnectivity().keySet()) { //if adjacent node is unresponsive then then exclude it from fully connected graph if (unresponsiveNodes.contains(adjacent)) { continue; } NodeConnectivity adjacentNode = getNodeConnectivity(adjacent); //if adjacent node is unavailable then exclude it from fully connected graph if (adjacentNode.getType() == NodeConnectivityType.UNAVAILABLE) { continue; } if (adjacentNode.getConnectionStatus(endpoint) != ConnectionStatus.OK) { log.trace("Fully connected node not found"); return Optional.empty(); } } return Optional.of(new NodeRank(endpoint, getNodeConnectivity(endpoint).getConnected())); }