From 59955d1a5b5f7edbd9c80252f37b58b90b06f4a5 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Thu, 11 Mar 2010 20:07:06 +0000 Subject: [PATCH] HBASE-2174 Stop from resolving HRegionServer addresses to names using DNS on every heartbeat git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@922000 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 4 +++- .../main/java/org/apache/hadoop/hbase/HServerInfo.java | 9 ++++++++- .../apache/hadoop/hbase/master/ProcessRegionOpen.java | 2 +- .../hadoop/hbase/master/ProcessServerShutdown.java | 2 +- .../org/apache/hadoop/hbase/master/ServerManager.java | 6 +++--- .../org/apache/hadoop/hbase/regionserver/wal/HLog.java | 2 +- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 764b97ac03a..1adf21d90eb 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -416,7 +416,9 @@ Release 0.21.0 - Unreleased (Benoit Sigoure via JD) HBASE-2282 More directories should be ignored when using git for development (Alexey Kovyrin via Stack) - HBASE-2267 More improvements to the Maven build (Lars Francke via Stack) + HBASE-2267 More improvements to the Maven build (Lars Francke via Stack) + HBASE-2174 Stop from resolving HRegionServer addresses to names using DNS on + every heartbeat (Karthik Ranganathan via Stack) NEW FEATURES HBASE-1961 HBase EC2 scripts diff --git a/core/src/main/java/org/apache/hadoop/hbase/HServerInfo.java b/core/src/main/java/org/apache/hadoop/hbase/HServerInfo.java index a38925b820b..2f772bd11f5 100644 --- a/core/src/main/java/org/apache/hadoop/hbase/HServerInfo.java +++ b/core/src/main/java/org/apache/hadoop/hbase/HServerInfo.java @@ -137,8 +137,15 @@ public class HServerInfo implements WritableComparable { */ public synchronized String getServerName() { if (this.serverName == null) { + // if we have the hostname of the RS, use it + if(this.name != null) { + this.serverName = getServerName(this.name, this.serverAddress.getPort(), this.startCode); + } + // go to DNS name resolution only if we dont have the name of the RS + else { this.serverName = getServerName(this.serverAddress, this.startCode); } + } return this.serverName; } @@ -219,7 +226,7 @@ public class HServerInfo implements WritableComparable { * @param info * @return the server name in the form hostname_startcode_port */ - public static String getServerName(HServerInfo info) { + private static String getServerName(HServerInfo info) { return getServerName(info.getServerAddress(), info.getStartCode()); } diff --git a/core/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionOpen.java b/core/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionOpen.java index 6ac4c74a4cf..9bda764a9d9 100644 --- a/core/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionOpen.java +++ b/core/src/main/java/org/apache/hadoop/hbase/master/ProcessRegionOpen.java @@ -53,7 +53,7 @@ class ProcessRegionOpen extends ProcessRegionStatusChange { @Override public String toString() { - return "PendingOpenOperation from " + HServerInfo.getServerName(serverInfo); + return "PendingOpenOperation from " + serverInfo.getServerName(); } @Override diff --git a/core/src/main/java/org/apache/hadoop/hbase/master/ProcessServerShutdown.java b/core/src/main/java/org/apache/hadoop/hbase/master/ProcessServerShutdown.java index 732050887f5..40ea0b40ad3 100644 --- a/core/src/main/java/org/apache/hadoop/hbase/master/ProcessServerShutdown.java +++ b/core/src/main/java/org/apache/hadoop/hbase/master/ProcessServerShutdown.java @@ -69,7 +69,7 @@ class ProcessServerShutdown extends RegionServerOperation { */ public ProcessServerShutdown(HMaster master, HServerInfo serverInfo) { super(master); - this.deadServer = HServerInfo.getServerName(serverInfo); + this.deadServer = serverInfo.getServerName(); this.deadServerAddress = serverInfo.getServerAddress(); this.logSplit = false; this.rootRescanned = false; diff --git a/core/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java b/core/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java index ef7db4f1303..5dd42bf6d2b 100644 --- a/core/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java +++ b/core/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java @@ -163,7 +163,7 @@ public class ServerManager implements HConstants { void regionServerStartup(final HServerInfo serverInfo) throws Leases.LeaseStillHeldException { HServerInfo info = new HServerInfo(serverInfo); - String serverName = HServerInfo.getServerName(info); + String serverName = info.getServerName(); if (this.serversToServerInfo.containsKey(serverName) || this.deadServers.contains(serverName)) { LOG.debug("Server start was rejected: " + serverInfo); @@ -217,7 +217,7 @@ public class ServerManager implements HConstants { */ void recordNewServer(HServerInfo info, boolean useInfoLoad) { HServerLoad load = useInfoLoad ? info.getLoad() : new HServerLoad(); - String serverName = HServerInfo.getServerName(info); + String serverName = info.getServerName(); info.setLoad(load); // We must set this watcher here because it can be set on a fresh start // or on a failover @@ -809,7 +809,7 @@ public class ServerManager implements HConstants { serverAddressToServerInfo.remove(serverAddress); HServerInfo info = serversToServerInfo.remove(server); if (info != null) { - String serverName = HServerInfo.getServerName(info); + String serverName = info.getServerName(); HServerLoad load = serversToLoad.remove(serverName); if (load != null) { synchronized (loadToServers) { diff --git a/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java b/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java index ccbea45924b..1af8bab7ffe 100644 --- a/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java +++ b/core/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java @@ -1336,7 +1336,7 @@ public class HLog implements HConstants, Syncable { * @return the HLog directory name */ public static String getHLogDirectoryName(HServerInfo info) { - return getHLogDirectoryName(HServerInfo.getServerName(info)); + return getHLogDirectoryName(info.getServerName()); } /**