2013-05-30 70 views
1

我正在MapReduce中構建一個日誌分析程序。我正在使用MaxMind GeoIP數據。現在我想將GeoIP數據放入分佈式緩存中。我在eclipse中開發我的應用程序。這是我在做什麼Hadoop 1.0.4分佈式緩存錯誤

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) 

我無法弄清楚什麼是錯的。請幫助

+0

當您將文件添加到緩存時,可以在部分中顯示導入嗎? –

回答

2

它撿了錯誤的類:你進口URIConfiguration

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

檢查。

按照該documentation,就應該java.net.URIorg.apache.hadoop.conf.Configuration

我想你可能已經搞砸了與JDK javax.security.auth.login.Configuration類。這不應該在這裏使用。

+0

工作感謝您的幫助! – Ananda