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);
}
}