一段时间内出现网络问题时,客户端与远程 Hbase 服务器的连接

Client connection with remote Hbase server in case of network issue for some time

我正在使用 Table 接口接口 ( https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Table.html ) and using connection interface ( https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Connection.html ) 来获取 Table 对象。但是正如Connection接口中提到的link,"连接创建是一个重量级的操作。连接的实现是线程安全的,这样客户端可以创建一次连接,并与不同的线程共享.”。

因此,如果我为所有线程创建单个连接对象(在静态块中创建此对象),那么如果出现网络问题并且客户端与 hbase 集群失去连接一段时间会发生什么情况。之后 Connection 对象还会工作吗?

如果连接丢失并在某个特定时间段(TCP 超时)再次连接,一切都会正常。

因为客户端和hbase之间建立了TCP连接。同样如文档中所述,"The individual connections to servers, meta cache, zookeeper connection, etc are all shared by the Table and Admin instances obtained from this connection",如果我们在网络无法访问时发送数据,数据将出现在缓冲区中,客户端将尝试重新传输该段的一部分,hbase 将在网络恢复时获取它。

但是如果网络在一定时间之前无法访问(TCP 超时),那么 TCP 最终会放弃并关闭 socket.For 这种情况你必须放置一些 catch 块来处理这个或者需要重新启动罐子。