Error using GeoLite2-Country.mmdb local database in divolte-collector

357 views
Skip to first unread message

Roger Ganga Sundararaj

unread,
Apr 4, 2017, 3:09:27 AM4/4/17
to divolte-collector
Hello all,
I am trying to retrieve the country details using clickstream data for which I have downloaded the GeoLite2-Country database. I have made the following modifications in my configuration files:

1. divolte-collector.conf
 
    divolte{
    global{
    mapper{
    ip2geo_database = "/path-to/divolte/ip2geo/GeoLite2-Country.mmdb"
    }
    }
    }

2. mapping.groovy

   def ua = ip2geo()                                                                   //by default it will take the remoteHost
  map ua.countryName() onto 'countryNameField'

3. MyEventRecord.avsc

{
  "namespace": "io.divolte.examples.record",
  "type": "record",
  "name": "MyEventRecord",
  "fields": [
   { "name": "countryNameField",          "type": ["null", "string"],    "default": null }
  ]
}

Once the ip2geo() function is called when a page is loaded, it throws the following error:

Caused by: java.lang.UnsupportedOperationException: Invalid attempt to open a GeoLite2-Country database using the city method

Turns out that it was trying to access com.maxmind.geoip2.DatabaseReader.city() function instead of country() function.

Caused by: java.lang.UnsupportedOperationException: Invalid attempt to open a GeoLite2-Country database using the city method
    at com.maxmind.geoip2.DatabaseReader.get(DatabaseReader.java:150)
    at com.maxmind.geoip2.DatabaseReader.city(DatabaseReader.java:206)
    at io.divolte.server.ip2geo.DatabaseLookupService.lookup(DatabaseLookupService.java:81)

On looking further into io.divolte.server.ip2geo.DatabaseLookupService, there is class only to collect the CityResponse and not the CountryResponse.

import com.maxmind.db.ClosedDatabaseException;
import com.maxmind.geoip2.DatabaseReader;
import com.maxmind.geoip2.exception.GeoIp2Exception;
import com.maxmind.geoip2.model.CityResponse;

Can anyone pls let me know is this the reason why I am not getting any country details? How can the issue be solved so that I can get the country name?

No issues were found in executing when I use GeoLite2-City.mmdb database.


Andrew Snare

unread,
Apr 4, 2017, 3:35:39 AM4/4/17
to divolte-collector
Hi Roger,

I've never tried out the Country-Lite database: normally I use the City databases (paid and lite).

I assume you're able to proceed by mapping the Country from the City-Lite database?

Is there any reason why you'd prefer the Country-Lite database instead? I can think of some reasons but would like to read yours… ;)

Cheers,

 - Andrew

Roger Ganga Sundararaj

unread,
Apr 4, 2017, 3:46:42 AM4/4/17
to divolte-collector
Woah!! Thank you very much, Andrew!! It did work!! :D 

I was under the assumption that the country details can be retrieved by only using GeoLite-Country database not via City database and hence I preferred the country database. 

Can you please explain what is the exact difference between country and the city database and its uses? I am more curious to know about the same.

Thanks again!!!

Regards,
Roger Ganga Sundararaj.

Andrew Snare

unread,
Apr 4, 2017, 4:06:02 AM4/4/17
to divolte-collector
Hi Roger,

The country database is a subset of the city database: the city database simply has more granular data. (If you look at the class hierarchy carefully, you'll see that CityResponse and CountryResponse both extend from AbstractCountryResponse which is where the country fields are declared. This makes sense: cities belong to a country.)

There are two reasons that spring to mind for preferring the country databases over the city ones, assuming you don't need the more granular lookup:
  1. If you're paying, the country databases are cheaper.
  2. The country databases are much smaller than the city ones, which means that lookup performance would probably be better.
I've created issue #156 to note this problem and track its resolution.

Cheers,

 - Andrew

Roger Ganga Sundararaj

unread,
Apr 4, 2017, 6:55:34 AM4/4/17
to divolte-collector
Interesting!! I didn't notice the AbstractCountryResponse class. Thank you very much, Andrew!! That was very helpful and informative!!!

Cheers,
Roger Ganga Sundararaj
Reply all
Reply to author
Forward
0 new messages