Hadoop instance RandomWriter

Source: Internet
Author: User
The RandomWriter (random write) example uses MapReduce to randomly write data to dfs. Input a single file name for each map, and then randomly write the keys and values of BytesWritable to the DFS Sequence File. Map does not produce any output, so reduce is not executed. The generated data can be configured. The configuration variable is named below. The default value is test. rando.

The RandomWriter (random write) example uses Map/REdUce writes data randomlyDfS. Input a single file name for each map, and then randomly write the keys and values of BytesWritable to the DFS Sequence File. Map does not produce any output, so reDuCe is not executed. The generated data can be configured. The configuration variables are as follows:

Name Default Value Description

Test. randomWriteR. maps_per_host

10 Number of maps/host

Test. randomwrite. bytes_per_map

1073741824 Number of bytes written/map

Test. randomwrite. min_key

10 Minimum size of the key in bytes

Test. randomwrite. max_key

1000 Maximum size of the key in bytes

Test. randomwrite. min_value

0 Minimum size of the value

Test. randomwrite. max_value

20000 Maximum size of the value

Test. randomwriter. maps_per_host indicates the number of times map is run on each slave node.By default, there is only one data node, so there are 10 maps, each map has 1 GB of data, so 10 Gb of data needs to be written to hdfs. However, I configured only two slave nodes in the test environment, so there are two maps.

Test. randomwrite. bytes_per_map I originally thought it was the size of the random write output test file. The default value is 1G = 1*1024*1024*1024, but after I change this data to 1*1024*1024, the output test file is still 1 GB, which makes me very puzzled.(?)

Code instance

Test. randomwrite. bytes_per_map = 1*1024*1024, test. randomwriter. maps_per_host = 1.

  1. /** 
  2. * LicenSedTo the Apache Software Foundation (ASF) under one 
  3. * OrMoreConTrIbutor license agreements. See the NOTICEFile 
  4. * Distributed with this work forDdItional infoRmAtion 
  5. * Regarding copyright ownership. The ASF licenses this file 
  6. * To you under the Apache License, Version 2.0 ( 
  7. * \ "License \"); you may not use this fileExCept in compliaNcE 
  8. * With the License. You may obtain a copy of the License 
  9. * 
  10. * Http://www.apache.org/licenses/LICENSE-2.0 
  11. * 
  12. * UnLessRequired by applicable law or agreed to in writing, software 
  13. * Distributed under the License is distributed on an \ "as is \" BASIS, 
  14. * Without warranties or conditions of any kind, eitherExprEss or implied. 
  15. * See the License for the specific language governing permissions and 
  16. * Limitations under the License. 
  17. */
  18. Package org. apache. hadoop. examples;
  19. Import java. io. IOException;
  20. Import java. util. Date;
  21. Import java. util. Random;

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.