您现在的位置是:主页 > news > 大连网站建设选高合科技/谷歌下载官网

大连网站建设选高合科技/谷歌下载官网

admin2025/6/18 6:13:24news

简介大连网站建设选高合科技,谷歌下载官网,外贸网站建设模式,泉州网站设计我正在尝试连接到HBase时处理故障情况.目前,我检查HBase是否与HBaseAdmin.checkHBaseAvailable(conf);一起运行.但是这个api只会在大约40秒之后抛出MasterNotRunning或ZookeeperConnectionException的异常.所以,我尝试设置以下重试,hbase.client.retries.number 1和zookeeper.…

大连网站建设选高合科技,谷歌下载官网,外贸网站建设模式,泉州网站设计我正在尝试连接到HBase时处理故障情况.目前,我检查HBase是否与HBaseAdmin.checkHBaseAvailable(conf);一起运行.但是这个api只会在大约40秒之后抛出MasterNotRunning或ZookeeperConnectionException的异常.所以,我尝试设置以下重试,hbase.client.retries.number 1和zookeeper.…

我正在尝试连接到HBase时处理故障情况.目前,我检查HBase是否与HBaseAdmin.checkHBaseAvailable(conf);一起运行.但是这个api只会在大约40秒之后抛出MasterNotRunning或ZookeeperConnectionException的异常.所以,我尝试设置以下重试,hbase.client.retries.number = 1和zookeeper.recovery.retry = 1.这让我在6-7秒内处理异常.但是,我需要一种更快速的方法来了解HBase集群是否正在运行,因为我正在我的应用程序中的同步调用中登录到HBase.

解决方法:

以这种方式检查连接怎么样:

import java.net.InetSocketAddress;

import org.apache.hadoop.hbase.ipc.HBaseRPC;

import org.apache.hadoop.hbase.ipc.HMasterInterface;

import org.apache.hadoop.hbase.ipc.RpcEngine;

...

public static boolean isRunning() {

boolean result = false;

Configuration conf = HBaseConfiguration.create();

conf.clear();

conf.set("hbase.zookeeper.quorum", "myhost");

conf.set("hbase.zookeeper.property.clientPort", "2181");

conf.set("hbase.master", "myhost:60000");

RpcEngine rpcEngine = null;

try {

InetSocketAddress isa = new InetSocketAddress("myhost", 60000);

rpcEngine = HBaseRPC.getProtocolEngine(conf);

HMasterInterface master = rpcEngine.getProxy(HMasterInterface.class,

HMasterInterface.VERSION, isa, conf, 1000);

result = master.isMasterRunning();

}

catch (Exception e) {

// ...

}

finally {

if (rpcEngine != null) {

rpcEngine.close();

}

}

return result;

}

注意:我在这里假设版本> = 0.94.5

标签:java,exception-handling,error-handling,hbase

来源: https://codeday.me/bug/20190629/1325347.html