
注1
drwxr-xr-x - hadoop supergroup 0 2019-01-28 22:57 /henryData
因为指定用户为hadoop
源代码解释1
public FSDataOutputStream create(Path f) throws IOException {
return this.create(f, true);
}
返回了一个FSDataOutputStream
一个输出流
代码1
out.writeUTF("first of first");
out.writeUTF("second of second");
out.flush();
out.close();
error1
此时发生了一个错误
本人发现之前在创建
uri = new URI("hdfs://外网ip:9000");
但是浏览器访问50070端口后发现
datanode使用内网ip注册的
所以解决方法是
现在本地host文件配置外网ip与远程主机hostname的映射
然后添加
configuration.set("dfs.client.use.datanode.hostname", "true");
此时可以看到HDFS上文件显示如下
first of firstsecond of second
源代码2
public RemoteIterator<LocatedFileStatus> listFiles(final Path f, final boolean recursive
网友评论