1

我现在在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 配置这个例子?

4

2 回答 2

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();
}
}
于 2015-10-01T08:33:03.220 回答
-1

您可以使用Configuration对象的各种.set()方法以编程方式设置 hadoop 配置,如下所示:

Configuration conf = new Configuration();
conf.set("example.foo", "bar");
于 2013-05-07T11:05:50.877 回答