【发布时间】:2014-12-18 06:44:59
【问题描述】:
我在 HDFS 中有以下目录结构,
/analysis/alertData/logs/YEAR/MONTH/DATE/HOURS
也就是说,数据是按月来的,并以年/月/日/小时的格式存储。
我已经编写了一个 shell 脚本,我在其中传递路径直到
"/analysis/alertData/logs" ( this will vary depending on what product of data i am handling)
然后shell脚本遍历年/月/日/小时文件夹并返回最新的路径。
例如:
Directories present in HDFS has following structure:
/analysis/alertData/logs/2014/10/22/01
/analysis/alertData/logs/2013/5/14/04
shell script is given path till : " /analysis/alertData/logs "
it outputs most recent directory : /analysis/alertData/logs/2014/10/22/01
我的问题是如何验证传递给 shell 脚本的 HDFS 目录路径是否有效。假设我传递了错误的路径作为输入或不存在的路径,那么如何在 shell 脚本中处理它。
示例错误路径可以是:
wrong path : /analysis/alertData ( correct path : /analysis/alertData/logs/ )
wrong path : /abc/xyz/ ( path does not exit in HDFS )
我尝试使用 Hadoop dfs -test -z/-d/-e 选项对我不起作用。 对此有任何建议。
注意:不在这里发布我的原始代码,因为我的问题的解决方案不依赖于它。
提前致谢。
【问题讨论】:
标签: shell hadoop scripting hdfs