Index: src/java/org/apache/hadoop/hbase/ClusterStatus.java =================================================================== --- src/java/org/apache/hadoop/hbase/ClusterStatus.java (revision 948218) +++ src/java/org/apache/hadoop/hbase/ClusterStatus.java (working copy) @@ -26,7 +26,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; import java.util.Map; import java.util.NavigableMap; import java.util.TreeMap; @@ -68,7 +67,7 @@ public Collection getServerNames() { ArrayList names = new ArrayList(liveServerInfo.size()); for (HServerInfo server: liveServerInfo) { - names.add(server.getName()); + names.add(server.getHostnamePort()); } return names; } Index: src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java =================================================================== --- src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (revision 948218) +++ src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (working copy) @@ -520,7 +520,8 @@ LOG.error("error closing and deleting HLog", e); } try { - serverInfo.setStartCode(System.currentTimeMillis()); + this.serverInfo = + createServerInfoWithNewStartCode(this.serverInfo); hlog = setupHLog(); this.hlogFlusher.setHLog(hlog); } catch (IOException e) { @@ -643,8 +644,7 @@ } closeAllRegions(); // Don't leave any open file handles } - LOG.info("aborting server at: " + - serverInfo.getServerAddress().toString()); + LOG.info("aborting server at: " + this.serverInfo.getServerName()); } else { ArrayList closedRegions = closeAllRegions(); try { @@ -666,14 +666,13 @@ } LOG.info("telling master that region server is shutting down at: " + - serverInfo.getServerAddress().toString()); + serverInfo.getServerName()); hbaseMaster.regionServerReport(serverInfo, exitMsg, (HRegionInfo[])null); } catch (Throwable e) { LOG.warn("Failed to send exiting message to master: ", RemoteExceptionHandler.checkThrowable(e)); } - LOG.info("stopping server at: " + - serverInfo.getServerAddress().toString()); + LOG.info("stopping server at: " + this.serverInfo.getServerName()); } if (this.hbaseMaster != null) { HBaseRPC.stopProxy(this.hbaseMaster); @@ -1049,7 +1048,7 @@ } if (fs.exists(logdir)) { throw new RegionServerRunningException("region server already " + - "running at " + this.serverInfo.getServerAddress().toString() + + "running at " + this.serverInfo.getServerName() + " because logdir " + logdir.toString() + " exists"); } HLog newlog = instantiateHLog(logdir); @@ -1183,8 +1182,10 @@ // auto bind enabled, try to use another port LOG.info("Failed binding http info server to port: " + port); port++; - // update HRS server info - this.serverInfo.setInfoPort(port); + // update HRS server info port. + this.serverInfo = new HServerInfo(this.serverInfo.getServerAddress(), + this.serverInfo.getStartCode(), port, + this.serverInfo.getHostname()); } } } @@ -1343,7 +1344,7 @@ lastMsg = System.currentTimeMillis(); boolean startCodeOk = false; while(!startCodeOk) { - serverInfo.setStartCode(System.currentTimeMillis()); + this.serverInfo = createServerInfoWithNewStartCode(this.serverInfo); startCodeOk = zooKeeperWrapper.writeRSLocation(this.serverInfo); if(!startCodeOk) { LOG.debug("Start code already taken, trying another one"); @@ -1366,6 +1367,11 @@ return result; } + private HServerInfo createServerInfoWithNewStartCode(final HServerInfo hsi) { + return new HServerInfo(hsi.getServerAddress(), hsi.getInfoPort(), + hsi.getHostname()); + } + /* Add to the outbound message buffer */ private void reportOpen(HRegionInfo region) { this.outboundMsgs.add(new HMsg(HMsg.Type.MSG_REPORT_OPEN, region)); Index: src/java/org/apache/hadoop/hbase/HServerInfo.java =================================================================== --- src/java/org/apache/hadoop/hbase/HServerInfo.java (revision 948218) +++ src/java/org/apache/hadoop/hbase/HServerInfo.java (working copy) @@ -1,5 +1,5 @@ /** - * Copyright 2007 The Apache Software Foundation + * Copyright 2010 The Apache Software Foundation * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -22,51 +22,70 @@ import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; -import java.util.Map; -import java.util.HashMap; +import java.net.InetSocketAddress; +import java.util.Set; +import org.apache.hadoop.hbase.regionserver.HRegionServer; +import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.WritableComparable; /** - * HServerInfo contains metainfo about an HRegionServer, Currently it only - * contains the server start code. - * - * In the future it will contain information about the source machine and - * load statistics. + * HServerInfo is meta info about an {@link HRegionServer}. It is the token + * by which a master distingushes a particular regionserver from the rest. + * It holds hostname, ports, regionserver startcode, and load. Each server has + * a servername where servername is made up of a concatenation of + * hostname, port, and regionserver startcode. This servername is used in + * various places identifying this regionserver. Its even used as part of + * a pathname in the filesystem. As part of the initialization, + * master will pass the regionserver the address that it knows this regionserver + * by. In subsequent communications, the regionserver will pass a HServerInfo + * with the master-supplied address. */ public class HServerInfo implements WritableComparable { + /* + * This character is used as separator between server hostname and port and + * its startcode. Servername is formatted as + * <hostname> '{@ink #SERVERNAME_SEPARATOR"}' <port> '{@ink #SERVERNAME_SEPARATOR"}' <startcode>. + */ + private static final String SERVERNAME_SEPARATOR = ","; + private HServerAddress serverAddress; private long startCode; private HServerLoad load; private int infoPort; private String serverName = null; - private String name; - private static Map dnsCache = new HashMap(); + // Hostname of the regionserver. + private String hostname; - /** default constructor - used by Writable */ public HServerInfo() { - this(new HServerAddress(), 0, - HConstants.DEFAULT_REGIONSERVER_INFOPORT, "default name"); + this(new HServerAddress(), 0, HConstants.DEFAULT_REGIONSERVER_INFOPORT, + "default name"); } - + /** - * Constructor - * @param serverAddress - * @param startCode - * @param infoPort Port the info server is listening on. + * Constructor that creates a HServerInfo with a generated startcode and an + * empty load. + * @param serverAddress An {@link InetSocketAddress} encased in a {@link Writable} + * @param infoPort Port the webui runs on. + * @param hostname Server hostname. */ + public HServerInfo(HServerAddress serverAddress, final int infoPort, + final String hostname) { + this(serverAddress, System.currentTimeMillis(), infoPort, hostname); + } + public HServerInfo(HServerAddress serverAddress, long startCode, - final int infoPort, String name) { + final int infoPort, String hostname) { this.serverAddress = serverAddress; this.startCode = startCode; this.load = new HServerLoad(); this.infoPort = infoPort; - this.name = name; + this.hostname = hostname; } - + /** - * Construct a new object using another as input (like a copy constructor) + * Copy-constructor * @param other */ public HServerInfo(HServerInfo other) { @@ -74,109 +93,101 @@ this.startCode = other.getStartCode(); this.load = other.getLoad(); this.infoPort = other.getInfoPort(); - this.name = other.getName(); + this.hostname = other.hostname; } - /** - * @return the load - */ public HServerLoad getLoad() { return load; } - /** - * @param load the load to set - */ public void setLoad(HServerLoad load) { this.load = load; } - /** @return the server address */ public synchronized HServerAddress getServerAddress() { return new HServerAddress(serverAddress); } - - /** - * Change the server address. - * @param serverAddress New server address - */ + public synchronized void setServerAddress(HServerAddress serverAddress) { this.serverAddress = serverAddress; this.serverName = null; } - - /** @return the server start code */ + public synchronized long getStartCode() { return startCode; } - - /** - * @return Port the info server is listening on. - */ + public int getInfoPort() { return this.infoPort; } - + + public String getHostname() { + return this.hostname; + } + /** - * @param infoPort - new port of info server + * @return The hostname and port concatenated with a ':' as separator. */ - public void setInfoPort(int infoPort) { - this.infoPort = infoPort; + public String getHostnamePort() { + return getHostnamePort(this.hostname, this.serverAddress.getPort()); } - + /** - * @param startCode the startCode to set + * @param hostname + * @param port + * @return The hostname and port concatenated with a ':' as separator. */ - public synchronized void setStartCode(long startCode) { - this.startCode = startCode; - this.serverName = null; + public static String getHostnamePort(final String hostname, final int port) { + return hostname + ":" + port; } - + /** - * @return the server name in the form hostname_startcode_port + * @return Server name made of the concatenation of hostname, port and + * startcode formatted as <hostname> ':' <port> ',' <startcode> */ public synchronized String getServerName() { if (this.serverName == null) { - // if we have the hostname of the RS, use it - if(this.name != null) { - this.serverName = getServerName(this.name, this.serverAddress.getPort(), this.startCode); - } - // go to DNS name resolution only if we dont have the name of the RS - else { - this.serverName = getServerName(this.serverAddress, this.startCode); + this.serverName = getServerName(this.hostname, + this.serverAddress.getPort(), this.startCode); } - } return this.serverName; } - - /** - * Get the hostname of the server - * @return hostname - */ - public String getName() { - return name; + + public static synchronized String getServerName(final String hostAndPort, + final long startcode) { + int index = hostAndPort.indexOf(":"); + if (index <= 0) throw new IllegalArgumentException("Expected ':' "); + return getServerName(hostAndPort.substring(0, index), + Integer.parseInt(hostAndPort.substring(index + 1)), startcode); } - - /** - * Set the hostname of the server - * @param name hostname + + /* + * @param hostname + * @param port + * @param sc Startcode + * @return Server name made of the concatenation of hostname, port and + * startcode formatted as <hostname> ',' <port> ',' <startcode> */ - public void setName(String name) { - this.name = name; + static String getServerName(String hostname, int port, long sc) { + StringBuilder sb = new StringBuilder(hostname); + sb.append(SERVERNAME_SEPARATOR); + sb.append(port); + sb.append(SERVERNAME_SEPARATOR); + sb.append(sc); + return sb.toString(); } /** - * @see java.lang.Object#toString() + * @return ServerName and load concatenated. + * @see #getServerName() + * @see #getLoad() */ @Override public String toString() { - return "address: " + this.serverAddress + ", startcode: " + this.startCode - + ", load: (" + this.load.toString() + ")"; + return "serverName=" + getServerName() + + ", load=(" + this.load.toString() + ")"; } - /** - * @see java.lang.Object#equals(java.lang.Object) - */ @Override public boolean equals(Object obj) { if (this == obj) { @@ -191,23 +202,17 @@ return compareTo((HServerInfo)obj) == 0; } - /** - * @see java.lang.Object#hashCode() - */ @Override public int hashCode() { return this.getServerName().hashCode(); } - - // Writable - public void readFields(DataInput in) throws IOException { this.serverAddress.readFields(in); this.startCode = in.readLong(); this.load.readFields(in); this.infoPort = in.readInt(); - this.name = in.readUTF(); + this.hostname = in.readUTF(); } public void write(DataOutput out) throws IOException { @@ -215,7 +220,7 @@ out.writeLong(this.startCode); this.load.write(out); out.writeInt(this.infoPort); - out.writeUTF(name); + out.writeUTF(hostname); } public int compareTo(HServerInfo o) { @@ -223,53 +228,25 @@ } /** - * @param info - * @return the server name in the form hostname_startcode_port + * Utility method that does a find of a servername or a hostandport combination + * in the passed Set. + * @param servers Set of server names + * @param serverName Name to look for + * @param hostAndPortOnly If serverName is a + * hostname ':' port + * or hostname , port , startcode. + * @return True if serverName found in servers */ - private static String getServerName(HServerInfo info) { - return getServerName(info.getServerAddress(), info.getStartCode()); - } - - /** - * @param serverAddress in the form hostname:port - * @param startCode - * @return the server name in the form hostname_startcode_port - */ - public static String getServerName(String serverAddress, long startCode) { - String name = null; - if (serverAddress != null) { - int colonIndex = serverAddress.lastIndexOf(':'); - if(colonIndex < 0) { - throw new IllegalArgumentException("Not a host:port pair: " + serverAddress); - } - String host = serverAddress.substring(0, colonIndex); - int port = - Integer.valueOf(serverAddress.substring(colonIndex + 1)).intValue(); - if(!dnsCache.containsKey(host)) { - HServerAddress address = new HServerAddress(serverAddress); - dnsCache.put(host, address.getHostname()); - } - host = dnsCache.get(host); - name = getServerName(host, port, startCode); + public static boolean isServer(final Set servers, + final String serverName, final boolean hostAndPortOnly) { + if (!hostAndPortOnly) return servers.contains(serverName); + String serverNameColonReplaced = + serverName.replaceFirst(":", SERVERNAME_SEPARATOR); + for (String hostPortStartCode: servers) { + int index = hostPortStartCode.lastIndexOf(SERVERNAME_SEPARATOR); + String hostPortStrippedOfStartCode = hostPortStartCode.substring(0, index); + if (hostPortStrippedOfStartCode.equals(serverNameColonReplaced)) return true; } - return name; + return false; } - - /** - * @param address - * @param startCode - * @return the server name in the form hostname_startcode_port - */ - public static String getServerName(HServerAddress address, long startCode) { - return getServerName(address.getHostname(), address.getPort(), startCode); - } - - private static String getServerName(String hostName, int port, long startCode) { - StringBuilder name = new StringBuilder(hostName); - name.append(","); - name.append(port); - name.append(","); - name.append(startCode); - return name.toString(); - } -} +} \ No newline at end of file Index: src/java/org/apache/hadoop/hbase/master/ServerManager.java =================================================================== --- src/java/org/apache/hadoop/hbase/master/ServerManager.java (revision 948218) +++ src/java/org/apache/hadoop/hbase/master/ServerManager.java (working copy) @@ -58,7 +58,7 @@ * The ServerManager class manages info about region servers - HServerInfo, * load numbers, dying servers, etc. */ -class ServerManager implements HConstants { +public class ServerManager implements HConstants { static final Log LOG = LogFactory.getLog(ServerManager.class.getName()); private static final HMsg REGIONSERVER_QUIESCE = @@ -75,9 +75,6 @@ final Map serversToServerInfo = new ConcurrentHashMap(); - final Map serverAddressToServerInfo = - new ConcurrentHashMap(); - /** * Set of known dead servers. On znode expiration, servers are added here. * This is needed in case of a network partitioning where the server's lease @@ -110,7 +107,7 @@ } protected void chore() { - int numServers = serverAddressToServerInfo.size(); + int numServers = serversToServerInfo.size(); int numDeadServers = deadServers.size(); double averageLoad = getAverageLoad(); String deadServersList = null; @@ -220,7 +217,6 @@ Watcher watcher = new ServerExpirer(serverName, info.getServerAddress()); master.getZooKeeperWrapper().updateRSLocationGetWatch(info, watcher); serversToServerInfo.put(serverName, info); - serverAddressToServerInfo.put(info.getServerAddress(), info); serversToLoad.put(serverName, load); synchronized (loadToServers) { Set servers = loadToServers.get(load); @@ -315,7 +311,7 @@ } synchronized (serversToServerInfo) { - removeServerInfo(info.getServerName(), info.getServerAddress()); + removeServerInfo(info.getServerName()); serversToServerInfo.notifyAll(); } @@ -338,8 +334,7 @@ try { // This method removes ROOT/META from the list and marks them to be reassigned // in addition to other housework. - if (removeServerInfo(serverInfo.getServerName(), - serverInfo.getServerAddress())) { + if (removeServerInfo(serverInfo.getServerName())) { // Only process the exit message if the server still has registered info. // Otherwise we could end up processing the server exit twice. LOG.info("Region server " + serverInfo.getServerName() + @@ -398,7 +393,6 @@ final HRegionInfo[] mostLoadedRegions, HMsg[] msgs) throws IOException { // Refresh the info object and the load information - serverAddressToServerInfo.put(serverInfo.getServerAddress(), serverInfo); serversToServerInfo.put(serverInfo.getServerName(), serverInfo); HServerLoad load = serversToLoad.get(serverInfo.getServerName()); if (load != null) { @@ -605,7 +599,7 @@ if (duplicateAssignment) { if (LOG.isDebugEnabled()) { - LOG.debug("region server " + serverInfo.getServerAddress().toString() + LOG.warn("region server " + serverInfo.getServerName() + " should not have opened region " + Bytes.toString(region.getRegionName())); } @@ -694,10 +688,8 @@ } /** Update a server load information because it's shutting down*/ - private boolean removeServerInfo(final String serverName, - final HServerAddress serverAddress) { + private boolean removeServerInfo(final String serverName) { boolean infoUpdated = false; - serverAddressToServerInfo.remove(serverAddress); HServerInfo info = serversToServerInfo.remove(serverName); // Only update load information once. // This method can be called a couple of times during shutdown. @@ -779,11 +771,19 @@ } } - public Map getServerAddressToServerInfo() { - // we use this one because all the puts to this map are parallel/synced with the other map. - synchronized (serversToServerInfo) { - return Collections.unmodifiableMap(serverAddressToServerInfo); + /** + * @param hsa + * @return The HServerInfo whose HServerAddress is hsa or null + * if nothing found. + */ + public HServerInfo getHServerInfo(final HServerAddress hsa) { + synchronized(this.serversToServerInfo) { + // TODO: This is primitive. Do a better search. + for (Map.Entry e: this.serversToServerInfo.entrySet()) { + if (e.getValue().getServerAddress().equals(hsa)) return e.getValue(); + } } + return null; } /** @@ -841,18 +841,15 @@ /** Watcher triggered when a RS znode is deleted */ private class ServerExpirer implements Watcher { private String server; - private HServerAddress serverAddress; ServerExpirer(String server, HServerAddress serverAddress) { this.server = server; - this.serverAddress = serverAddress; } public void process(WatchedEvent event) { if(event.getType().equals(EventType.NodeDeleted)) { LOG.info(server + " znode expired"); // Remove the server from the known servers list and update load info - serverAddressToServerInfo.remove(serverAddress); HServerInfo info = serversToServerInfo.remove(server); if (info != null) { String serverName = info.getServerName(); @@ -908,5 +905,4 @@ public void setMinimumServerCount(int minimumServerCount) { this.minimumServerCount = minimumServerCount; } - } Index: src/java/org/apache/hadoop/hbase/master/HMaster.java =================================================================== --- src/java/org/apache/hadoop/hbase/master/HMaster.java (revision 948218) +++ src/java/org/apache/hadoop/hbase/master/HMaster.java (working copy) @@ -349,10 +349,6 @@ return serverManager.getServersToServerInfo(); } - public Map getServerAddressToServerInfo() { - return serverManager.getServerAddressToServerInfo(); - } - /** * @return Read-only map of servers to load. */ @@ -564,7 +560,7 @@ HRegionInterface hri = this.connection.getHRegionConnection(address, false); HServerInfo info = hri.getHServerInfo(); - LOG.debug("Inspection found server " + info.getName()); + LOG.debug("Inspection found server " + info.getServerName()); serverManager.recordNewServer(info, true); HRegionInfo[] regions = hri.getRegionsAssignment(); for (HRegionInfo region : regions) { @@ -686,19 +682,18 @@ */ public MapWritable regionServerStartup(final HServerInfo serverInfo) throws IOException { - // Set the address for now even tho it will not be persisted on HRS side - // If the address given is not the default one, - // use the IP given by the user. - if (serverInfo.getServerAddress().getBindAddress().equals( - DEFAULT_HOST)) { - String rsAddress = HBaseServer.getRemoteAddress(); - serverInfo.setServerAddress(new HServerAddress(rsAddress, - serverInfo.getServerAddress().getPort())); - } + // Set the ip into the passed in serverInfo. Its ip is more than likely + // 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" + String rsAddress = HBaseServer.getRemoteAddress(); + serverInfo.setServerAddress(new HServerAddress(rsAddress, + serverInfo.getServerAddress().getPort())); // Register with server manager this.serverManager.regionServerStartup(serverInfo); // Send back some config info - return createConfigurationSubset(); + MapWritable mw = createConfigurationSubset(); + mw.put(new Text("hbase.regionserver.address"), new Text(rsAddress)); + return mw; } /** @@ -707,12 +702,6 @@ */ protected MapWritable createConfigurationSubset() { MapWritable mw = addConfig(new MapWritable(), HConstants.HBASE_DIR); - // Get the real address of the HRS. - String rsAddress = HBaseServer.getRemoteAddress(); - if (rsAddress != null) { - mw.put(new Text("hbase.regionserver.address"), new Text(rsAddress)); - } - return addConfig(mw, "fs.default.name"); } @@ -1019,29 +1008,26 @@ // Arguments are regionname and an optional server name. byte [] regionname = ((ImmutableBytesWritable)args[0]).get(); LOG.debug("Attempting to close region: " + Bytes.toStringBinary(regionname)); - String servername = null; + String hostnameAndPort = null; if (args.length == 2) { - servername = Bytes.toString(((ImmutableBytesWritable)args[1]).get()); + hostnameAndPort = Bytes.toString(((ImmutableBytesWritable)args[1]).get()); } // Need hri Result rr = getFromMETA(regionname, HConstants.CATALOG_FAMILY); HRegionInfo hri = getHRegionInfo(rr.getRow(), rr); - if (servername == null) { + if (hostnameAndPort == null) { // Get server from the .META. if it wasn't passed as argument - servername = + hostnameAndPort = Bytes.toString(rr.getValue(CATALOG_FAMILY, SERVER_QUALIFIER)); } // Take region out of the intransistions in case it got stuck there doing // an open or whatever. this.regionManager.clearFromInTransition(regionname); - // If servername is still null, then none, exit. - if (servername == null) break; - // Need to make up a HServerInfo 'servername' for that is how - // items are keyed in regionmanager Maps. - HServerAddress addr = new HServerAddress(servername); + // If hostnameAndPort is still null, then none, exit. + if (hostnameAndPort == null) break; long startCode = Bytes.toLong(rr.getValue(CATALOG_FAMILY, STARTCODE_QUALIFIER)); - String name = HServerInfo.getServerName(addr, startCode); + String name = HServerInfo.getServerName(hostnameAndPort, startCode); LOG.info("Marking " + hri.getRegionNameAsString() + " as closing on " + name + "; cleaning SERVER + STARTCODE; " + "master will tell regionserver to close region on next heartbeat"); Index: src/java/org/apache/hadoop/hbase/master/ProcessRegionOpen.java =================================================================== --- src/java/org/apache/hadoop/hbase/master/ProcessRegionOpen.java (revision 948218) +++ src/java/org/apache/hadoop/hbase/master/ProcessRegionOpen.java (working copy) @@ -68,18 +68,18 @@ HRegionInterface server = master.connection.getHRegionConnection(getMetaRegion().getServer()); LOG.info(regionInfo.getRegionNameAsString() + " open on " + - serverInfo.getServerAddress().toString()); + serverInfo.getServerName()); // Register the newly-available Region's location. Put p = new Put(regionInfo.getRegionName()); p.add(CATALOG_FAMILY, SERVER_QUALIFIER, - Bytes.toBytes(serverInfo.getServerAddress().toString())); + Bytes.toBytes(serverInfo.getHostnamePort())); p.add(CATALOG_FAMILY, STARTCODE_QUALIFIER, Bytes.toBytes(serverInfo.getStartCode())); server.put(metaRegionName, p); LOG.info("Updated row " + regionInfo.getRegionNameAsString() + " in region " + Bytes.toString(metaRegionName) + " with startcode=" + - serverInfo.getStartCode() + ", server=" + serverInfo.getServerAddress()); + serverInfo.getStartCode() + ", server=" + serverInfo.getHostnamePort()); synchronized (master.regionManager) { if (isMetaTable) { // It's a meta region. @@ -121,4 +121,4 @@ protected int getPriority() { return 0; // highest priority } -} \ No newline at end of file +} Index: src/java/org/apache/hadoop/hbase/master/BaseScanner.java =================================================================== --- src/java/org/apache/hadoop/hbase/master/BaseScanner.java (revision 948218) +++ src/java/org/apache/hadoop/hbase/master/BaseScanner.java (working copy) @@ -522,16 +522,16 @@ * @param regionServer * @param meta * @param info - * @param serverAddress + * @param hostnameAndPort hostname ':' port as it comes out of .META. * @param startCode * @throws IOException */ protected void checkAssigned(final HRegionInterface regionServer, final MetaRegion meta, final HRegionInfo info, - final String serverAddress, final long startCode) + final String hostnameAndPort, final long startCode) throws IOException { String serverName = null; - String sa = serverAddress; + String sa = hostnameAndPort; long sc = startCode; // Scans are sloppy. They don't respect row locks and they get and // cache a row internally so may have data that is stale. Make sure that for @@ -543,9 +543,9 @@ Result r = regionServer.get(meta.getRegionName(), g); if (r != null && !r.isEmpty()) { sa = getServerAddress(r); - if (sa != null && sa.length() > 0 && !sa.equalsIgnoreCase(serverAddress)) { + if (sa != null && sa.length() > 0 && !sa.equalsIgnoreCase(hostnameAndPort)) { LOG.debug("GET on " + info.getRegionNameAsString() + " got different " + - "address than SCAN: sa=" + sa + ", serverAddress=" + serverAddress); + "address than SCAN: sa=" + sa + ", serverAddress=" + hostnameAndPort); } // Reget startcode in case its changed in the meantime too. sc = getStartCode(r); Index: src/webapps/master/table.jsp =================================================================== --- src/webapps/master/table.jsp (revision 948218) +++ src/webapps/master/table.jsp (working copy) @@ -42,8 +42,6 @@ HBaseAdmin hbadmin = new HBaseAdmin(conf); String tableName = request.getParameter("name"); HTable table = new HTable(conf, tableName); - Map serverAddressToServerInfos = - master.getServerAddressToServerInfo(); String tableHeader = "

Table Regions

"; HServerAddress rootLocation = master.getRootRegionLocation(); %> @@ -105,7 +103,7 @@ %> <%= tableHeader %> <% - int infoPort = serverAddressToServerInfos.get(rootLocation).getInfoPort(); + int infoPort = master.getServerManager().getHServerInfo(rootLocation).getInfoPort(); String url = "http://" + rootLocation.getHostname() + ":" + infoPort + "/"; %> @@ -123,7 +121,7 @@ <% Map onlineRegions = master.getOnlineMetaRegions(); for (MetaRegion meta: onlineRegions.values()) { - int infoPort = serverAddressToServerInfos.get(meta.getServer()).getInfoPort(); + int infoPort = master.getServerManager().getHServerInfo(meta.getServer()).getInfoPort(); String url = "http://" + meta.getServer().getHostname() + ":" + infoPort + "/"; %> @@ -146,10 +144,7 @@ <%= tableHeader %> <% for(Map.Entry hriEntry : regions.entrySet()) { - - int infoPort = serverAddressToServerInfos.get( - hriEntry.getValue()).getInfoPort(); - + int infoPort = master.getServerManager().getHServerInfo(hriEntry.getValue()).getInfoPort(); String urlRegionServer = "http://" + hriEntry.getValue().getHostname().toString() + ":" + infoPort + "/"; %>
NameRegion ServerEncoded NameStart KeyEnd Key