@Test @Ignore("AB 2019/05/30 - Intermittent issue or flaky test - see issue #7657") public void testNetTree6() throws Exception { List<String> ips = new ArrayList<>(); NetworkOrganizer.VirtualTree tree = new NetworkOrganizer.VirtualTree(); for (int i = 0; i < 254; i++) ips.add(getRandomIp()); for (int i = 1; i < 255; i++) ips.add(getRandomAwsIp()); Collections.shuffle(ips); Set<String> uniqueIps = new HashSet<>(ips); for (String ip : uniqueIps) tree.map(NetworkOrganizer.convertIpToOctets(ip)); assertEquals(508, uniqueIps.size()); assertEquals(uniqueIps.size(), tree.getTotalBranches()); assertEquals(uniqueIps.size(), tree.getUniqueBranches()); String networkA = tree.getHottestNetworkA(); assertEquals("10101100", networkA); String networkAB = tree.getHottestNetworkAB(); }
protected static String convertIpToOctets(@NonNull String ip) { String[] octets = ip.split("\\."); if (octets.length != 4) throw new UnsupportedOperationException(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < 3; i++) builder.append(toBinaryOctet(octets[i])).append("."); builder.append(toBinaryOctet(octets[3])); return builder.toString(); }
NetworkOrganizer { protected static String convertIpToOctets(@NonNull String ip) { String[] octets = ip.split("\\."); if (octets.length != 4) throw new UnsupportedOperationException(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < 3; i++) builder.append(toBinaryOctet(octets[i])).append("."); builder.append(toBinaryOctet(octets[3])); return builder.toString(); } }
NetworkOrganizer { protected static String convertIpToOctets(@NonNull String ip) { String[] octets = ip.split("\\."); if (octets.length != 4) throw new UnsupportedOperationException(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < 3; i++) builder.append(toBinaryOctet(octets[i])).append("."); builder.append(toBinaryOctet(octets[3])); return builder.toString(); } protected  NetworkOrganizer(@NonNull Collection<NetworkInformation> infoSet);  NetworkOrganizer(@NonNull Collection<NetworkInformation> infoSet, String mask);  NetworkOrganizer(@NonNull String networkMask); }
NetworkOrganizer { protected static String convertIpToOctets(@NonNull String ip) { String[] octets = ip.split("\\."); if (octets.length != 4) throw new UnsupportedOperationException(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < 3; i++) builder.append(toBinaryOctet(octets[i])).append("."); builder.append(toBinaryOctet(octets[3])); return builder.toString(); } 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 { protected static String convertIpToOctets(@NonNull String ip) { String[] octets = ip.split("\\."); if (octets.length != 4) throw new UnsupportedOperationException(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < 3; i++) builder.append(toBinaryOctet(octets[i])).append("."); builder.append(toBinaryOctet(octets[3])); return builder.toString(); } 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);  }