2014-11-04 92 views
1

我试图使用分布式缓存的新api来运行hadoop程序。我被困在下面的错误消息。使用分布式缓存的新api的问题

14/11/04 10:54:36 WARN fs.FileUtil: Command 'ln -s /tmp/hadoop-hduser/mapred/local/1415078671812/normal_small /home/yogi/Desktop/normal_small' failed 1 with: ln: failed to create symbolic link ‘/home/yogi/Desktop/normal_small’: Permission denied 

14/11/04 10:54:36 WARN mapred.LocalDistributedCacheManager: Failed to create symlink: /tmp/hadoop-hduser/mapred/local/1415078671812/normal_small <- /home/yogi/Desktop/normal_small 

java.io.FileNotFoundException: hdfs:/master:54310/usr/local/hadoop/input/normal_small (No such file or directory) 

我从来没有在我的代码中提到关于/ home/yogi/Desktop/normal_small的任何信息。无法理解它试图访问该文件的位置。

另外,我应该如何给驱动程序类中的输入文件路径解决文件未找到异常?

下面是我的映射器和驱动程序类摘要:

映射:

BufferedReader in = null; 
    FileReader fr = null; 
    private List<String> list = new ArrayList<String>(); 


    @Override 
    protected void setup(Context context) 
      throws IOException, InterruptedException { 
     Configuration conf = context.getConfiguration(); 
     URI[] cacheFiles = context.getCacheFiles(); 


     try { 
      fr = new FileReader(cacheFiles[0].toString()); 
      in = new BufferedReader(fr); 
      String str; 
      while ((str = in.readLine()) != null) { 
       list.add(str); 
      } 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } finally { 
      in.close(); 
      fr.close(); 
     } 

    } 


public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { 


    FileOutputStream fos = new FileOutputStream("output"); 
    ObjectOutputStream oos = new ObjectOutputStream(fos); 
    oos.writeObject(list); // write MenuArray to ObjectOutputStream 


    BufferedReader br=new BufferedReader(new FileReader("output")); 


     String line=br.readLine(); 
     ......... 
} 

司机:

Job job = Job.getInstance(getConf()); 
job.setJobName("wordcount"); 
job.setJarByClass(driver.class);   
job.addCacheFile(new Path("hdfs://master:54310/usr/local/hadoop/input/normal_small").toUri()); 
+0

我认为,'hdfs:// master:54310'部分根本不需要。然而,它并没有解释幻影路径的查找。 – blackSmith 2014-11-04 05:52:45

+0

@blackSmith:错误依然存在。它显示文件未找到异常。我正在使用multinode hadoop cluster btw – re3el 2014-11-04 06:12:59

+0

你的路径'/ usr/local/hadoop/input/normal_small'似乎指向一个本地文件。该文件应该在HDFS中缓存在节点上。 – blackSmith 2014-11-04 06:29:36

回答

0

当您将文件添加到分布式缓存,它将创建一个临时目录。因此,将该目录的所有权更改为当前用户。