How to Build Rowkey for RS resizing performance verification of HBase Clusters

Source: Internet
Author: User

After the RegionServer node is expanded, You need to migrate some of the original Region to the new RegionServer to enable Load Balancing for each RegionServer.

To improve the HBase write performance after one node is added, You need to evenly distribute the RowKey in the List to all existing Region databases during each put operation, to achieve the concurrent processing of all regionservers.

The following code is the meta Code Constructed by the uniform RowKey:

Import java. util. ArrayList;
Import java. util. List;


Public class externTest {

Public static long TOTAL_NUMS = 145;
Public static int REGION_NUMS = 24;
Public static long EACH_PUT_NUMS = 48;

Public static void buildString (){
Int addition = 0;
String str = null;
List <String> list = new ArrayList <String> ();
Long curNum = 0;

Long putNums = TOTAL_NUMS/EACH_PUT_NUMS; // usually equal to the total number of put-1;
Long loopsInOnePut = EACH_PUT_NUMS/REGION_NUMS; // Number of inner loops required for a put operation, that is, the number of automatically incrementing curNum

// Process
For (long k = 0; k <putNums; k ++ ){
For (long I = 0; I <loopsInOnePut; I ++ ){
For (int j = 0; j <REGION_NUMS; j ++ ){
// The A-Z uses the same value
Addition = j % REGION_NUMS;
Str = num2ABC (addition );
// Construct the record string
System. out. println (str + curNum );
List. add (str );
}
CurNum ++; // The current ending number + 1 after a loop
}
// TODO: Execute put once
System. out. println ("put ");
List. clear ();
}

// The number outside the processing cycle must be smaller than EACH_PUT_NUMS. The last put Operation
Long lastNums = TOTAL_NUMS % EACH_PUT_NUMS; // how many records are left to put
Long lastloops = lastNums/REGION_NUMS; // The number of curNum auto-increment entries
Long numPlus = lastNums % REGION_NUMS; // The number of additional records
For (long I = 0; I <lastloops; I ++ ){
For (int j = 0; j <REGION_NUMS; j ++ ){
// The A-Z uses the same value
Addition = j % REGION_NUMS;
Str = num2ABC (addition );
// Construct the record string
System. out. println (str + curNum );
List. add (str );
}
CurNum ++; // The current ending number + 1 after a loop
}
// Remove out of Loop
For (int j = 0; j <numPlus; j ++ ){
// The A-Z uses the same value
Addition = j % REGION_NUMS;
Str = num2ABC (addition );
// Construct the record string
System. out. println (str + curNum );
List. add (str );
}
// TODO: Execute put once
System. out. println ("put ");
List. clear ();

Return;
}
 
Public static String num2ABC (int num ){
String str = null;
Switch (num ){
Case 0:
Str = new String ("");
Break;
Case 1:
Str = new String ("B ");
Break;
Case 2:
Str = new String ("C ");
Break;
Case 3:
Str = new String ("D ");
Break;
Case 4:
Str = new String ("E ");
Break;
Case 5:
Str = new String ("F ");
Break;
Case 6:
Str = new String ("G ");
Break;
Case 7:
Str = new String ("H ");
Break;
Case 8:
Str = new String ("I ");
Break;
Case 9:
Str = new String ("J ");
Break;
Case 10:
Str = new String ("K ");
Break;
Case 11:
Str = new String ("L ");
Break;
Case 12:
Str = new String ("M ");
Break;
Case 13:
Str = new String ("N ");
Break;
Case 14:
Str = new String ("O ");
Break;
Case 15:
Str = new String ("P ");
Break;
Case 16:
Str = new String ("Q ");
Break;
Case 17:
Str = new String ("R ");
Break;
Case 18:
Str = new String ("S ");
Break;
Case 19:
Str = new String ("T ");
Break;
Case 20:
Str = new String ("U ");
Break;
Case 21:
Str = new String ("V ");
Break;
Case 22:
Str = new String ("W ");
Break;
Case 23:
Str = new String ("X ");
Break;
Default:
Str = new String ("Z ");
Break;
}
Return str;
}
 
/**
* @ Param args
*/
Public static void main (String [] args ){
System. out. println ("Test my Java! ");

BuildString ();
}
}

Related Article

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.