2011-01-18 4 views
0

두 개의 인수 인 URI와 구성이 있습니다. 클라이언트가 설정되어있는 JobConf 객체가 Configuration에서 작동해야한다고 가정하지만 URI는 무엇입니까?hadoop에서 initialize 메서드를 통해 DistributedFileSystem 객체를 초기화하는 방법은 무엇입니까?

JobClient client = new JobClient(); 
JobConf conf = new JobConf(ClickViewSessions.class); 

conf.setJobName("ClickViewSessions"); 

conf.setOutputKeyClass(LongWritable.class); 
conf.setOutputValueClass(MinMaxWritable.class); 

FileInputFormat.addInputPath(conf, new Path("input")); 
FileOutputFormat.setOutputPath(conf, new Path("output")); 

conf.setMapperClass(ClickViewSessionsMapper.class); 
conf.setReducerClass(ClickViewSessionsReducer.class); 

client.setConf(conf); 

DistributedFileSystem dfs = new DistributedFileSystem(); 
try { 
    dfs.initialize(new URI("blah") /* what goes here??? */, conf); 
} catch (Exception e) { 
    throw new RuntimeException(e.toString()); 
} 

가 어떻게 URI가 위 initialize에 대한 호출에 공급받을 수 있나요 : 여기

내가 드라이버를 가지고있는 코드는?

+0

당신이 로컬 또는 원격이 있습니까 Hadoop 클러스터가 실행 중입니까? –

+0

VM에서 실행하고 있습니다. – jonderry

답변

0

URI는 실행중인 HDFS의 위치입니다. 파일 시스템 이름의 기본값은 conf/core-site.xml에 있어야합니다. 'fs.default.name'값은 연결할 URI 여야합니다. 아직 간단한 단일 노드 시스템을 설정하는 방법에 대한 자습서를 보았다하지 않은 경우

, 내가보기 엔 그것을 추천 할 것입니다 :

http://hadoop.apache.org/common/docs/current/single_node_setup.html

0
You could also use as shown below to intialize a file system 

import java.io.IOException; 
import org.apache.hadoop.conf.Configuration; 
import org.apache.hadoop.fs.FileStatus; 
import org.apache.hadoop.fs.FileSystem; 
import org.apache.hadoop.fs.Path; 

    public static void main(String args[]){ 
     try { 
      Configuration conf = new Configuration(); 
      conf.set("fs.defaultFS", "hdfs://localhost:54310/user/hadoop/"); 
      FileSystem fs = FileSystem.get(conf); 
      FileStatus[] status = fs.listStatus(new Path(".")); 
      for(int i=0;i<status.length;i++){ 
       System.out.println(status[i].getPath()); 
      } 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 

    } 
관련 문제