@Test public void testSelectionDisjointNetworkC1() { List<NetworkInformation> collection = new ArrayList<>(); for (int i = 1; i < 128; i++) { NetworkInformation information = new NetworkInformation(); if (i < 20) information.addIpAddress("172.12.0." + i); information.addIpAddress(getRandomIp()); collection.add(information); } NetworkOrganizer discoverer = new NetworkOrganizer(collection, "172.12.0.0/24"); List<String> shards = discoverer.getSubset(10); assertEquals(10, shards.size()); List<String> backup = discoverer.getSubset(10, shards); assertEquals(9, backup.size()); for (String ip : backup) { assertNotEquals(null, ip); assertTrue(ip.startsWith("172.12.0")); assertFalse(shards.contains(ip)); } }
public List<String> getSubset(int numShards) { return getSubset(numShards, null); }
NetworkOrganizer { public List<String> getSubset(int numShards) { return getSubset(numShards, null); } }
NetworkOrganizer { public List<String> getSubset(int numShards) { return getSubset(numShards, null); } protected  NetworkOrganizer(@NonNull Collection<NetworkInformation> infoSet);  NetworkOrganizer(@NonNull Collection<NetworkInformation> infoSet, String mask);  NetworkOrganizer(@NonNull String networkMask); }
NetworkOrganizer { public List<String> getSubset(int numShards) { return getSubset(numShards, null); } protected  NetworkOrganizer(@NonNull Collection<NetworkInformation> infoSet);  NetworkOrganizer(@NonNull Collection<NetworkInformation> infoSet, String mask);  NetworkOrganizer(@NonNull String networkMask); String getMatchingAddress(); List<String> getSubset(int numShards); List<String> getSubset(int numShards, Collection<String> primary); }
NetworkOrganizer { public List<String> getSubset(int numShards) { return getSubset(numShards, null); } protected  NetworkOrganizer(@NonNull Collection<NetworkInformation> infoSet);  NetworkOrganizer(@NonNull Collection<NetworkInformation> infoSet, String mask);  NetworkOrganizer(@NonNull String networkMask); String getMatchingAddress(); List<String> getSubset(int numShards); List<String> getSubset(int numShards, Collection<String> primary);  }