Author: jdcryans
Date: Wed Dec 1 01:32:52 2010
New Revision: 1040848
URL: http://svn.apache.org/viewvc?rev=1040848&view=rev
Log:
HBASE-3286 Master passes IP and not hostname back to region server
Modified:
hbase/trunk/CHANGES.txt
hbase/trunk/src/main/java/org/apache/hadoop/hbase/HServerAddress.java
hbase/trunk/src/main/java/org/apache/hadoop/hbase/HServerInfo.java
hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Modified: hbase/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1040848&r1=1040847&r2=1040848&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Wed Dec 1 01:32:52 2010
@@ -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
Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/HServerAddress.java
URL:
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/HServerAddress.java?rev=1040848&r1=1040847&r2=1040848&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/HServerAddress.java
(original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/HServerAddress.java Wed
Dec 1 01:32:52 2010
@@ -62,7 +62,7 @@ public class HServerAddress implements W
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 W
*/
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 W
//
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 W
out.writeUTF("");
out.writeInt(0);
} else {
- out.writeUTF(address.getAddress().getHostAddress());
+ out.writeUTF(address.getAddress().getHostName());
out.writeInt(address.getPort());
}
}
Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/HServerInfo.java
URL:
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/HServerInfo.java?rev=1040848&r1=1040847&r2=1040848&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/HServerInfo.java
(original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/HServerInfo.java Wed Dec
1 01:32:52 2010
@@ -113,6 +113,7 @@ public class HServerInfo implements Writ
public synchronized void setServerAddress(HServerAddress serverAddress) {
this.serverAddress = serverAddress;
+ this.hostname = serverAddress.getHostname();
this.serverName = null;
}
Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL:
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1040848&r1=1040847&r2=1040848&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
(original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Wed
Dec 1 01:32:52 2010
@@ -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, HMasterRegi
// 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;
}
Modified:
hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL:
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1040848&r1=1040847&r2=1040848&view=diff
==============================================================================
---
hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
(original)
+++
hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Wed Dec 1 01:32:52 2010
@@ -801,32 +801,23 @@ public class HRegionServer implements HR
protected void handleReportForDutyResponse(final MapWritable c) throws
IOException {
try {
for (Map.Entry<Writable, Writable> 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) {