/** * 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<String>(); 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(); }
/** * Set the configuration and extract the configuration parameters of interest * @param conf the new configuration */ @Override public void setConf (Configuration conf) { super.setConf(conf); if (conf != null) { scriptName = conf.get(SCRIPT_FILENAME_KEY); maxArgs = conf.getInt(SCRIPT_ARG_COUNT_KEY, DEFAULT_ARG_COUNT); } else { scriptName = null; maxArgs = 0; } }
/** * Query for a {@link DNSToSwitchMapping} instance being on a single * switch. * <p/> * This predicate simply assumes that all mappings not derived from * this class are multi-switch. * @param mapping the mapping to query * @return true if the base class says it is single switch, or the mapping * is not derived from this class. */ public static boolean isMappingSingleSwitch(DNSToSwitchMapping mapping) { return mapping != null && mapping instanceof AbstractDNSToSwitchMapping && ((AbstractDNSToSwitchMapping) mapping).isSingleSwitch(); }
protected void assertMapSize(AbstractDNSToSwitchMapping switchMapping, int expectedSize) { assertEquals( "Expected two entries in the map " + switchMapping.dumpTopology(), expectedSize, switchMapping.getSwitchMap().size()); }
private void assertMultiSwitch(DNSToSwitchMapping mapping) { assertEquals("Expected a multi switch mapping " + mapping, false, AbstractDNSToSwitchMapping.isMappingSingleSwitch(mapping)); }
protected void assertMapSize(AbstractDNSToSwitchMapping switchMapping, int expectedSize) { assertEquals( "Expected two entries in the map " + switchMapping.dumpTopology(), expectedSize, switchMapping.getSwitchMap().size()); }
private void assertMultiSwitch(DNSToSwitchMapping mapping) { assertEquals("Expected a multi switch mapping " + mapping, false, AbstractDNSToSwitchMapping.isMappingSingleSwitch(mapping)); }
/** * Set the configuration and extract the configuration parameters of interest * @param conf the new configuration */ @Override public void setConf (Configuration conf) { super.setConf(conf); if (conf != null) { scriptName = conf.get(SCRIPT_FILENAME_KEY); maxArgs = conf.getInt(SCRIPT_ARG_COUNT_KEY, DEFAULT_ARG_COUNT); } else { scriptName = null; maxArgs = 0; } }
/** * 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<String>(); 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(); }
/** * Query for a {@link DNSToSwitchMapping} instance being on a single * switch. * <p/> * This predicate simply assumes that all mappings not derived from * this class are multi-switch. * @param mapping the mapping to query * @return true if the base class says it is single switch, or the mapping * is not derived from this class. */ public static boolean isMappingSingleSwitch(DNSToSwitchMapping mapping) { return mapping != null && mapping instanceof AbstractDNSToSwitchMapping && ((AbstractDNSToSwitchMapping) mapping).isSingleSwitch(); }
private void assertSingleSwitch(DNSToSwitchMapping mapping) { assertEquals("Expected a single switch mapping " + mapping, true, AbstractDNSToSwitchMapping.isMappingSingleSwitch(mapping)); }
/** * Set the configuration and extract the configuration parameters of interest * @param conf the new configuration */ @Override public void setConf (Configuration conf) { super.setConf(conf); if (conf != null) { scriptName = conf.get(SCRIPT_FILENAME_KEY); maxArgs = conf.getInt(SCRIPT_ARG_COUNT_KEY, DEFAULT_ARG_COUNT); } else { scriptName = null; maxArgs = 0; } }
/** * 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<String>(); 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(); }
/** * Query for a {@link DNSToSwitchMapping} instance being on a single * switch. * <p/> * This predicate simply assumes that all mappings not derived from * this class are multi-switch. * @param mapping the mapping to query * @return true if the base class says it is single switch, or the mapping * is not derived from this class. */ public static boolean isMappingSingleSwitch(DNSToSwitchMapping mapping) { return mapping != null && mapping instanceof AbstractDNSToSwitchMapping && ((AbstractDNSToSwitchMapping) mapping).isSingleSwitch(); }
private void assertSingleSwitch(DNSToSwitchMapping mapping) { assertEquals("Expected a single switch mapping " + mapping, true, AbstractDNSToSwitchMapping.isMappingSingleSwitch(mapping)); }
/** * Set the configuration and extract the configuration parameters of interest * @param conf the new configuration */ @Override public void setConf (Configuration conf) { super.setConf(conf); if (conf != null) { scriptName = conf.get(SCRIPT_FILENAME_KEY); maxArgs = conf.getInt(SCRIPT_ARG_COUNT_KEY, DEFAULT_ARG_COUNT); } else { scriptName = null; maxArgs = 0; } }
/** * 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<String>(); 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(); }
/** * Query for a {@link DNSToSwitchMapping} instance being on a single * switch. * <p/> * This predicate simply assumes that all mappings not derived from * this class are multi-switch. * @param mapping the mapping to query * @return true if the base class says it is single switch, or the mapping * is not derived from this class. */ public static boolean isMappingSingleSwitch(DNSToSwitchMapping mapping) { return mapping != null && mapping instanceof AbstractDNSToSwitchMapping && ((AbstractDNSToSwitchMapping) mapping).isSingleSwitch(); }
@Test public void testNullMapping() { assertFalse(AbstractDNSToSwitchMapping.isMappingSingleSwitch(null)); }
/** * Set the configuration and extract the configuration parameters of interest * @param conf the new configuration */ @Override public void setConf (Configuration conf) { super.setConf(conf); if (conf != null) { scriptName = conf.get(SCRIPT_FILENAME_KEY); maxArgs = conf.getInt(SCRIPT_ARG_COUNT_KEY, DEFAULT_ARG_COUNT); } else { scriptName = null; maxArgs = 0; } }