2013년 8월 2일 금요일

스프링 프레임워크 - 하둡

스프링에 하둡 배치 잡을 실행 시킬 수 있다.
참조: http://bcho.tistory.com/726
http://static.springsource.org/spring-hadoop/docs/current/reference/html/fs.html

환경 설정은 위의 참조 홈페이지를 따라 하면 되고 메이븐을 쓴다면
스프링 프레임워크의 하둡 프로젝트를 디펜던시에 추가해주면 된다.
디펜던지 참조: http://www.springsource.org/spring-data/hadoop

나는 설정을 이렇게 했다.
<hdp:configuration>
        fs.default.name=${hd.fs}
        dfs.name.dir=file://${name.dir}
        dfs.data.dir=file://${data.dir}
        hadoop.temp.dir=file://${temp.dir}
     </hdp:configuration>

그리고 나는 맵과 리듀스 그리고 드라이버 이렇게 하나의 하둡잡에 세개의 클래스를 만들었다.
그래서 스프링에서 아래와 같이 드라이버를 tool-runner로 실행했다.
<hdp:tool-runner id="내Driver" tool-class="com.내Driver"
run-at-startup="true">
    <hdp:arg value="/user/내hdfs/input"/>
    <hdp:arg value="/user/내hdfs/test/output"/>
    <hdp:arg value="세번째 인자"/>
    <hdp:arg value="네번째 인자"/>
    property=value
</hdp:tool-runner>

그리고 실행하니 NullPointerException이 난다.
Error creating bean with name 'adMainDriver': Invocation of init method failed; nested exception is java.lang.NullPointerExcepttion

원인은 잘 모르겠지만 결론적으론 내 하둡 설정이 잘못되어 있던 것인듯
스프링 소스에서 설정 부분을 아래로 바꿨더니 돌아간다.
파일 이름은 시스템에서 사용하는 하둡 설정 파일로 바꾸고 내 시스템의 하둡 설정 파일을 소스폴더에 붙여넣었다.
<hdp:configuration resources="classpath:/custom-site.xml, classpath:/hq-site.xml"/>

댓글 없음:

댓글 쓰기