Index: src/java/org/apache/hadoop/hbase/HServerInfo.java =================================================================== --- src/java/org/apache/hadoop/hbase/HServerInfo.java (revision 673670) +++ src/java/org/apache/hadoop/hbase/HServerInfo.java (working copy) @@ -87,6 +87,14 @@ public HServerAddress getServerAddress() { return serverAddress; } + + /** + * Change the server address. + * @param serverAddress New server address + */ + public void setServerAddress(HServerAddress serverAddress) { + this.serverAddress = serverAddress; + } /** @return the server start code */ public long getStartCode() { Index: src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java =================================================================== --- src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (revision 673670) +++ src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (working copy) @@ -23,7 +23,6 @@ import java.lang.Thread.UncaughtExceptionHandler; import java.lang.reflect.Constructor; import java.net.InetSocketAddress; -import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -88,7 +87,6 @@ import org.apache.hadoop.io.Text; import org.apache.hadoop.io.Writable; import org.apache.hadoop.ipc.Server; -import org.apache.hadoop.net.DNS; import org.apache.hadoop.util.Progressable; import org.apache.hadoop.util.StringUtils; @@ -248,8 +246,10 @@ this.server = HbaseRPC.getServer(this, address.getBindAddress(), address.getPort(), conf.getInt("hbase.regionserver.handler.count", 10), false, conf); + // Address is givin a default IP for the moment. Will be changed after + // calling the master. this.serverInfo = new HServerInfo(new HServerAddress( - new InetSocketAddress(getThisIP(), + new InetSocketAddress(DEFAULT_HOST, this.server.getListenerAddress().getPort())), System.currentTimeMillis(), this.conf.getInt("hbase.regionserver.info.port", 60030)); this.numRegionsToReport = @@ -487,6 +487,12 @@ } 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 + if(conf.get("hbase.regionserver.address") != null) + serverInfo.setServerAddress(new HServerAddress + (conf.get("hbase.regionserver.address"), + serverInfo.getServerAddress().getPort())); // Master sent us hbase.rootdir to use. Should be fully qualified // path with file system specification included. Set 'fs.default.name' // to match the filesystem on hbase.rootdir else underlying hadoop hdfs @@ -522,7 +528,8 @@ private HLog setupHLog() throws RegionServerRunningException, IOException { - Path logdir = new Path(rootDir, "log" + "_" + getThisIP() + "_" + + Path logdir = new Path(rootDir, "log" + "_" + + serverInfo.getServerAddress().getBindAddress() + "_" + this.serverInfo.getStartCode() + "_" + this.serverInfo.getServerAddress().getPort()); if (LOG.isDebugEnabled()) { @@ -625,16 +632,6 @@ return this.log; } - /* - * Use interface to get the 'real' IP for this host. 'serverInfo' is sent to - * master. Should have the real IP of this host rather than 'localhost' or - * 0.0.0.0 or 127.0.0.1 in it. - * @return This servers' IP. - */ - private String getThisIP() throws UnknownHostException { - return DNS.getDefaultIP(conf.get("hbase.regionserver.dns.interface","default")); - } - /** * Sets a flag that will cause all the HRegionServer threads to shut down * in an orderly fashion. Used by unit tests. Index: src/java/org/apache/hadoop/hbase/master/HMaster.java =================================================================== --- src/java/org/apache/hadoop/hbase/master/HMaster.java (revision 673670) +++ src/java/org/apache/hadoop/hbase/master/HMaster.java (working copy) @@ -529,6 +529,11 @@ @SuppressWarnings("unused") public MapWritable regionServerStartup(HServerInfo serverInfo) throws IOException { + // Set the address for now even tho it will not be persisted on + // the HRS side. + String rsAddress = Server.getRemoteAddress(); + serverInfo.setServerAddress(new HServerAddress + (rsAddress, serverInfo.getServerAddress().getPort())); // register with server manager serverManager.regionServerStartup(serverInfo); // send back some config info @@ -541,6 +546,12 @@ */ protected MapWritable createConfigurationSubset() { MapWritable mw = addConfig(new MapWritable(), HConstants.HBASE_DIR); + // Get the real address of the HRS. + String rsAddress = Server.getRemoteAddress(); + if (rsAddress != null) { + mw.put(new Text("hbase.regionserver.address"), new Text(rsAddress)); + } + return addConfig(mw, "fs.default.name"); }