Search in sources :

Example 16 with DatabaseReader

use of com.maxmind.geoip2.DatabaseReader in project nutch by apache.

the class GeoIPDocumentCreator method createDocFromIspDb.

public static NutchDocument createDocFromIspDb(String serverIp, NutchDocument doc, DatabaseReader reader) throws UnknownHostException, IOException, GeoIp2Exception {
    IspResponse response = reader.isp(InetAddress.getByName(serverIp));
    addIfNotNull(doc, "ip", serverIp);
    addIfNotNull(doc, "autonSystemNum", response.getAutonomousSystemNumber());
    addIfNotNull(doc, "autonSystemOrg", response.getAutonomousSystemOrganization());
    addIfNotNull(doc, "isp", response.getIsp());
    addIfNotNull(doc, "org", response.getOrganization());
    return doc;
}
Also used : IspResponse(com.maxmind.geoip2.model.IspResponse)

Aggregations

IOException (java.io.IOException)8 DatabaseReader (com.maxmind.geoip2.DatabaseReader)6 CityResponse (com.maxmind.geoip2.model.CityResponse)5 InetAddress (java.net.InetAddress)5 GeoIp2Exception (com.maxmind.geoip2.exception.GeoIp2Exception)4 IspResponse (com.maxmind.geoip2.model.IspResponse)3 File (java.io.File)3 InputStream (java.io.InputStream)3 HashMap (java.util.HashMap)3 CHMCache (com.maxmind.db.CHMCache)2 AddressNotFoundException (com.maxmind.geoip2.exception.AddressNotFoundException)2 ConnectionTypeResponse (com.maxmind.geoip2.model.ConnectionTypeResponse)2 DomainResponse (com.maxmind.geoip2.model.DomainResponse)2 Subdivision (com.maxmind.geoip2.record.Subdivision)2 GZIPInputStream (java.util.zip.GZIPInputStream)2 FlowFile (org.apache.nifi.flowfile.FlowFile)2 DatabaseReader (org.apache.nifi.processors.maxmind.DatabaseReader)2 StopWatch (org.apache.nifi.util.StopWatch)2 JsonObject (com.google.gson.JsonObject)1 InvalidDatabaseException (com.maxmind.db.InvalidDatabaseException)1