You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ec...@apache.org on 2015/10/05 18:35:45 UTC
hbase git commit: HBASE-14544 Allow HConnectionImpl to not refresh
the dns on errors
Repository: hbase
Updated Branches:
refs/heads/master b014ba124 -> ceafa09d3
HBASE-14544 Allow HConnectionImpl to not refresh the dns on errors
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/ceafa09d
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/ceafa09d
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/ceafa09d
Branch: refs/heads/master
Commit: ceafa09d3cf6102d21c66745ca80e132021890c9
Parents: b014ba1
Author: Elliott Clark <ec...@apache.org>
Authored: Fri Oct 2 14:39:43 2015 -0700
Committer: Elliott Clark <ec...@apache.org>
Committed: Mon Oct 5 09:35:40 2015 -0700
----------------------------------------------------------------------
.../hbase/client/ConnectionImplementation.java | 23 ++++++++++++++------
1 file changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/ceafa09d/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
index e72d964..fbb77dc 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
@@ -110,7 +110,9 @@ class ConnectionImplementation implements ClusterConnection, Closeable {
public static final String RETRIES_BY_SERVER_KEY = "hbase.client.retries.by.server";
private static final Log LOG = LogFactory.getLog(ConnectionImplementation.class);
private static final String CLIENT_NONCES_ENABLED_KEY = "hbase.client.nonces.enabled";
+ private static final String RESOLVE_HOSTNAME_ON_FAIL_KEY = "hbase.resolve.hostnames.on.failure";
+ private final boolean hostnamesCanChange;
private final long pause;
private final boolean useMetaReplicas;
private final int numTries;
@@ -220,6 +222,7 @@ class ConnectionImplementation implements ClusterConnection, Closeable {
boolean shouldListen = conf.getBoolean(HConstants.STATUS_PUBLISHED,
HConstants.STATUS_PUBLISHED_DEFAULT);
+ this.hostnamesCanChange = conf.getBoolean(RESOLVE_HOSTNAME_ON_FAIL_KEY, true);
Class<? extends ClusterStatusListener.Listener> listenerClass =
conf.getClass(ClusterStatusListener.STATUS_LISTENER_CLASS,
ClusterStatusListener.DEFAULT_STATUS_LISTENER_CLASS,
@@ -1194,7 +1197,8 @@ class ConnectionImplementation implements ClusterConnection, Closeable {
throw new MasterNotRunningException(sn + " is dead.");
}
// Use the security info interface name as our stub key
- String key = getStubKey(getServiceName(), sn.getHostname(), sn.getPort());
+ String key = getStubKey(getServiceName(),
+ sn.getHostname(), sn.getPort(), hostnamesCanChange);
connectionLock.putIfAbsent(key, key);
Object stub = null;
synchronized (connectionLock.get(key)) {
@@ -1283,7 +1287,7 @@ class ConnectionImplementation implements ClusterConnection, Closeable {
throw new RegionServerStoppedException(serverName + " is dead.");
}
String key = getStubKey(AdminProtos.AdminService.BlockingInterface.class.getName(),
- serverName.getHostname(), serverName.getPort());
+ serverName.getHostname(), serverName.getPort(), this.hostnamesCanChange);
this.connectionLock.putIfAbsent(key, key);
AdminProtos.AdminService.BlockingInterface stub = null;
synchronized (this.connectionLock.get(key)) {
@@ -1306,7 +1310,7 @@ class ConnectionImplementation implements ClusterConnection, Closeable {
}
String key = getStubKey(
ClientProtos.ClientService.BlockingInterface.class.getName(), sn.getHostname(),
- sn.getPort());
+ sn.getPort(), this.hostnamesCanChange);
this.connectionLock.putIfAbsent(key, key);
ClientProtos.ClientService.BlockingInterface stub = null;
synchronized (this.connectionLock.get(key)) {
@@ -1323,16 +1327,21 @@ class ConnectionImplementation implements ClusterConnection, Closeable {
return stub;
}
- static String getStubKey(final String serviceName, final String rsHostname, int port) {
+ static String getStubKey(final String serviceName,
+ final String rsHostname,
+ int port,
+ boolean resolveHostnames) {
// Sometimes, servers go down and they come back up with the same hostname but a different
// IP address. Force a resolution of the rsHostname by trying to instantiate an
// InetSocketAddress, and this way we will rightfully get a new stubKey.
// Also, include the hostname in the key so as to take care of those cases where the
// DNS name is different but IP address remains the same.
- InetAddress i = new InetSocketAddress(rsHostname, port).getAddress();
String address = rsHostname;
- if (i != null) {
- address = i.getHostAddress() + "-" + rsHostname;
+ if (resolveHostnames) {
+ InetAddress i = new InetSocketAddress(rsHostname, port).getAddress();
+ if (i != null) {
+ address = i.getHostAddress() + "-" + rsHostname;
+ }
}
return serviceName + "@" + address + ":" + port;
}