我们知道,新的需要将所有需要的类打包到job-jar中并将其上传到服务器。它是如此之慢,我将知道是否有一种方法可以指定第三方jar包括执行map-red job,这样我就只能打包我的类而不依赖它们。
PS(我发现有一个“-libjar”命令,但我不知道如何使用它。这是链接http://blog.cloudera.com/blog/2011/01/how-to-include-third-party-libraries-in-your-map-reduce-job/)
答案 0 :(得分:3)
这些被称为generic options。 所以,为了支持这些,你的工作应该实现工具。
像 -
一样运行你的工作hadoop jar yourfile.jar [mainClass] args -libjars <comma seperated list of jars>
编辑:
要实施工具并扩展已配置,您可以在MapReduce应用程序中执行以下操作 -
public class YourClass extends Configured implements Tool {
public static void main(String[] args) throws Exception {
int res = ToolRunner.run(new YourClass(), args);
System.exit(res);
}
public int run(String[] args) throws Exception
{
//parse you normal arguments here.
Configuration conf = getConf();
Job job = new Job(conf, "Name of job");
//set the class names etc
//set the output data type classes etc
//to accept the hdfs input and outpur dir at run time
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
return job.waitForCompletion(true) ? 0 : 1;
}
}
答案 1 :(得分:0)
对我来说,我必须在参数之前指定-libjar选项。否则它被认为是一个论点。