1

マッパーから直接 Hadoop ファイル システムにプレーン テキスト ファイルを書き込もうとしています。

私は次のようにします:

public void createFile(Configuration conf) throws IOException{    
    FileSystem fs = FileSystem.get(conf);

    Path filenamePath = new Path(conf.get("mapred.output.dir")+"/_"+conf.get("mapred.task.id"), "tree.txt");    

        try {

      if (fs.exists(filenamePath)) {        
        // remove the file first
        fs.delete(filenamePath);            
      }

      FSDataOutputStream out = fs.create(filenamePath);       
      out.writeUTF("hello, world!");        
      out.close();

    } catch (IOException ioe) {
        System.err.println("IOException during operation: " + ioe.toString());
        System.exit(1);
    }
}

また、疑似分散モードでは何も書き込みません。ただし、スタンドアロンでは完璧に書きます。

問題はどこだ?

4

1 に答える 1

1

私は Amazon Elastic MapReduce (EMR) を使用していましたが、S3 からファイルを使用できるようにするには、URI で FileSystem を取得する必要がありました。

FileSystem fs = FileSystem.get(uri, conf);

それはあなたを助けないかもしれません。

于 2013-03-13T18:58:07.323 に答える