@Test public void testLatencies() { double delta = 25; assertEquals(68.08, service.latency(LA_IP, NEW_YORK_IP), delta); assertEquals(34.79, service.latency(ORLEANDO_IP, NEW_YORK_IP), delta); assertEquals(30.39, service.latency(MADRID_IP, LONDON_IP), delta); assertEquals(117.13, service.latency(HONG_KONG_IP, SYDNEY_IP), delta); assertEquals(77.28, service.latency(SINGAPORE_IP, TOKYO_IP), delta); assertEquals(75.07, service.latency(LONDON_IP, NEW_YORK_IP), delta); assertEquals(110.28, service.latency(RIO_DE_JANEIRO_IP, NEW_YORK_IP), delta); assertEquals(97.33, service.latency(TOKYO_IP, SAN_FRANCISCO_IP), delta); }
@Override public final double latency(final String ip1, final String ip2) { String key = ip1 + ip2; Double cached = ipDistanceCache.getIfPresent(key); if (cached != null) { return cached; } final double[] reqCoord1 = getCoordinates(ip1); final double[] reqCoord2 = getCoordinates(ip2); double result = latency(reqCoord1, reqCoord2); CustomLog.print(Level.FINEST, String.format("Latency betweeen %s and %s is %.2f", ip1, ip2, result)); ipDistanceCache.put(key, result); return result; }
GeoIP2PingERService extends BaseGeolocationService implements IGeolocationService, Closeable { @Override public final double latency(final String ip1, final String ip2) { String key = ip1 + ip2; Double cached = ipDistanceCache.getIfPresent(key); if (cached != null) { return cached; } final double[] reqCoord1 = getCoordinates(ip1); final double[] reqCoord2 = getCoordinates(ip2); double result = latency(reqCoord1, reqCoord2); CustomLog.print(Level.FINEST, String.format("Latency betweeen %s and %s is %.2f", ip1, ip2, result)); ipDistanceCache.put(key, result); return result; } }
GeoIP2PingERService extends BaseGeolocationService implements IGeolocationService, Closeable { @Override public final double latency(final String ip1, final String ip2) { String key = ip1 + ip2; Double cached = ipDistanceCache.getIfPresent(key); if (cached != null) { return cached; } final double[] reqCoord1 = getCoordinates(ip1); final double[] reqCoord2 = getCoordinates(ip2); double result = latency(reqCoord1, reqCoord2); CustomLog.print(Level.FINEST, String.format("Latency betweeen %s and %s is %.2f", ip1, ip2, result)); ipDistanceCache.put(key, result); return result; } GeoIP2PingERService(final InputStream geoIP2DB, final InputStream pingErRTT, final InputStream pingerMonitoringSites);  GeoIP2PingERService(final File geoIP2DB, final File pingErRTTFile, final File pingerMonitoringSitesFile);  GeoIP2PingERService(); }
GeoIP2PingERService extends BaseGeolocationService implements IGeolocationService, Closeable { @Override public final double latency(final String ip1, final String ip2) { String key = ip1 + ip2; Double cached = ipDistanceCache.getIfPresent(key); if (cached != null) { return cached; } final double[] reqCoord1 = getCoordinates(ip1); final double[] reqCoord2 = getCoordinates(ip2); double result = latency(reqCoord1, reqCoord2); CustomLog.print(Level.FINEST, String.format("Latency betweeen %s and %s is %.2f", ip1, ip2, result)); ipDistanceCache.put(key, result); return result; } GeoIP2PingERService(final InputStream geoIP2DB, final InputStream pingErRTT, final InputStream pingerMonitoringSites);  GeoIP2PingERService(final File geoIP2DB, final File pingErRTTFile, final File pingerMonitoringSitesFile);  GeoIP2PingERService(); @Override final double[] getCoordinates(final String ip); @Override IPMetadata getMetaData(final String ip); @Override void close(); @Override final double latency(final String ip1, final String ip2); @Override double latency(final double[] reqCoord1, final double[] reqCoord2); double weigthedAverage(final MinMaxPriorityQueue<PingERLatencyEntry> heap); void updateHeap(final MinMaxPriorityQueue<PingERLatencyEntry> heap, final PingERLatencyEntry qEntry); static void main(String[] args); }
GeoIP2PingERService extends BaseGeolocationService implements IGeolocationService, Closeable { @Override public final double latency(final String ip1, final String ip2) { String key = ip1 + ip2; Double cached = ipDistanceCache.getIfPresent(key); if (cached != null) { return cached; } final double[] reqCoord1 = getCoordinates(ip1); final double[] reqCoord2 = getCoordinates(ip2); double result = latency(reqCoord1, reqCoord2); CustomLog.print(Level.FINEST, String.format("Latency betweeen %s and %s is %.2f", ip1, ip2, result)); ipDistanceCache.put(key, result); return result; } GeoIP2PingERService(final InputStream geoIP2DB, final InputStream pingErRTT, final InputStream pingerMonitoringSites);  GeoIP2PingERService(final File geoIP2DB, final File pingErRTTFile, final File pingerMonitoringSitesFile);  GeoIP2PingERService(); @Override final double[] getCoordinates(final String ip); @Override IPMetadata getMetaData(final String ip); @Override void close(); @Override final double latency(final String ip1, final String ip2); @Override double latency(final double[] reqCoord1, final double[] reqCoord2); double weigthedAverage(final MinMaxPriorityQueue<PingERLatencyEntry> heap); void updateHeap(final MinMaxPriorityQueue<PingERLatencyEntry> heap, final PingERLatencyEntry qEntry); static void main(String[] args);  }