/** * 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(); }
/** * 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(); }