private Double distToNode(RAS_Node src, RAS_Node dest) { if (src.getId().equals(dest.getId()) == true) { return 1.0; } else if (this.NodeToCluster(src) == this.NodeToCluster(dest)) { return 2.0; } else { return 3.0; } }
/** * hostname to Id * * @param hostname * @return the id of a node */ public String NodeHostnameToId(String hostname) { for (RAS_Node n : _nodes.values()) { 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 (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() + "}\n"; retVal += "--> Total Resources: {Mem " + node.getTotalMemoryResources() + ", CPU " + node.getTotalCpuResources() + "}\n"; } } return retVal; }