本帖最后由 tb_dhu_hadoop 于 2014-8-11 17:08 编辑
在Oozie bin目录下执行job运行命令: ./oozie job -oozie http://10.1.1.228:11000/oozie -D params.in.test2=D_set -config /opt/botian/taomee/oozie/apps/params/job.properties -run
按照Apache官方文档说明,
oozie job <OPTIONS> : job operations -D <property=value> set/override value for given property
但是我的-D似乎没起到覆盖的作用。
先看看Map类的代码:
public class MrParamsMapper extends MapReduceBase implements
Mapper<LongWritable, Text, Text, IntWritable> {
private Text word = new Text();
private IntWritable one = new IntWritable(1);
private Map<String, String> map = new HashMap<String, String>();
private OutputCollector<Text, IntWritable> outputCollector = null;
@Override
public void configure(JobConf job) {
String test_key_1 = "mapred.mapper.class";
String test_key_2 = "params.in.test";
String test_key_3 = "params.in.test2";
String test_value_1 = job.get(test_key_1);
String test_value_2 = job.get(test_key_2);
String test_value_3 = job.get(test_key_3);
map.put(test_key_1, test_value_1);
map.put(test_key_2, test_value_2);
map.put(test_key_3, test_value_3);
}
@Override
public void map(LongWritable key, Text value,
OutputCollector<Text, IntWritable> output, Reporter reporter)
throws IOException {
String line = value.toString().trim();
StringTokenizer tokenizer = new StringTokenizer(line);
while (tokenizer.hasMoreTokens()) {
word.set(tokenizer.nextToken());
output.collect(word, one);
}
if (outputCollector == null) {
outputCollector = output;
}
}
@Override
public void close() throws IOException {
for(Map.Entry<String, String> entry:map.entrySet()){
outputCollector.collect(new Text(entry.getKey()+"-->"+entry.getValue()), one);
}
}
}
main类中:
Configuration actionConf = new Configuration(false);
actionConf.addResource(new Path("file:///", System
.getProperty("oozie.action.conf.xml")));
actionConf.set("params.in.test", "conf_set");
actionConf.set("params.in.test2", "conf_set");
HDFS上的输出结果:
mapred.mapper.class-->tm.research.oozie.MrParamsMapper 1
message[${wf:errorMessage(wf:lastErrorNode())}]</message> 1
name="end" 1
name="fail"> 1
name="mapreduce-node"> 1
name="params-in-mapred"> 1
params.in.test-->conf_set 1
params.in.test2-->conf_set 1
path="${paramsOutPath}" 1
to="end" 1
如果-D起到作用的话,那么”params.in.test2-->conf_set 1“应该是“params.in.test2-->D_set 1”求大神看看是哪里出问题了?
|
|