The number of backup files written by hadoop APIs

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.