perf(hbase): 优化 HBase 客户端配置以提高连接可靠性

- 添加 ZooKeeper端口配置,确保与 ZooKeeper 正确连接
- 设置客户端重试次数和 RPC 超时时间,提升临时连接问题的容错能力
This commit is contained in:
fly6516 2025-03-26 09:59:07 +08:00
parent 67a270aeaf
commit 5db4f7bca1

View File

@ -39,6 +39,12 @@ public class EmpHBaseClient {
public EmpHBaseClient() {
conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.quorum", "localhost");
// 新增ZooKeeper端口配置默认2181但显式声明更可靠
conf.set("hbase.zookeeper.property.clientPort", "2181");
// 新增重试策略配置解决临时连接问题
conf.set("hbase.client.retries.number", "3");
conf.set("hbase.rpc.timeout", "60000");
try {
connection = ConnectionFactory.createConnection(conf);
table = connection.getTable(TableName.valueOf("emp1520"));