我正在从groovy脚本执行以下hadoop文件系统shell命令,以将hive生成的文件移动到hdfs。
targetFolderPath="/data/app/2016/06/30/"
srcFile=["/apps/hive/warehouse/customer_input.db/customer/year=2016/month=06/day=30/000000_0.txt.bz2"....]
dst="/data/app/2016/06/30/customer_20160630_201707151297.txt.bz2"
make_dir = " hdfs dfs -mkdir -p ${targetFolderPath} ".execute()
copy_file = " hdfs dfs -cp ${srcFile} ${dst} ".execute()
println ( " created folder ${targetFolderPath} and copied file ${srcFile} as ${dst} " )
此命令在循环中运行。我没有得到任何错误,但是行为很明显
第一个循环始终正确
在第二个循环中创建文件夹但不复制文件。
在第三个循环中,既不创建文件夹也不复制文件。
在后续循环中,不会创建任何文件夹或文件,
有时复制文件具有.__复制扩展名
从groovy调用此命令可能有什么问题? groovy不适合在hdfs上执行命令字符串吗?
答案 0 :(得分:1)
认为您需要等待流程完成
在所有.waitForProcessOutput()
来电之后添加.execute()