@Test(expected = IllegalArgumentException.class) public void testInvalidIPMultipleAddresses() { service.getCoordinates("1.2.3.4.5"); }
@Override public final double[] getCoordinates(final String ip) { double[] result = coordinatesCache.getIfPresent(ip); if (result == null) { Location location; try { location = reader.city(InetAddress.getByName(ip)).getLocation(); result = new double[] { location.getLatitude(), location.getLongitude() }; } catch (UnknownHostException e) { String msg = "Invalid IP: " + Objects.toString(ip); CustomLog.logError(Level.SEVERE, msg, e); throw new IllegalArgumentException("Invalid IP", e); } catch (IOException e) { String msg = "Could not locate IP: " + Objects.toString(ip) + ", " + "because of I/O error:" + e.getMessage(); CustomLog.logError(Level.SEVERE, msg, e); throw new IllegalStateException(e); } catch (GeoIp2Exception e) { String msg = "Could not locate IP: " + Objects.toString(ip) + ", because " + e.getMessage(); CustomLog.logError(Level.FINER, msg, e); result = new double[] { Double.NaN, Double.NaN }; } coordinatesCache.put(ip, result); } return result; }
GeoIP2PingERService extends BaseGeolocationService implements IGeolocationService, Closeable { @Override public final double[] getCoordinates(final String ip) { double[] result = coordinatesCache.getIfPresent(ip); if (result == null) { Location location; try { location = reader.city(InetAddress.getByName(ip)).getLocation(); result = new double[] { location.getLatitude(), location.getLongitude() }; } catch (UnknownHostException e) { String msg = "Invalid IP: " + Objects.toString(ip); CustomLog.logError(Level.SEVERE, msg, e); throw new IllegalArgumentException("Invalid IP", e); } catch (IOException e) { String msg = "Could not locate IP: " + Objects.toString(ip) + ", " + "because of I/O error:" + e.getMessage(); CustomLog.logError(Level.SEVERE, msg, e); throw new IllegalStateException(e); } catch (GeoIp2Exception e) { String msg = "Could not locate IP: " + Objects.toString(ip) + ", because " + e.getMessage(); CustomLog.logError(Level.FINER, msg, e); result = new double[] { Double.NaN, Double.NaN }; } coordinatesCache.put(ip, result); } return result; } }
GeoIP2PingERService extends BaseGeolocationService implements IGeolocationService, Closeable { @Override public final double[] getCoordinates(final String ip) { double[] result = coordinatesCache.getIfPresent(ip); if (result == null) { Location location; try { location = reader.city(InetAddress.getByName(ip)).getLocation(); result = new double[] { location.getLatitude(), location.getLongitude() }; } catch (UnknownHostException e) { String msg = "Invalid IP: " + Objects.toString(ip); CustomLog.logError(Level.SEVERE, msg, e); throw new IllegalArgumentException("Invalid IP", e); } catch (IOException e) { String msg = "Could not locate IP: " + Objects.toString(ip) + ", " + "because of I/O error:" + e.getMessage(); CustomLog.logError(Level.SEVERE, msg, e); throw new IllegalStateException(e); } catch (GeoIp2Exception e) { String msg = "Could not locate IP: " + Objects.toString(ip) + ", because " + e.getMessage(); CustomLog.logError(Level.FINER, msg, e); result = new double[] { Double.NaN, Double.NaN }; } coordinatesCache.put(ip, 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[] getCoordinates(final String ip) { double[] result = coordinatesCache.getIfPresent(ip); if (result == null) { Location location; try { location = reader.city(InetAddress.getByName(ip)).getLocation(); result = new double[] { location.getLatitude(), location.getLongitude() }; } catch (UnknownHostException e) { String msg = "Invalid IP: " + Objects.toString(ip); CustomLog.logError(Level.SEVERE, msg, e); throw new IllegalArgumentException("Invalid IP", e); } catch (IOException e) { String msg = "Could not locate IP: " + Objects.toString(ip) + ", " + "because of I/O error:" + e.getMessage(); CustomLog.logError(Level.SEVERE, msg, e); throw new IllegalStateException(e); } catch (GeoIp2Exception e) { String msg = "Could not locate IP: " + Objects.toString(ip) + ", because " + e.getMessage(); CustomLog.logError(Level.FINER, msg, e); result = new double[] { Double.NaN, Double.NaN }; } coordinatesCache.put(ip, 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[] getCoordinates(final String ip) { double[] result = coordinatesCache.getIfPresent(ip); if (result == null) { Location location; try { location = reader.city(InetAddress.getByName(ip)).getLocation(); result = new double[] { location.getLatitude(), location.getLongitude() }; } catch (UnknownHostException e) { String msg = "Invalid IP: " + Objects.toString(ip); CustomLog.logError(Level.SEVERE, msg, e); throw new IllegalArgumentException("Invalid IP", e); } catch (IOException e) { String msg = "Could not locate IP: " + Objects.toString(ip) + ", " + "because of I/O error:" + e.getMessage(); CustomLog.logError(Level.SEVERE, msg, e); throw new IllegalStateException(e); } catch (GeoIp2Exception e) { String msg = "Could not locate IP: " + Objects.toString(ip) + ", because " + e.getMessage(); CustomLog.logError(Level.FINER, msg, e); result = new double[] { Double.NaN, Double.NaN }; } coordinatesCache.put(ip, 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);  }