ls = new LookupService(f, LookupService.GEOIP_STANDARD); for (int i = 0; i < search.length; i++) { Long ipl = search[i]; ls = new LookupService(f, LookupService.GEOIP_STANDARD); for (int i = 0; i < search.length; i++) { Long ipl = search[i];
LookupService lookupService = new LookupService("./GeoIP.dat");
@Override public void setup() { try { reader = new LookupService(databasePath, LookupService.GEOIP_MEMORY_CACHE | LookupService.GEOIP_CHECK_CACHE); } catch (IOException ex) { throw new RuntimeException(ex); } }
@Override public void setup() { try { reader = new LookupService(databasePath, LookupService.GEOIP_MEMORY_CACHE | LookupService.GEOIP_CHECK_CACHE); } catch (IOException ex) { throw new RuntimeException(ex); } }
/** * Create a IP -> Location mapper. * Pig example: * DEFINE GeoIpLookup com.mozilla.pig.eval.geoip.GeoIpLookup('GeoIPCity.dat'); * foo = LOAD ... * bar = foreach foo generate GeoIpLookup(ip_address) AS * location:tuple(country:chararray, country_code:chararray, * region:chararray, city:chararray, * postal_code:chararray, metro_code:int); * * This will expect a file in hdfs in /user/you/GeoIPCity.dat * * Using the getCacheFiles approach, you no longer need to specify the * -Dmapred.cache.archives * -Dmapred.create.symlink * options to pig. * * @param filename Basename of the GeoIP Database file. Should be located in your home dir in HDFS * @throws IOException */ public GeoIpLookup(String filename) throws IOException { lookupFilename = filename; lookupService = new LookupService(lookupFilename); }
LookupService ls = new LookupService("/usr/local/share/GeoIP/GeoIPCity.dat"); Location location = cl.getLocation("213.52.50.8"); System.out.println(location.countryName); System.out.println(location.city); ...
public static synchronized LookupService getLookup() { if (lookup!=null) return lookup; try { lookup = new LookupService(MAXMIND_DB_PATH); } catch (IOException e) { lookupFailed = true; log.debug("MaxMind geo lookup unavailable; either download and unpack the latest "+ "http://www.maxmind.com/app/geolitecity binary into "+MAXMIND_DB_PATH+", "+ "or specify a different HostGeoLookup implementation with the key "+ BrooklynSystemProperties.HOST_GEO_LOOKUP_IMPL.getPropertyName()+" (error trying to read: "+e+")"); } return lookup; }
if (DistributedCache.getLocalCacheFiles(context.getConfiguration()) != null) { List<Path> localFiles = Utility.arrayToList(DistributedCache.getLocalCacheFiles(context.getConfiguration())); for (Path localFile : localFiles) { if ((localFile.getName() != null) && (localFile.getName().equalsIgnoreCase("GeoIPCity.dat"))) { m_geoipLookupService = new LookupService(new File(localFile.toUri().getPath())); } } }
protected String lookup(String ip) throws IOException { if (geoloc == null) { geoloc = new LookupService("./" + DIST_CACHE_GEOIP_NAME, LookupService.GEOIP_MEMORY_CACHE); } String country = geoloc.getCountry(ip).getName(); if ("N/A".equals(country)) { return null; } return country; }
protected String lookup(String ip, String filename) throws HiveException { try { if (geoloc == null) { URL u = getClass().getClassLoader().getResource(filename); if (u == null) { throw new HiveException("Couldn't find geolocation file '" + filename + "'"); } geoloc = new LookupService(u.getFile(), LookupService.GEOIP_MEMORY_CACHE); } String countryCode = geoloc.getCountry(ip).getCode(); if ("--".equals(countryCode)) { return null; } return countryCode; } catch (IOException e) { throw new HiveException("Caught IO exception", e); } }
@BeforeClass public static void createGeoIPDatabase() throws IOException { File f = new File("GeoLiteCity.dat"); if (!f.exists()) { return; } geoipLookup = new LookupService(f); }
/** * Gets the single instance of the {@link LookupService}. * * @return the single instance of the {@link LookupService}. */ public static LookupService getInstance() throws IOException { if (instance == null) { synchronized (LookupServiceSingleton.class) { // double check... if (instance == null) { File fileLocation = null; final InputStream is = ClassExtensions.getResourceAsStream(PREFIX + SUFFIX); fileLocation = inputStreamToFile(is); instance = new LookupService(fileLocation, LookupService.GEOIP_MEMORY_CACHE); } } } return instance; }
@BeforeClass public static void createGeoIPDatabase() throws IOException { File f = new File("GeoLiteCity.dat"); if (!f.exists()) { return; } geoipLookup = new LookupService(f); }
LookupService cl = new LookupService(ConfigSettings.getGeoIPCityFile(), LookupService.GEOIP_MEMORY_CACHE); String kmlBodyPayload = "";
@Override public Object getValueAt(int rowIndex, int columnIndex) { if (countryLookup == null) { try { countryLookup = new LookupService(ConfigSettings.getGeoIPCountryFile(), LookupService.GEOIP_MEMORY_CACHE); } catch (IOException ex) { Logger.getLogger(IpModel.class.getName()).log(Level.SEVERE, null, ex); } } if (rowIndex < getRowCount()) { String rowStr = (String) data.get(rowIndex); if (rowStr == null) { return null; } switch (columnIndex) { case 0: return rowStr; case 1: return "<n/a>"; case 2: if (countryLookup != null) { return countryLookup.getCountry(rowStr).getName(); } else { return "<n/a>"; } } } return null; }
try geoipLookup = new LookupService(dbfile, LookupService.GEOIP_STANDARD);
lookupService = new LookupService(file, LookupService.GEOIP_MEMORY_CACHE | LookupService.GEOIP_CHECK_CACHE); databases.put(databaseName, lookupService); } catch (IOException ex) {
Map<String, CustomWaypoint> point = new HashMap<>(); try { LookupService cl = new LookupService(ConfigSettings.getGeoIPCityFile(), LookupService.GEOIP_MEMORY_CACHE);
if (geoIpLookupService == null) { String dbLocation = env.get("geoIpDb.location"); geoIpLookupService = new LookupService(dbLocation, LookupService.GEOIP_MEMORY_CACHE);
lookupService = new LookupService(filename, LookupService.GEOIP_MEMORY_CACHE);