No FileSystem for scheme: hdfs问题


通过FileSystem.get(conf)初始化的时候,要通过静态加载来实现,其加载类的方法代码如下:

private static FileSystem createFileSystem(URI uri, Configuration conf
      ) throws IOException {
    Class<?> clazz = conf.getClass("fs." + uri.getScheme() + ".impl", null); 
    if (clazz == null) {
      throw new IOException("No FileSystem for scheme: " + uri.getScheme());
    }
    FileSystem fs = (FileSystem)ReflectionUtils.newInstance(clazz, conf);
    fs.initialize(uri, conf);
    return fs;
  }

onf.getClass需要读取hadoop-common-x.jar下面的core-default.xml,但是这个xml里面没有fs.hdfs.impl的配置信息,所以需要将这个类给配置上去。

将hadoop-commom-x.jar里面的core-default.xml文件取出并修改,添加如下代码:

<property>
<name>fs.hdfs.impl</name>
<value>org.apache.hadoop.hdfs.DistributedFileSystem</value>
<description>The FileSystem for hdfs: uris.</description>
</property>

或者应用代码使用时候,自行添加:

configuration.set("fs.hdfs.impl", "org.apache.hadoop.hdfs.DistributedFileSystem");

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM