1

我正在 MapReduce 中构建一个日志分析程序。我正在使用 MaxMind GeoIP 数据。现在我想将 GeoIP 数据放入分布式缓存中。我正在eclipse中开发我的应用程序。这是我正在做的

Job job = new Job();        
DistributedCache.addCacheFile(new URI(args[3]), job.getConfiguration());

其中 args[3] 将具有路径。

我在这里使用它

protected void setup(Context context) {
    try {
        //String dbfile = "GeoIP//GeoIPCountry.dat";

        org.apache.hadoop.conf.Configuration conf =  context.getConfiguration();

        Path[] dbfile = DistributedCache.getLocalCacheFiles(conf); 

        // GEOIP_MEMORY_CACHE - load database into memory, faster
        // performance but uses more memory, Increase the JVM heap Size
        cl = new LookupService(dbfile.toString(), LookupService.GEOIP_MEMORY_CACHE);

    } catch (Exception e) {
        System.err.println("Error opening GeoIP data file.");
        System.err.println(e);
        System.exit(2);
    }
}

但是在运行时我收到以下错误

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
The method addCacheFile(URI, Configuration) in the type DistributedCache is not applicable for the arguments (URI, Configuration)

我无法弄清楚出了什么问题。请帮忙

4

1 回答 1

2

它选择了错误的课程:

The method addCacheFile(URI, Configuration) in the type DistributedCache is not applicable for the arguments (URI, Configuration)

检查你的导入URIConfiguration类。

根据文档,它们应该是java.net.URI并且org.apache.hadoop.conf.Configuration

我想你可能搞砸了jdk 中的javax.security.auth.login.Configuration类。那不应该在这里使用。

于 2013-05-30T07:03:26.500 回答