Package com.maxmind.geoip

Examples of com.maxmind.geoip.LookupService


    maxmind = new LookupService(dbFile, LookupService.GEOIP_MEMORY_CACHE);
  }
 
  public IpGeo(String locationDbFile, String asnDbFile, int options) throws IOException
  {
    maxmind = new LookupService(locationDbFile, options);
    asnLookup = new LookupService(asnDbFile, options);
  }
View Full Code Here


        if (verbose) System.out.println("Writing to solr server at: " + sserver);
    solr = new CommonsHttpSolrServer(sserver);

    metadataStorageInfo = SolrLogger.getMetadataStorageInfo();
        String dbfile = ConfigurationManager.getProperty("solr.dbfile");
    geoipLookup = new LookupService(dbfile, LookupService.GEOIP_STANDARD);

        StatisticsImporter si = new StatisticsImporter(local);
        if (line.hasOption('m'))
        {
            // Convert all the files
View Full Code Here

    Map metadataStorageInfo = SolrLogger.getMetadataStorageInfo();

    String prevIp = null;
    String dbfile = ConfigurationManager.getProperty("solr.dbfile");
    LookupService cl = new LookupService(dbfile,
        LookupService.GEOIP_STANDARD);
    int countryErrors = 0;
    for (int i = 0; i < nrLogs; i++) {
      String ip = "";
      Date time;
      String continent;
      String country = "";
      String countryCode;
      float longitude;
      float latitude;
      String city;

      // 1. Generate an ip for our user
      for (int j = 0; j < 4; j++) {
        ip += getRandomNumberInRange(0, 254);
        if (j != 3)
          ip += ".";
      }
      // 2 Depending on our ip get all the location info
      Location location;
      try {
        location = cl.getLocation(ip);
      } catch (Exception e) {
        location = null;
      }
      if (location == null) {
        // If we haven't got a prev ip this is pretty useless so move on
        // to the next one
        if (prevIp == null)
          continue;
        ip = prevIp;
        location = cl.getLocation(ip);
      }

      city = location.city;
      country = location.countryName;
      countryCode = location.countryCode;
View Full Code Here

    }

    public void initializeElasticSearch() {
        log.info("DSpace ElasticSearchLogger Initializing");
        try {
        LookupService service = null;
        // Get the db file for the location
        String dbfile = ConfigurationManager.getProperty("usage-statistics", "dbfile");
        if (dbfile != null) {
            try {
                service = new LookupService(dbfile, LookupService.GEOIP_STANDARD);
            } catch (FileNotFoundException fe) {
                log.error("The GeoLite Database file is missing (" + dbfile + ")! Usage Statistics cannot generate location based reports! Please see the DSpace installation instructions for instructions to install this file.", fe);
            } catch (IOException e) {
                log.error("Unable to load GeoLite Database file (" + dbfile + ")! You may need to reinstall it. See the DSpace installation instructions for more details.", e);
            }
View Full Code Here

    solr.deleteByQuery("*:*");
    solr.commit();

    String prevIp = null;
    String dbfile = ConfigurationManager.getProperty("usage-statistics", "dbfile");
    LookupService cl = new LookupService(dbfile,
        LookupService.GEOIP_STANDARD);
    int countryErrors = 0;
    for (int i = 0; i < nrLogs; i++) {
      String ip = "";
      Date time;
      String continent;
      String countryCode;
      float longitude;
      float latitude;
      String city;

      // 1. Generate an ip for our user
            StringBuilder ipBuilder = new StringBuilder();
      for (int j = 0; j < 4; j++) {
        ipBuilder.append(getRandomNumberInRange(0, 254));
        if (j != 3)
                {
                    ipBuilder.append(".");
                }
      }
            ip = ipBuilder.toString();
           
      // 2 Depending on our ip get all the location info
      Location location;
      try {
        location = cl.getLocation(ip);
      } catch (Exception e) {
        location = null;
      }
      if (location == null) {
        // If we haven't got a prev ip this is pretty useless so move on
        // to the next one
        if (prevIp == null)
                {
                    continue;
                }
        ip = prevIp;
        location = cl.getLocation(ip);
      }

      city = location.city;
      countryCode = location.countryCode;
      longitude = location.longitude;
View Full Code Here

        boolean verbose = line.hasOption('v');

        String dbfile = ConfigurationManager.getProperty("usage-statistics", "dbfile");
        try
        {
            geoipLookup = new LookupService(dbfile, LookupService.GEOIP_STANDARD);
        }
        catch (FileNotFoundException fe)
        {
            log.error("The GeoLite Database file is missing (" + dbfile + ")! Elastic Search  Statistics cannot generate location based reports! Please see the DSpace installation instructions for instructions to install this file.", fe);
        }
View Full Code Here

    solr = new HttpSolrServer(sserver);

        String dbfile = ConfigurationManager.getProperty("usage-statistics", "dbfile");
        try
        {
            geoipLookup = new LookupService(dbfile, LookupService.GEOIP_STANDARD);
        }
        catch (FileNotFoundException fe)
        {
            log.error("The GeoLite Database file is missing (" + dbfile + ")! Solr Statistics cannot generate location based reports! Please see the DSpace installation instructions for instructions to install this file.", fe);
        }
View Full Code Here

        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)) {
View Full Code Here

  }

  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)) {
View Full Code Here

    try {
      file = new File(url.toURI());
    } catch (URISyntaxException e) {
      e.printStackTrace();
    }
    this.lookupService = file != null ? new LookupService(file) : null;
    // vv HushHTablePoolProvider
  }
View Full Code Here

TOP

Related Classes of com.maxmind.geoip.LookupService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.