HBASE-710 Find out why users have network problems in HBase and not in Hadoop

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@673748 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2008-07-03 18:12:06 +00:00
parent 3224f18ba7
commit 94eba4e517
4 changed files with 32 additions and 14 deletions

View File

@ -164,6 +164,8 @@ Trunk (unreleased changes)
multiple families (Clint Morgan via Jim Kellerman)
HBASE-534 Double-assignment at SPLIT-time
HBASE-712 midKey found compacting is the first, not necessarily the optimal
HBASE-719 Find out why users have network problems in HBase and not in Hadoop
and HConnectionManager (Jean-Daniel Cryans via Stack)
IMPROVEMENTS
HBASE-559 MR example job to count table rows

View File

@ -87,6 +87,14 @@ public class HServerInfo implements WritableComparable {
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() {

View File

@ -529,6 +529,11 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
@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 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
*/
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");
}

View File

@ -23,7 +23,6 @@ import java.io.IOException;
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.MapWritable;
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 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
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 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
}
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 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
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 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
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.