hdfs 常见的获取文件系统代码,如下
Configuration conf = new Configuration();
FileSystem fs;
fs = FileSystem.get(conf);
fs 最终指向的是FileSystem哪个子类呢,过程是怎么样的,
逐步跳进代码一看
public static FileSystem get(Configuration conf) throws IOException {
return get(getDefaultUri(conf), conf);
}
再点进去
public static FileSystem get(URI uri, Configuration conf) throws IOException {
String scheme = uri.getScheme();
String authority = uri.getAuthority();
//如果均为空,使用默认的本地文件存储系统
if (scheme == null && authority == null) { // use default FS
return get(conf);
}
if (scheme != null && authority == null) { // no a