HBASE-25292 Improve InetSocketAddress usage discipline (#2669)
commit679dd7b8f906b58d709200a48c38c41873fa5fc2
authorAndrew Purtell <apurtell@apache.org>
Sat, 28 Nov 2020 13:01:22 +0000 (28 05:01 -0800)
committerGitHub <noreply@github.com>
Sat, 28 Nov 2020 13:01:22 +0000 (28 21:01 +0800)
tree42584d7aceb29325994ecb23b21aebd0815f7bff
parente6165412e0ccbcfd056897e77948048220051337
HBASE-25292 Improve InetSocketAddress usage discipline (#2669)

Network identities should be bound late. Remote addresses should be
resolved at the last possible moment, just before connect(). Network
identity mappings can change, so our code should not inappropriately
cache them. Otherwise we might miss a change and fail to operate normally.

Revert "HBASE-14544 Allow HConnectionImpl to not refresh the dns on errors"
Removes hbase.resolve.hostnames.on.failure and related code. We always
resolve hostnames, as late as possible.

Preserve InetSocketAddress caching per RPC connection. Avoids potential
lookups per Call.

Replace InetSocketAddress with Address where used as a map key. If we want
to key by hostname and/or resolved address we should be explicit about it.
Using Address chooses mapping by hostname and port only.

Add metrics for potential nameservice resolution attempts, whenever an
InetSocketAddress is instantiated for connect; and metrics for failed
resolution, whenever InetSocketAddress#isUnresolved on the new instance
is true.

* Use ServerName directly to build a stub key

* Resolve and cache ISA on a RpcChannel as late as possible, at first call

* Remove now invalid unit test TestCIBadHostname

We resolve DNS at the latest possible time, at first call, and do not
resolve hostnames for creating stubs at all, so this unit test cannot
work now.

Reviewed-by: Mingliang Liu <liuml07@apache.org>
Signed-off-by: Duo Zhang <zhangduo@apache.org>
24 files changed:
hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java
hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetricsConnection.java
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/AbstractRpcClient.java
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/BlockingRpcConnection.java
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/ConnectionId.java
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/FailedServers.java
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcConnection.java
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcClient.java
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcConnection.java
hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/ServerTooBusyException.java
hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestMasterRegistryHedgedReads.java
hbase-client/src/test/java/org/apache/hadoop/hbase/ipc/TestConnectionId.java
hbase-client/src/test/java/org/apache/hadoop/hbase/ipc/TestFailedServersLog.java
hbase-client/src/test/java/org/apache/hadoop/hbase/ipc/TestIPCUtil.java
hbase-client/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyRpcConnection.java
hbase-common/src/main/java/org/apache/hadoop/hbase/net/Address.java
hbase-external-blockcache/src/main/java/org/apache/hadoop/hbase/io/hfile/MemcachedBlockCache.java
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestCIBadHostname.java [deleted file]
hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientTimeouts.java
hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestHBaseClient.java
hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java