using-update选项

1l5u6lss  于 2021-05-27  发布在  Hadoop
关注(0)|答案(1)|浏览(391)

我的目标是在java中使用javadistcpapi。
使用命令行,我可以执行distcp:

hadoop --config /path/to/cluster2/hadoop/conf distcp -skipcrccheck -update hdfs://clusterHA1/path/to/file hdfs://clusterHA2/path/to/target

在java中,使用-skipcrccheck和-update选项会遇到一些问题。

final DistCpOptions distcpOption = new DistCpOptions(sourceFile, destFile);
distcpOption.setSkipCRC(true);
distcpOption.setSyncFolder(true);
runExitCode = this.distCpRun(sourceFile, destFile, distcpOption);

我有个例外:

java.lang.IllegalArgumentException: Skip CRC is valid only with update options

当您查看代码时,顺序非常重要,因此我切换两个选项:

final DistCpOptions distcpOption = new DistCpOptions(sourceFile, destFile);
distcpOption.setSyncFolder(true);
distcpOption.setSkipCRC(true);
runExitCode = this.distCpRun(sourceFile, destFile, distcpOption);

我得到:

java.io.IOException: Check-sum mismatch between source and target

我很确定setsyncfolder在distcpoption中设置了update选项:

public enum DistCpOptionSwitch {
SYNC_FOLDERS("distcp.sync.folders", new Option("update", false, "Update target, copying only missingfiles or directories")),
}

我使用的是hadoop2.6.4,两个集群之间不匹配,因为每个集群都有自己的rangerkms示例。我将文件从未加密区域发送到加密区域,这在命令行中运行良好。

643ylb08

643ylb081#

我最终通过将参数传递给main函数而不是使用distcpoptionbuilder来解决这个问题。

distCp.run(new String[] {"-skipcrccheck", "-update",source, destination });

相关问题