HBASE-3286 Master passes IP and not hostname back to region server

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1040848 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jean-Daniel Cryans 2010-12-01 01:32:52 +00:00
parent 826fbd99ff
commit d4eeff6d35
5 changed files with 28 additions and 32 deletions

View File

@ -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

View File

@ -62,7 +62,7 @@ public class HServerAddress implements WritableComparable<HServerAddress> {
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<HServerAddress> {
*/
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<HServerAddress> {
//
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<HServerAddress> {
out.writeUTF("");
out.writeInt(0);
} else {
out.writeUTF(address.getAddress().getHostAddress());
out.writeUTF(address.getAddress().getHostName());
out.writeInt(address.getPort());
}
}

View File

@ -113,6 +113,7 @@ public class HServerInfo implements WritableComparable<HServerInfo> {
public synchronized void setServerAddress(HServerAddress serverAddress) {
this.serverAddress = serverAddress;
this.hostname = serverAddress.getHostname();
this.serverName = null;
}

View File

@ -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;
}

View File

@ -801,31 +801,22 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
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.