/** * Get the rack on which a node is a part of. * * @param node the node to find out which rack its on * @return the rack id */ protected String nodeToRack(RAS_Node node) { return superIdToRack.get(node.getId()); }
protected List<String> makeHostToNodeIds(List<String> hosts) { if (hosts == null) { return Collections.emptyList(); } List<String> ret = new ArrayList<>(hosts.size()); for (String host: hosts) { List<RAS_Node> nodes = hostnameToNodes.get(host); if (nodes != null) { for (RAS_Node node : nodes) { ret.add(node.getId()); } } } return ret; }
LOG.trace("{} Found spread violation {} on node {}", exec, execComp, node.getId()); return false;
@VisibleForTesting void prepare(Cluster cluster) { this.cluster = cluster; nodes = new RAS_Nodes(cluster); networkTopography = cluster.getNetworkTopography(); Map<String, String> hostToRack = new HashMap<>(); for (Map.Entry<String, List<String>> entry : networkTopography.entrySet()) { String rackId = entry.getKey(); for (String hostName: entry.getValue()) { hostToRack.put(hostName, rackId); } } for (RAS_Node node: nodes.getNodes()) { String superId = node.getId(); String hostName = node.getHostname(); String rackId = hostToRack.getOrDefault(hostName, DNSToSwitchMapping.DEFAULT_RACK); superIdToHostname.put(superId, hostName); superIdToRack.put(superId, rackId); hostnameToNodes.computeIfAbsent(hostName, (hn) -> new ArrayList<>()).add(node); rackIdToNodes.computeIfAbsent(rackId, (hn) -> new ArrayList<>()).add(node); } logClusterInfo(); }
if (nodeCompMap.computeIfAbsent(node, (k) -> new HashSet<>()).contains(comp)) { LOG.error("Incorrect Scheduling: Spread for Component: {} {} on node {} not satisfied {}", comp, exec, node.getId(), nodeCompMap.get(node)); ret = false;
/** * Log a bunch of stuff for debugging. */ private void logClusterInfo() { if (LOG.isDebugEnabled()) { LOG.debug("Cluster:"); for (Map.Entry<String, List<String>> clusterEntry : networkTopography.entrySet()) { String rackId = clusterEntry.getKey(); LOG.debug("Rack: {}", rackId); for (String nodeHostname : clusterEntry.getValue()) { for (RAS_Node node : hostnameToNodes(nodeHostname)) { LOG.debug("-> Node: {} {}", node.getHostname(), node.getId()); LOG.debug( "--> Avail Resources: {Mem {}, CPU {} Slots: {}}", node.getAvailableMemoryResources(), node.getAvailableCpuResources(), node.totalSlotsFree()); LOG.debug( "--> Total Resources: {Mem {}, CPU {} Slots: {}}", node.getTotalMemoryResources(), node.getTotalCpuResources(), node.totalSlots()); } } } } }
String superId = rasNode.getId(); ObjectResources node = new ObjectResources(superId);
LOG.error("Incorrect Scheduling: node {} has consumed incorrect amount of cpu. Expected: {}" + " Actual: {} Executors scheduled on node: {}", node.getId(), (node.getTotalCpuResources() - cpuUsed), node.getAvailableCpuResources(), execs); return false; LOG.error("Incorrect Scheduling: node {} has consumed incorrect amount of memory. Expected: {}" + " Actual: {} Executors scheduled on node: {}", node.getId(), (node.getTotalMemoryResources() - memoryUsed), node.getAvailableMemoryResources(), execs); return false;
RAS_Node node = nodes.get("r000s000"); assertEquals("r000s000", node.getId()); assertTrue(node.isAlive()); assertEquals(0, node.getRunningTopologies().size());
/** * hostname to Id * * @param hostname the hostname to convert to node id * @return the id of a node */ public String NodeHostnameToId(String hostname) { for (RAS_Node n : _nodes.getNodes()) { if (n.getHostname() == null) { continue; } if (n.getHostname().equals(hostname)) { return n.getId(); } } LOG.error("Cannot find Node with hostname {}", hostname); return null; }
/** * Get the amount of resources available and total for each node * * @return a String with cluster resource info for debug */ private String getClusterInfo() { String retVal = "Cluster info:\n"; for (Map.Entry<String, List<String>> clusterEntry : _clusterInfo.entrySet()) { String clusterId = clusterEntry.getKey(); retVal += "Rack: " + clusterId + "\n"; for (String nodeHostname : clusterEntry.getValue()) { RAS_Node node = this.idToNode(this.NodeHostnameToId(nodeHostname)); retVal += "-> Node: " + node.getHostname() + " " + node.getId() + "\n"; retVal += "--> Avail Resources: {Mem " + node.getAvailableMemoryResources() + ", CPU " + node.getAvailableCpuResources() + " Slots: " + node.totalSlotsFree() + "}\n"; retVal += "--> Total Resources: {Mem " + node.getTotalMemoryResources() + ", CPU " + node.getTotalCpuResources() + " Slots: " + node.totalSlots() + "}\n"; } } return retVal; }
String nodeId = ras_node.getId(); ObjectResources node = new ObjectResources(nodeId);