Today, I used the hadoop API to create several files for the hadoop cluster and try to write data. As a result, the number of backup files in my configuration file is 1, but no matter how I create it, the number of file backups created is three. The Code is as follows:
public static void testHDFS() throws IOException{String str="hdfs://cloudgis4:9000/usr/tmp/";Path path=new Path(str);Configuration conf=new Configuration();FileSystem hdfs=path.getFileSystem(conf);long begin=System.currentTimeMillis();for(int i=0;i<10000;i++){byte [] kkk=new byte[10000+1*i];FSDataOutputStream fsDataOut=hdfs.create(new Path(str+i));fsDataOut.write(kkk);fsDataOut.close();//hdfs.close();}long end=System.currentTimeMillis();System.out.println("hdfs:"+(end-begin));}
It's strange that I searched the internet and found this API: setreplication. After this is used, the number of file backups created is 3. After searching this API, we found that this API can only change the number of backups of existing files. If you create and modify the backup, the framework will undoubtedly become more affordable. Later I thought about how to change the configuration file to 1, so the application did not read the configuration file. Therefore, you can manually read the configuration file.
Conf. addresource (New Path ("/usr/local/hadoop/CONF/hdfs-site.xml "));
PS: The hbase authoritative guide provides the following sentence:
If you are using ing an IDE to run an hbase client, you coshould include the conf/
Directory on your classpath. That wocould make the configuration files discoverable
The client code.