我对HDFS Java API感到困惑,尤其是hadoop Configuration对我们在hadoop服务器上安装的配置的作用( /etc/hadoop/core-site.xml ,等)。
答案 0 :(得分:0)
示例:
public class HdfsTest {
//download file from hdfs
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
conf.set("fs.defaultFS", "hdfs://yourHadoopIP:9000/");
conf.set("dfs.blocksize", "64");
//to get a client of the hdfs system
FileSystem fs = FileSystem.get(conf);
fs.copyToLocalFile(new Path("hdfs://yourHadoopIP:9000/jdk-7u65-linux-i586.tar.gz"), new Path("/root/jdk.tgz"));
fs.close();
}
}