@Test public void testExtractHsrp() { Table<Ip, Integer, Set<Interface>> groups = HashBasedTable.create(); Interface i = Interface.builder().setName("name").build(); extractHsrp(groups, i); assertTrue(groups.isEmpty()); Ip ip = Ip.parse("1.1.1.1"); i.setHsrpGroups(ImmutableMap.of(1, HsrpGroup.builder().setIp(ip).setGroupNumber(1).build())); extractHsrp(groups, i); assertThat(groups.get(ip, 1), equalTo(ImmutableSet.of(i))); }
@VisibleForTesting static void extractHsrp(Table<Ip, Integer, Set<Interface>> hsrpGroups, Interface i) { i.getHsrpGroups() .values() .forEach( g -> { Ip ip = g.getIp(); int groupNum = g.getGroupNumber(); if (ip == null) { return; } Set<Interface> candidates = hsrpGroups.get(ip, groupNum); if (candidates == null) { candidates = Collections.newSetFromMap(new IdentityHashMap<>()); hsrpGroups.put(ip, groupNum, candidates); } candidates.add(i); }); }
IpOwners { @VisibleForTesting static void extractHsrp(Table<Ip, Integer, Set<Interface>> hsrpGroups, Interface i) { i.getHsrpGroups() .values() .forEach( g -> { Ip ip = g.getIp(); int groupNum = g.getGroupNumber(); if (ip == null) { return; } Set<Interface> candidates = hsrpGroups.get(ip, groupNum); if (candidates == null) { candidates = Collections.newSetFromMap(new IdentityHashMap<>()); hsrpGroups.put(ip, groupNum, candidates); } candidates.add(i); }); } }
IpOwners { @VisibleForTesting static void extractHsrp(Table<Ip, Integer, Set<Interface>> hsrpGroups, Interface i) { i.getHsrpGroups() .values() .forEach( g -> { Ip ip = g.getIp(); int groupNum = g.getGroupNumber(); if (ip == null) { return; } Set<Interface> candidates = hsrpGroups.get(ip, groupNum); if (candidates == null) { candidates = Collections.newSetFromMap(new IdentityHashMap<>()); hsrpGroups.put(ip, groupNum, candidates); } candidates.add(i); }); } IpOwners(Map<String, Configuration> configurations); }
IpOwners { @VisibleForTesting static void extractHsrp(Table<Ip, Integer, Set<Interface>> hsrpGroups, Interface i) { i.getHsrpGroups() .values() .forEach( g -> { Ip ip = g.getIp(); int groupNum = g.getGroupNumber(); if (ip == null) { return; } Set<Interface> candidates = hsrpGroups.get(ip, groupNum); if (candidates == null) { candidates = Collections.newSetFromMap(new IdentityHashMap<>()); hsrpGroups.put(ip, groupNum, candidates); } candidates.add(i); }); } IpOwners(Map<String, Configuration> configurations); static Map<String, Map<String, Set<Ip>>> computeInterfaceOwnedIps(
      Map<String, Configuration> configurations, boolean excludeInactive); static Map<Ip, Set<String>> computeIpNodeOwners(
      Map<String, Configuration> configurations, boolean excludeInactive); Map<Ip, Map<String, Set<String>>> getActiveDeviceOwnedIps(); Map<Ip, Map<String, Set<String>>> getAllDeviceOwnedIps(); Map<String, Map<String, IpSpace>> getAllInterfaceHostIps(); Map<String, Map<String, IpSpace>> getInterfaceOwnedIpSpaces(); Map<Ip, Map<String, Set<String>>> getIpVrfOwners(); Map<String, Map<String, Map<String, IpSpace>>> getVrfIfaceOwnedIpSpaces(); }
IpOwners { @VisibleForTesting static void extractHsrp(Table<Ip, Integer, Set<Interface>> hsrpGroups, Interface i) { i.getHsrpGroups() .values() .forEach( g -> { Ip ip = g.getIp(); int groupNum = g.getGroupNumber(); if (ip == null) { return; } Set<Interface> candidates = hsrpGroups.get(ip, groupNum); if (candidates == null) { candidates = Collections.newSetFromMap(new IdentityHashMap<>()); hsrpGroups.put(ip, groupNum, candidates); } candidates.add(i); }); } IpOwners(Map<String, Configuration> configurations); static Map<String, Map<String, Set<Ip>>> computeInterfaceOwnedIps(
      Map<String, Configuration> configurations, boolean excludeInactive); static Map<Ip, Set<String>> computeIpNodeOwners(
      Map<String, Configuration> configurations, boolean excludeInactive); Map<Ip, Map<String, Set<String>>> getActiveDeviceOwnedIps(); Map<Ip, Map<String, Set<String>>> getAllDeviceOwnedIps(); Map<String, Map<String, IpSpace>> getAllInterfaceHostIps(); Map<String, Map<String, IpSpace>> getInterfaceOwnedIpSpaces(); Map<Ip, Map<String, Set<String>>> getIpVrfOwners(); Map<String, Map<String, Map<String, IpSpace>>> getVrfIfaceOwnedIpSpaces();  }