0

我的代码中有这一行:

DistributedFileSystem.get(conf).delete(new Path(new URI(otherArgs[1])), true);    

otherArgs[1]有这个值:hdfs://master:54310/input/results

我收到此异常:

Exception in thread "main" java.lang.IllegalArgumentException: Wrong FS:hdfs://master:54310/input/results, expected: file:///
at org.apache.hadoop.fs.FileSystem.checkPath(FileSystem.java:354)
at org.apache.hadoop.fs.RawLocalFileSystem.pathToFile(RawLocalFileSystem.java:55)
at org.apache.hadoop.fs.RawLocalFileSystem.getFileStatus(RawLocalFileSystem.java:367)
at org.apache.hadoop.fs.ChecksumFileSystem.delete(ChecksumFileSystem.java:430)
at <package>.<classname>.main(Degree.java:137)    

注意:我尝试在new Path(otherArgs[1])没有 URI 的情况下使用,但得到了完全相同的错误!

谢谢,-K

4

2 回答 2

0

看起来您尚未在 core-site.xml 中设置fs.default.name 。

检查这个链接

如果您已经设置,请确保配置文件在类路径中

您还可以从驱动程序中设置 fs.default.name 属性

conf.set("fs.default.name", "hdfs://yourserver:port");
于 2014-10-14T05:31:22.193 回答
0

事实证明,我使用“hadoop -jar”而不是“hadoop jar”运行我的 jar。所有 conf 文件都正确且到位。

问题解决了,但我仍然不知道为什么使用“-jar”让它作为本地(伪分布式)运行!

于 2014-10-15T02:14:09.137 回答