代码拉取完成,页面将自动刷新
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;
public class NameService_Load {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Configuration configuration=new Configuration();
configuration.set("dfs.nameservices","ns1");
configuration.set("dfs.ha.namenodes.ns1", "nn1,nn2");
configuration.set("dfs.namenode.rpc-address.ns1.nn1", "hadoop01:9000");
configuration.set("dfs.namenode.rpc-address.ns1.nn2", "hadoop02:9000");
configuration.set("dfs.client.failover.proxy.provider.ns1",
"org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider");
FileSystem fs =FileSystem.get(new URI("hdfs://ns1"), configuration);
InputStream in=fs.open(new Path("/words"));
OutputStream out=new FileOutputStream(new File("f://asd.txt"));
IOUtils.copyBytes(in, out, 4096, true);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。