无法从EMR中的分布式缓存中读取序列文件

问题描述:

我想从EMR中的分布式缓存中对文件进行排序,但无法从EMR中的分布式缓存中读取文件。我的代码在本地工作正常,但它给我emr的问题。这里是我的代码snippet-无法从EMR中的分布式缓存中读取序列文件

把序列文件到分布式的cache

job.addCacheFile(new URI(status.getPath().toString())); 

读取路径 -

for (Path eachPath : cacheFilesLocal) { 
loadMap(eachPath.getName(),context.getConfiguration()); 
} 

从路径 -

private void loadMap(String filePath,Configuration conf) throws IOException 
    { 
     try { 
      Path somePath=new Path(filePath); 
      reader=new Reader(somePath.getFileSystem(conf),somePath,conf); 
     // brReader = new BufferedReader(new FileReader(filePath)); 
      Writable key= new Text(); 
      Writable value=new Text(); 
      // Read each line, split and load to HashMap 
      while (reader.next(key,value)) { 
      // String index[]=strLineRead.toString().split(Pattern.quote(" - ")); 
       rMap.put(key.toString(),value.toString()); 
      } 
     } 
     catch (FileNotFoundException e) { 
      e.printStackTrace(); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 
     finally { 
      if (reader != null) { 
       reader.close(); 
      } 
     } 
    } 

任何帮助阅读文件将不胜感激。

+0

我与自定义JAR访问求CacheFile挣扎。 – chetan

在参数提供S3路径按文件enter link description here

现在在Driver类使用的参数 这样的:

job.addCacheFile(new URI(args[3])); 
    job.addCacheFile(new URI(args[4])); 
    job.addCacheFile(new URI(args[5])); 
    job.addCacheFile(new URI(args[5])); 

而在映射使用缓存文件如常。

cacheFiles = context.getCacheFiles(); 
     if (cacheFiles != null) { 
      File cityCacheFile = new File("AreaCityCountryCache"); 

工作对我来说...