Index: src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (revision 1040669) +++ src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (working copy) @@ -798,32 +798,23 @@ 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) { Index: src/main/java/org/apache/hadoop/hbase/HServerInfo.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/HServerInfo.java (revision 1040669) +++ src/main/java/org/apache/hadoop/hbase/HServerInfo.java (working copy) @@ -113,6 +113,7 @@ public synchronized void setServerAddress(HServerAddress serverAddress) { this.serverAddress = serverAddress; + this.hostname = serverAddress.getHostname(); this.serverName = null; } Index: src/main/java/org/apache/hadoop/hbase/master/HMaster.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/master/HMaster.java (revision 1040669) +++ src/main/java/org/apache/hadoop/hbase/master/HMaster.java (working copy) @@ -22,6 +22,7 @@ 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; @@ -598,16 +599,18 @@ // 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; } Index: src/main/java/org/apache/hadoop/hbase/HServerAddress.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/HServerAddress.java (revision 1040669) +++ src/main/java/org/apache/hadoop/hbase/HServerAddress.java (working copy) @@ -62,7 +62,7 @@ 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 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 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 @@ out.writeUTF(""); out.writeInt(0); } else { - out.writeUTF(address.getAddress().getHostAddress()); + out.writeUTF(address.getAddress().getHostName()); out.writeInt(address.getPort()); } }