HBase-客户端-超时机制设置

背景

当用户有一些大请求的时候,会报超时,但是用户觉得请求慢一些也能接受,如何设置?

如果用户觉得HBase默认超时时间太长,希望请求超过一定毫秒数就报超时退出来,而不是一直在等待,如何设置?

入手

从网上搜索可以看到很多有关hbase客户端超时设置的参数说明

不过并不是非常详细

不过至少我们能定位到这几个参数,以进行入手

hbase.rpc.timeout

hbase.client.operation.timeout

hbase.client.scanner.timeout.period

HConstants是一个重要的类,几乎所有hbase的参数都在这里定义参数名和参数默认值

1.hbase.rpc.timeout

 

/**

 * timeout for each RPC

 */

public static final String HBASE_RPC_TIMEOUT_KEY = "hbase.rpc.timeout";

 

 

很多地方引用,先看命名最有可能的地方

RpcRetryingCallerFactory中的用法:

在newCaller中用到,看过HBase读写链路的话,应该知道比如HTable.get里面就用到了newCaller

RpcRetryingCaller

RpcRetryingCaller中具体执行rpc操作,看注释可以看到,rpc timeout是每次rpc的超时时间(一个操作可能会有多次rpc(重试机制HBase-客户端-重试机制))

rpc timeout在哪里被用到了

1.rpcClient里面是实际的io交互,在caller中set了rpc timeout的值

2.以及判断整个操作是否超时

3. 一个rpc多条操作的时候

2.hbase.client.operation.timeout

/** Parameter name for HBase client operation timeout. */

public static final String HBASE_CLIENT_OPERATION_TIMEOUT = "hbase.client.operation.timeout";

依然看调用位置

1.HBaseAdmin

2.TableCpmfiguration<--HTable

都是赋值给operationTimeout

应用:

HTable.get中caller用到

是callWithRetries方法的最后一个参数 (之前在rpc timeout也讲到这个方法)

从代码可以看到:

hbase.client.operation.timeout对应operationTimeout变量

1.只有在catch中才被用到,

2.而且是重试次数大于1的情况下

点击图片查看大图

发布了52 篇原创文章 · 获赞 4 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/Gloria_y/article/details/90082234