Java Distributedfilesystem类使用本地类而不是分布式类
我的代码中有这一行:Java Distributedfilesystem类使用本地类而不是分布式类,java,hadoop,distributed-filesystem,Java,Hadoop,Distributed Filesystem,我的代码中有这一行: 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/in
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)
线程“main”java.lang.IllegalArgumentException中的异常:错误的FS:hdfs://master:54310/input/results,应为:文件:///
位于org.apache.hadoop.fs.FileSystem.checkPath(FileSystem.java:354)
位于org.apache.hadoop.fs.RawLocalFileSystem.pathToFile(RawLocalFileSystem.java:55)
位于org.apache.hadoop.fs.RawLocalFileSystem.getFileStatus(RawLocalFileSystem.java:367)
位于org.apache.hadoop.fs.ChecksumFileSystem.delete(ChecksumFileSystem.java:430)
at..main(Degree.java:137)
注意:我尝试在没有URI的情况下使用新路径(otherArgs[1])
,但得到了完全相同的错误
谢谢,
-K看起来您没有在core-site.xml中设置fs.default.name 检查这个 如果已经设置了,请确保配置文件位于类路径中 您还可以从驱动程序中设置fs.default.name属性
conf.set("fs.default.name", "hdfs://yourserver:port");
事实证明,我是用“hadoop-jar”而不是“hadoop-jar”来运行我的jar的。所有conf文件都正确且到位 问题解决了,但我仍然不知道为什么使用“-jar”使它作为本地(伪分布式)运行