diff --git a/CHANGES.txt b/CHANGES.txt index 094431bc9b7..c8cec90f3e5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -726,6 +726,7 @@ Release 0.90.0 - Unreleased HBASE-3265 Regionservers waiting for ROOT while Master waiting for RegionServers HBASE-3263 Stack overflow in AssignmentManager HBASE-3234 hdfs-724 "breaks" TestHBaseTestingUtility multiClusters + HBASE-3286 Master passes IP and not hostname back to region server IMPROVEMENTS diff --git a/src/main/java/org/apache/hadoop/hbase/HServerAddress.java b/src/main/java/org/apache/hadoop/hbase/HServerAddress.java index 3859968717f..7f8a4721a78 100644 --- a/src/main/java/org/apache/hadoop/hbase/HServerAddress.java +++ b/src/main/java/org/apache/hadoop/hbase/HServerAddress.java @@ -62,7 +62,7 @@ public class HServerAddress implements WritableComparable { String host = hostAndPort.substring(0, colonIndex); int port = Integer.parseInt(hostAndPort.substring(colonIndex + 1)); this.address = new InetSocketAddress(host, port); - this.stringValue = hostAndPort; + this.stringValue = address.getHostName() + ":" + port; checkBindAddressCanBeResolved(); } @@ -72,7 +72,7 @@ public class HServerAddress implements WritableComparable { */ public HServerAddress(String bindAddress, int port) { this.address = new InetSocketAddress(bindAddress, port); - this.stringValue = bindAddress + ":" + port; + this.stringValue = address.getHostName() + ":" + port; checkBindAddressCanBeResolved(); } @@ -156,15 +156,15 @@ public class HServerAddress implements WritableComparable { // public void readFields(DataInput in) throws IOException { - String bindAddress = in.readUTF(); + String hostname = in.readUTF(); int port = in.readInt(); - if (bindAddress == null || bindAddress.length() == 0) { + if (hostname == null || hostname.length() == 0) { address = null; stringValue = null; } else { - address = new InetSocketAddress(bindAddress, port); - stringValue = bindAddress + ":" + port; + address = new InetSocketAddress(hostname, port); + stringValue = hostname + ":" + port; checkBindAddressCanBeResolved(); } } @@ -174,7 +174,7 @@ public class HServerAddress implements WritableComparable { out.writeUTF(""); out.writeInt(0); } else { - out.writeUTF(address.getAddress().getHostAddress()); + out.writeUTF(address.getAddress().getHostName()); out.writeInt(address.getPort()); } } diff --git a/src/main/java/org/apache/hadoop/hbase/HServerInfo.java b/src/main/java/org/apache/hadoop/hbase/HServerInfo.java index aaf4835158e..c742951be22 100644 --- a/src/main/java/org/apache/hadoop/hbase/HServerInfo.java +++ b/src/main/java/org/apache/hadoop/hbase/HServerInfo.java @@ -113,6 +113,7 @@ public class HServerInfo implements WritableComparable { public synchronized void setServerAddress(HServerAddress serverAddress) { this.serverAddress = serverAddress; + this.hostname = serverAddress.getHostname(); this.serverName = null; } diff --git a/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index 7da8a97a27a..43c027e9553 100644 --- a/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -22,6 +22,7 @@ package org.apache.hadoop.hbase.master; import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import java.net.InetSocketAddress; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; @@ -599,16 +600,18 @@ implements HMasterInterface, HMasterRegionInterface, MasterServices, Server { // not the ip that the master sees here. See at end of this method where // we pass it back to the regionserver by setting "hbase.regionserver.address" // Everafter, the HSI combination 'server name' is what uniquely identifies - // the incoming RegionServer. No more DNS meddling of this little messing - // belose. - String rsAddress = HBaseServer.getRemoteAddress(); - serverInfo.setServerAddress(new HServerAddress(rsAddress, - serverInfo.getServerAddress().getPort())); + // the incoming RegionServer. + InetSocketAddress address = new InetSocketAddress( + HBaseServer.getRemoteIp().getHostName(), + serverInfo.getServerAddress().getPort()); + serverInfo.setServerAddress(new HServerAddress(address)); + // Register with server manager this.serverManager.regionServerStartup(serverInfo, serverCurrentTime); // Send back some config info MapWritable mw = createConfigurationSubset(); - mw.put(new Text("hbase.regionserver.address"), new Text(rsAddress)); + mw.put(new Text("hbase.regionserver.address"), + serverInfo.getServerAddress()); return mw; } diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index b2b9cc42e70..8903813bbb4 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -801,32 +801,23 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, protected void handleReportForDutyResponse(final MapWritable c) throws IOException { try { for (Map.Entry e : c.entrySet()) { + String key = e.getKey().toString(); + // Use the address the master passed us + if (key.equals("hbase.regionserver.address")) { + HServerAddress hsa = (HServerAddress) e.getValue(); + LOG.info("Master passed us address to use. Was=" + + this.serverInfo.getServerAddress() + ", Now=" + hsa.toString()); + this.serverInfo.setServerAddress(hsa); + continue; + } String value = e.getValue().toString(); if (LOG.isDebugEnabled()) { LOG.debug("Config from master: " + key + "=" + value); } this.conf.set(key, value); } - // Master may have sent us a new address with the other configs. - // Update our address in this case. See HBASE-719 - String hra = conf.get("hbase.regionserver.address"); - // TODO: The below used to be this.address != null. Was broken by what - // looks like a mistake in: - // - // HBASE-1215 migration; metautils scan of meta region was broken; - // wouldn't see first row - // ------------------------------------------------------------------------ - // r796326 | stack | 2009-07-21 07:40:34 -0700 (Tue, 21 Jul 2009) | 38 - // lines - if (hra != null) { - HServerAddress hsa = new HServerAddress(hra, this.serverInfo - .getServerAddress().getPort()); - LOG.info("Master passed us address to use. Was=" - + this.serverInfo.getServerAddress() + ", Now=" + hsa.toString()); - this.serverInfo.setServerAddress(hsa); - } - + // hack! Maps DFSClient => RegionServer for logs. HDFS made this // config param for task trackers, but we can piggyback off of it. if (this.conf.get("mapred.task.id") == null) {