@Override public String toString() { return "DefaultRackDNSToSwitchMapping (" + mappingCache.size() + " mappings cached)" + dumpTopology(); } }
private Map<String, String> getHostToRackMapping(Map<Integer, NodeInfo> taskToNodePort) { Set<String> hosts = new HashSet(); for (int task : targetTasks) { //if this task containing worker will be killed by a assignments sync, //taskToNodePort will be an empty map which is refreshed by WorkerState if (taskToNodePort.containsKey(task)) { hosts.add(taskToNodePort.get(task).get_node()); } else { LOG.error("Could not find task NodeInfo from local cache."); } } hosts.add(sourceNodeInfo.get_node()); return dnsToSwitchMapping.resolve(new ArrayList<>(hosts)); }
/** * Generate a string listing the switch mapping implementation, the mapping for every known node and the number of nodes and unique * switches known about -each entry to a separate line. * * @return a string that can be presented to the ops team or used in debug messages. */ public String dumpTopology() { Map<String, String> rack = getSwitchMap(); StringBuilder builder = new StringBuilder(); builder.append("Mapping: ").append(toString()).append("\n"); if (rack != null) { builder.append("Map:\n"); Set<String> switches = new HashSet<>(); for (Map.Entry<String, String> entry : rack.entrySet()) { builder.append(" ") .append(entry.getKey()) .append(" -> ") .append(entry.getValue()) .append("\n"); switches.add(entry.getValue()); } builder.append("Nodes: ").append(rack.size()).append("\n"); builder.append("Switches: ").append(switches.size()).append("\n"); } else { builder.append("No topology information"); } return builder.toString(); }
Map<String, String> resolvedSuperVisors = topographyMapper.resolve(supervisorHostNames); for (Map.Entry<String, String> entry : resolvedSuperVisors.entrySet()) { String hostName = entry.getKey();
@Override public String toString() { return "DefaultRackDNSToSwitchMapping (" + mappingCache.size() + " mappings cached)" + dumpTopology(); } }
/** * Generate a string listing the switch mapping implementation, * the mapping for every known node and the number of nodes and * unique switches known about -each entry to a separate line. * * @return a string that can be presented to the ops team or used in * debug messages. */ public String dumpTopology() { Map<String, String> rack = getSwitchMap(); StringBuilder builder = new StringBuilder(); builder.append("Mapping: ").append(toString()).append("\n"); if (rack != null) { builder.append("Map:\n"); Set<String> switches = new HashSet<>(); for (Map.Entry<String, String> entry : rack.entrySet()) { builder.append(" ") .append(entry.getKey()) .append(" -> ") .append(entry.getValue()) .append("\n"); switches.add(entry.getValue()); } builder.append("Nodes: ").append(rack.size()).append("\n"); builder.append("Switches: ").append(switches.size()).append("\n"); } else { builder.append("No topology information"); } return builder.toString(); }
Map<String, String> resolvedSuperVisors = TestNetworkTopographyPlugin.resolve(supHostnames); for (Map.Entry<String, String> entry : resolvedSuperVisors.entrySet()) { String hostName = entry.getKey();
Map<String, String> resolvedSuperVisors = TestNetworkTopographyPlugin.resolve(supHostnames); for (Map.Entry<String, String> entry : resolvedSuperVisors.entrySet()) { String hostName = entry.getKey();
public Map<String, List<String>> getNetworkTopography() { if (networkTopography == null) { networkTopography = new HashMap<String, List<String>>(); ArrayList<String> supervisorHostNames = new ArrayList<String>(); for (SupervisorDetails s : supervisors.values()) { supervisorHostNames.add(s.getHost()); } String clazz = (String) conf.get(Config.STORM_NETWORK_TOPOGRAPHY_PLUGIN); DNSToSwitchMapping topographyMapper = (DNSToSwitchMapping) Utils.newInstance(clazz); Map<String, String> resolvedSuperVisors = topographyMapper.resolve(supervisorHostNames); for (Map.Entry<String, String> entry : resolvedSuperVisors.entrySet()) { String hostName = entry.getKey(); String rack = entry.getValue(); List<String> nodesForRack = networkTopography.get(rack); if (nodesForRack == null) { nodesForRack = new ArrayList<String>(); networkTopography.put(rack, nodesForRack); } nodesForRack.add(hostName); } } return networkTopography; }