我现在正在http://blog.springsource.org/2012/02/29/introducing-spring-hadoop/
关注Spring HADOOP的介绍页面示例配置基于xml。以下代码描述了wordCount示例。
<!-- define the job -->
<hdp:job id="word-count"
input-path="/input/" output-path="/ouput/"
mapper="org.apache.hadoop.examples.WordCount.TokenizerMapper"
reducer="org.apache.hadoop.examples.WordCount.IntSumReducer"/>
<!-- execute the job -->
<bean id="runner" class="org.springframework.data.hadoop.mapreduce.JobRunner"
p:jobs-ref="word-count"/>
有没有办法用Javaconfig配置这个例子?
答案 0 :(得分:0)
@Configuration
@EnableHadoop
@PropertySource(value={"classpath:config/hadoop.properties"})
public class HadoopConfiguration extends SpringHadoopConfigurerAdapter {
@Override
public void configure(HadoopConfigConfigurer config) throws Exception {
Properties props = new Properties();
config.fileSystemUri("hdfs://");
config.withProperties(props).property("propkey", "propvalue").and();
}
}
答案 1 :(得分:-1)
您可以使用Configuration
对象的各种.set()
方法以编程方式设置hadoop配置,如下所示:
Configuration conf = new Configuration();
conf.set("example.foo", "bar");