由于waitForCompletion(Boolean xxx)方法的文档说明了
Job上的waitForCompletion()方法提交作业并等待它完成。该方法的单个参数是一个标志,指示是否生成详细输出。如果为true,则作业会将有关其进度的信息写入控制台。
在接下来的练习中,我将这个单一论点设置为真。但仍然没有在控制台上打印详细的输出。 这是我的代码:
public class MaxTemperature extends Configured implements Tool {
public static void main(String[] args) throws Exception {
int exitCode = ToolRunner.run(new MaxTemperature(), args);
System.exit(exitCode);
}
@Override
public int run(String[] args) throws Exception {
if (args.length != 2) {
System.err.println("Usage: MaxTemperature <input path> <output path>");
System.exit(-1);
}
System.out.println("Starting job");
Job job = new Job();
job.setJarByClass(MaxTemperature.class);
job.setJobName("Max temperature");
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
job.setMapperClass(MaxTemperatureMapper.class);
job.setReducerClass(MaxTemperatureReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
int returnValue = job.waitForCompletion(true) ? 0:1;
if(job.isSuccessful()) {
System.out.println("Job was successful");
} else if(!job.isSuccessful()) {
System.out.println("Job was not successful");
}
return returnValue;
}
}
这是控制台:
Starting job
Job was successful
这是我在资源文件夹中的log4j.properties文件:
log4j.rootLogger=DEBUG, CA
log4j.appender.CA=org.apache.log4j.ConsoleAppender
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
log4j.appender.CA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
有任何建议,为什么有关工作进度和细节的信息没有打印出来?