2013-03-13 4 views
1

맵퍼에서 hadoop 파일 시스템에 일반 텍스트 파일을 직접 쓰려고합니다. 다음과 같이지도에서 hadoop 파일 시스템 (HDFS)에 쓰기가 가능하지 않습니다.

나는 그것을 할 :

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); 
    } 
} 

을 그리고 의사 분산 모드에서 아무것도 기록하지 않습니다. 그러나 독립 실행 형에서는 완벽하게 작성합니다.

어디에 문제가 있습니까?

+0

무엇이 오류입니까? 전달 된'Configuration' 객체가'fs.default.name' 속성을 가지고 있지 않으면이 파일을 HDFS가 아닌 로컬 디스크에 쓸 수 있습니다. –

+0

로깅 문을 코드에 넣고 로그를 확인 했습니까? – dfrankow

답변

1

Amazon Elastic MapReduce (EMR)를 사용하고 있었고 S3에서 파일을 사용할 수 있으려면 get FileSystem by URI을 사용해야했습니다.

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

도움이되지 않을 수도 있습니다.