如何获得DistributedFileSystem?
问题描述:
我下面一些例子来尝试使用以下,以获得DistributedFileSystem,但是我发现下面的返回废弃的错误如何获得DistributedFileSystem?
FileSystem fs=FileSystem.get(conf);
DistributedFileSystem hdfs = (DistributedFileSystem) fs;
异常在线程“主要” java.lang.ClassCastException: org.apache .hadoop.fs.LocalFileSystem不能在 在 Hadoop.Driver.main(Driver.java:8)投射到 org.apache.hadoop.hdfs.DistributedFileSystem在 Hadoop.File.infoNode(File.java:55) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invok E(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:498)
如何解决这个问题?
答
这不是贬值错误
LocalFileSystem无法施展
你conf
对象需要被初始化为fs.defaultFS
,随着hdfs://
代替file://
退房的开始您的HADOOP_CONF_DIR
中的core-site.xml文件设置属性