繁体   English   中英

如何设置创建HBase连接的时间限制

[英]How to set time limit for creating HBase connection

我目前正在使用HBase v0.98.6。 我想检查外部Java程序的当前连接状态。 现在,我正在执行以下检查:

connectionSuccess = true;
try {
     HConnection hConnection = createConnection(config);
} catch (Exception ex) {
     connectionSuccess = false;
}

连接正常时,这将很快返回。 问题是当连接不起作用时,它需要20分钟才能最终返回connectionSuccess=false 有什么办法可以减少此时间限制,因为我只是想了解当前时间的连接状态?

之所以需要这么长的时间,是因为默认情况下,如果连接失败,它将多次重试(我认为6?请不要引用我),并且每次连接尝试都需要一段时间。 尝试结合使用这些命令来限制每个连接在超时之前的时间以及允许的重试次数。

hbase.client.retries.number = 3
hbase.client.pause = 1000
zookeeper.recovery.retry = 1(即不重试)

来自http://hadoop-hbase.blogspot.com/2012/09/hbase-client-timeouts.html的 Lars

我的org.apache.hadoop.conf.Configuration对象包含以下键值对:

Configuration conf = HBaseConfiguration.create();

//configuring timeout and retry parameters
conf.set("hbase.rpc.timeout", "10000");
conf.set("hbase.client.scanner.timeout.period", "10000");
conf.set("hbase.cells.scanned.per.heartbeat.check", "10000");
conf.set("zookeeper.session.timeout", "10000");
conf.set("phoenix.query.timeoutMs", "10000");
conf.set("phoenix.query.keepAliveMs", "10000");
conf.set("hbase.client.retries.number", "3");
conf.set("hbase.client.pause", "1000");
conf.set("zookeeper.recovery.retry", "1");

您可以将重试值设置为1,以获取当前时间的连接状态。

Configuration conf = HBaseConfiguration.create();
conf.setInt("hbase.client.retries.number",1);
conf.setInt("zookeeper.recovery.retry",0);

或者,您可以使用下面的内置HbaseAdmin方法执行相同的操作。

connectionSuccess = true;
try
{
  HBaseAdmin.checkHBaseAvailable(config);
}
catch(MasterNotRunningException e)
{
  connectionSuccess = false;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM