HBase集群RS扩容性能验证Rowkey构建方法
RegionServer节点扩展后,需要将一部分原有Region迁移到新的RegionServer中,使各RegionServer负载均衡。
RegionServer节点扩展后,需要将一部分原有Region迁移到新的RegionServer中,使各RegionServer负载均衡。
为了验证多了一个节点后的HBase的写性能提升,需要使每次put时List中的RowKey平均分配到现有的所有Region中,以达到使所有RegionServer并发处理的目的。
下面的代码是这种均匀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
long curNum = 0;
long putNums = TOTAL_NUMS/EACH_PUT_NUMS; //通常等于总put数-1;
long loopsInOnePut = EACH_PUT_NUMS/REGION_NUMS; //一次put所需的内层循环数,也即是curNum自增数
// 处理循环内的
for (long k = 0; k for (long i = 0; i for (int j = 0; j //A-Z使用同一个数值
addition = j % REGION_NUMS;
str = num2ABC(addition);
//构建本条记录字符串
System.out.println(str + curNum);
list.add(str);
}
curNum++; //一次循环后当前尾数+1
}
// TODO: 执行一次put
System.out.println("put");
list.clear();
}
// 处理循环外的,肯定小于EACH_PUT_NUMS,,最后一次put操作
long lastNums = TOTAL_NUMS % EACH_PUT_NUMS; //还剩多少记录要put
long lastloops = lastNums / REGION_NUMS; //curNum还要自增多少
long numPlus = lastNums % REGION_NUMS; //最后额外补充多少条记录
for (long i = 0; i for (int j = 0; j //A-Z使用同一个数值
addition = j % REGION_NUMS;
str = num2ABC(addition);
//构建本条记录字符串
System.out.println(str + curNum);
list.add(str);
}
curNum++; //一次循环后当前尾数+1
}
// 将循环外
for (int j = 0; j //A-Z使用同一个数值
addition = j % REGION_NUMS;
str = num2ABC(addition);
//构建本条记录字符串
System.out.println(str + curNum);
list.add(str);
}
// TODO: 执行一次put
System.out.println("put");
list.clear();
return;
}
public static String num2ABC(int num) {
String str = null;
switch (num) {
case 0:
str = new String("A");
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();
}
}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



With the advent of the big data era, data processing and storage have become more and more important, and how to efficiently manage and analyze large amounts of data has become a challenge for enterprises. Hadoop and HBase, two projects of the Apache Foundation, provide a solution for big data storage and analysis. This article will introduce how to use Hadoop and HBase in Beego for big data storage and query. 1. Introduction to Hadoop and HBase Hadoop is an open source distributed storage and computing system that can

Dependency: org.springframework.dataspring-data-hadoop-hbase2.5.0.RELEASEorg.apache.hbasehbase-client1.1.2org.springframework.dataspring-data-hadoop2.5.0.RELEASE The official way to add configuration is through xml, which is simple After rewriting, it is as follows: @ConfigurationpublicclassHBaseConfiguration{@Value("${hbase.zooke

How to use Java to develop a NoSQL database application based on HBase Introduction: With the advent of the big data era, NoSQL databases have become one of the important tools for processing massive data. HBase, as an open source distributed NoSQL database system, has extensive applications in the field of big data. This article will introduce how to use Java to develop NoSQL database applications based on HBase and provide specific code examples. 1. Introduction to HBase: HBase is a distribution system based on Hadoop.

With the advent of the big data era, the storage and processing of massive data has become particularly important. In terms of NoSQL databases, HBase is currently a widely used solution. As a statically strongly typed programming language, Go language is increasingly used in fields such as cloud computing, website development, and data science due to its simple syntax and excellent performance. This article will introduce how to use HBase in Go language to implement efficient NoSQL database applications. HBase introduction HBase is a highly scalable, highly reliable, basic

With the continuous growth of Internet applications and data volume, traditional relational databases can no longer meet the needs of storing and processing massive data. As a new type of database management system, NoSQL (NotOnlySQL) has significant advantages in massive data storage and processing, and has received more and more attention and applications. Among NoSQL databases, ApacheHBase is a very popular open source distributed database. It is designed based on Google’s BigTable idea and has

Using HBase for data storage and query in Beego framework With the continuous development of the Internet era, data storage and query have become more and more critical. With the advent of the big data era, various data sources occupy an important position in their respective fields. Non-relational databases are a database with obvious advantages in data storage and query, and HBase is a distributed non-relational database based on Hadoop. Relational Database. This article will introduce how to use HBase for data storage and query in the Beego framework. 1.H

Workerman is a high-performance PHPsocket framework that can host a large number of concurrent connections. Unlike traditional PHP frameworks, Workerman does not rely on web servers such as Apache or Nginx. Instead, it runs the entire application by itself by starting a PHP process. Workerman has extremely high operating efficiency and better load capacity. At the same time, HBase is a distributed NoSQL database system that is widely used in big data

HBase is a Hadoop-based distributed storage system designed to store and process large-scale structured data. In order to optimize its read and write performance, HBase provides a variety of caching mechanisms, which can improve query efficiency and reduce read and write delays through reasonable configuration. This article will introduce HBase caching technology and how to configure it. HBase cache types HBase provides two basic cache mechanisms: block cache (BlockCache) and MemStore cache (also called write cache). The block cache is in
