如何重新覆盖/重用Hadoop作业的现有输出路径并重新使用 [英] How to overwrite/reuse the existing output path for Hadoop jobs again and agian

查看:257
本文介绍了如何重新覆盖/重用Hadoop作业的现有输出路径并重新使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我每天运行我的Hadoop作业时,我想覆盖/重用现有的输出目录。
实际上,输出目录将存储每天作业运行结果的汇总输出。
如果我指定了相同的输出目录,它会给出错误输出目录已存在。



如何绕过此验证?

解决方案

在运行作业之前删除目录怎么样?



你可以通过shell :

  hadoop fs -rmr / path / to / your / output / 

或通过Java API:

  //配置应该包含对你的namenode的引用
FileSystem fs = FileSystem.get(new Configuration());
// true表示递归删除你给出的文件夹
fs.delete(new Path(/ path / to / your / output),true);


I want to overwrite/reuse the existing output directory when I run my Hadoop job daily. Actually the output directory will store summarized output of each day's job run results. If I specify the same output directory it gives the error "output directory already exists".

How to bypass this validation?

解决方案

What about deleting the directory before you run the job?

You can do this via shell:

hadoop fs -rmr /path/to/your/output/

or via the Java API:

// configuration should contain reference to your namenode
FileSystem fs = FileSystem.get(new Configuration());
// true stands for recursively deleting the folder you gave
fs.delete(new Path("/path/to/your/output"), true);

这篇关于如何重新覆盖/重用Hadoop作业的现有输出路径并重新使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆