You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by mb...@apache.org on 2012/07/19 01:51:25 UTC

svn commit: r1363178 - in /hbase/branches/0.89-fb/src: main/java/org/apache/hadoop/hbase/ main/java/org/apache/hadoop/hbase/avro/ main/java/org/apache/hadoop/hbase/regionserver/ main/resources/hbase-webapps/master/ test/java/org/apache/hadoop/hbase/ te...

Author: mbautin
Date: Wed Jul 18 23:51:24 2012
New Revision: 1363178

URL: http://svn.apache.org/viewvc?rev=1363178&view=rev
Log:
[master] Remove info port from HServerInfo

Author: mbautin

Summary: Removing info port from HServerInfo and using the port from the configuration instead, because the only time we assign info ports different than that specified in the configuration is in unit tests, and we don't use the web UI in unit tests anyway.

Test Plan:
Unit tests
Deploy to dev cluster
Check master web UI
Check regionserver web UI

Reviewers: pkhemani

Reviewed By: pkhemani

Differential Revision: https://reviews.facebook.net/D4197

Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HServerInfo.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/avro/AvroUtil.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/master.jsp
    hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/table.jsp
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/TestSerialization.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/master/TestKillingServersFromMaster.java

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HServerInfo.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HServerInfo.java?rev=1363178&r1=1363177&r2=1363178&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HServerInfo.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HServerInfo.java Wed Jul 18 23:51:24 2012
@@ -53,7 +53,6 @@ public class HServerInfo implements Writ
   private HServerAddress serverAddress;
   private long startCode;
   private HServerLoad load;
-  private int infoPort;
   // Servername is made of hostname, port and startcode.
   private String serverName = null;
   // Hostname of the regionserver.
@@ -61,8 +60,7 @@ public class HServerInfo implements Writ
   private String cachedHostnamePort = null;
 
   public HServerInfo() {
-    this(new HServerAddress(), 0, HConstants.DEFAULT_REGIONSERVER_INFOPORT,
-      "default name");
+    this(new HServerAddress(), 0, "default name");
   }
 
   /**
@@ -72,17 +70,14 @@ public class HServerInfo implements Writ
    * @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, final String hostname) {
+    this(serverAddress, System.currentTimeMillis(), hostname);
   }
 
-  public HServerInfo(HServerAddress serverAddress, long startCode,
-      final int infoPort, String hostname) {
+  public HServerInfo(HServerAddress serverAddress, long startCode, String hostname) {
     this.serverAddress = serverAddress;
     this.startCode = startCode;
     this.load = new HServerLoad();
-    this.infoPort = infoPort;
     this.hostname = hostname;
   }
 
@@ -94,7 +89,6 @@ public class HServerInfo implements Writ
     this.serverAddress = new HServerAddress(other.getServerAddress());
     this.startCode = other.getStartCode();
     this.load = other.getLoad();
-    this.infoPort = other.getInfoPort();
     this.hostname = other.hostname;
   }
 
@@ -119,10 +113,6 @@ public class HServerInfo implements Writ
     return startCode;
   }
 
-  public int getInfoPort() {
-    return this.infoPort;
-  }
-
   public String getHostname() {
     return this.hostname;
   }
@@ -226,7 +216,7 @@ public class HServerInfo implements Writ
     this.serverAddress.readFields(in);
     this.startCode = in.readLong();
     this.load.readFields(in);
-    this.infoPort = in.readInt();
+    in.readInt();
     this.hostname = in.readUTF();
   }
 
@@ -234,7 +224,8 @@ public class HServerInfo implements Writ
     this.serverAddress.write(out);
     out.writeLong(this.startCode);
     this.load.write(out);
-    out.writeInt(this.infoPort);
+    // Still serializing the info port for backward compatibility but it is not used.
+    out.writeInt(HConstants.DEFAULT_REGIONSERVER_INFOPORT);
     out.writeUTF(hostname);
   }
 

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/avro/AvroUtil.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/avro/AvroUtil.java?rev=1363178&r1=1363177&r2=1363178&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/avro/AvroUtil.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/avro/AvroUtil.java Wed Jul 18 23:51:24 2012
@@ -25,6 +25,7 @@ import java.util.List;
 
 import org.apache.hadoop.hbase.ClusterStatus;
 import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.HServerInfo;
 import org.apache.hadoop.hbase.HServerLoad;
@@ -115,7 +116,7 @@ public class AvroUtil {
 
   static public AServerInfo hsiToASI(HServerInfo hsi) throws IOException {
     AServerInfo asi = new AServerInfo();
-    asi.infoPort = hsi.getInfoPort();
+    asi.infoPort = HConstants.DEFAULT_REGIONSERVER_INFOPORT;
     asi.load = hslToASL(hsi.getLoad());
     asi.serverAddress = hsaToASA(hsi.getServerAddress());
     asi.serverName = new Utf8(hsi.getServerName());

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1363178&r1=1363177&r2=1363178&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Wed Jul 18 23:51:24 2012
@@ -444,9 +444,7 @@ public class HRegionServer implements HR
     }
     this.serverInfo = new HServerInfo(new HServerAddress(
       new InetSocketAddress(address.getBindAddress(), port)),
-      System.currentTimeMillis(),
-      this.conf.getInt(HConstants.REGIONSERVER_INFO_PORT,
-          HConstants.DEFAULT_REGIONSERVER_INFOPORT), machineName);
+      System.currentTimeMillis(), machineName);
     if (this.serverInfo.getServerAddress() == null) {
       throw new NullPointerException("Server address cannot be null; " +
         "hbase-958 debugging");
@@ -1451,12 +1449,11 @@ public class HRegionServer implements HR
           // auto bind enabled, try to use another port
           LOG.info("Failed binding http info server to port: " + port);
           port++;
-          // update HRS server info port.
-          this.serverInfo = new HServerInfo(this.serverInfo.getServerAddress(),
-            this.serverInfo.getStartCode(), port,
-            this.serverInfo.getHostname());
         }
       }
+      // update HRS server info port.
+      this.serverInfo = new HServerInfo(this.serverInfo.getServerAddress(),
+        this.serverInfo.getStartCode(), this.serverInfo.getHostname());
     }
 
     this.replicationHandler.startReplicationServices();

Modified: hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/master.jsp
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/master.jsp?rev=1363178&r1=1363177&r2=1363178&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/master.jsp (original)
+++ hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/master.jsp Wed Jul 18 23:51:24 2012
@@ -14,6 +14,7 @@
   import="org.apache.hadoop.hbase.HColumnDescriptor" %><%
   HMaster master = (HMaster)getServletContext().getAttribute(HMaster.MASTER);
   Configuration conf = master.getConfiguration();
+  int rsInfoPort = conf.getInt(HConstants.REGIONSERVER_INFO_PORT, HConstants.DEFAULT_REGIONSERVER_INFOPORT);
   HServerAddress rootLocation = master.getRegionManager().getRootRegionLocation();
   Map<byte [], MetaRegion> onlineRegions = master.getRegionManager().getOnlineMetaRegions();
   Map<String, HServerInfo> serverToServerInfos =
@@ -144,7 +145,7 @@
      Arrays.sort(serverNames);
      for (String serverName: serverNames) {
        HServerInfo hsi = serverToServerInfos.get(serverName);
-       String hostname = hsi.getServerAddress().getHostname() + ":" + hsi.getInfoPort();
+       String hostname = hsi.getServerAddress().getHostname() + ":" + rsInfoPort;
        String url = "http://" + hostname + "/";
        totalRegions += hsi.getLoad().getNumberOfRegions();
        totalRequests += hsi.getLoad().getNumberOfRequests() / interval;

Modified: hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/table.jsp
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/table.jsp?rev=1363178&r1=1363177&r2=1363178&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/table.jsp (original)
+++ hbase/branches/0.89-fb/src/main/resources/hbase-webapps/master/table.jsp Wed Jul 18 23:51:24 2012
@@ -15,6 +15,7 @@
   import="org.apache.hadoop.hbase.HConstants"%><%
   HMaster master = (HMaster)getServletContext().getAttribute(HMaster.MASTER);
   Configuration conf = master.getConfiguration();
+  int rsInfoPort = conf.getInt(HConstants.REGIONSERVER_INFO_PORT, HConstants.DEFAULT_REGIONSERVER_INFOPORT);
   HBaseAdmin hbadmin = new HBaseAdmin(conf);
   String tableName = request.getParameter("name");
   HTable table = new HTable(conf, tableName);
@@ -84,8 +85,7 @@
 %>
 <%= tableHeader %>
 <%
-  int infoPort = master.getServerManager().getHServerInfo(rootLocation).getInfoPort();
-  String url = "http://" + rootLocation.getHostname() + ":" + infoPort + "/";
+  String url = "http://" + rootLocation.getHostname() + ":" + rsInfoPort + "/";
 %>
 <tr>
   <td><%= tableName %></td>
@@ -102,12 +102,11 @@
 <%
   Map<byte [], MetaRegion> onlineRegions = master.getRegionManager().getOnlineMetaRegions();
   for (MetaRegion meta: onlineRegions.values()) {
-    int infoPort = master.getServerManager().getHServerInfo(meta.getServer()).getInfoPort();
-    String url = "http://" + meta.getServer().getHostname() + ":" + infoPort + "/";
+    String url = "http://" + meta.getServer().getHostname() + ":" + rsInfoPort + "/";
 %>
 <tr>
   <td><%= Bytes.toString(meta.getRegionName()) %></td>
-    <td><a href="<%= url %>"><%= meta.getServer().getHostname().toString() + ":" + infoPort %></a></td>
+    <td><a href="<%= url %>"><%= meta.getServer().getHostname().toString() + ":" + rsInfoPort %></a></td>
     <td>-</td><td><%= Bytes.toString(meta.getStartKey()) %></td><td><%= Bytes.toString(meta.getEndKey()) %></td>
 </tr>
 <%  } %>
@@ -139,13 +138,12 @@
 <%=     tableHeader %>
 <%
   for(Map.Entry<HRegionInfo, HServerAddress> hriEntry : regions.entrySet()) {
-    int infoPort = master.getServerManager().getHServerInfo(hriEntry.getValue()).getInfoPort();
     String urlRegionServer =
-        "http://" + hriEntry.getValue().getHostname().toString() + ":" + infoPort + "/";
+        "http://" + hriEntry.getValue().getHostname().toString() + ":" + rsInfoPort + "/";
 %>
 <tr>
   <td><%= Bytes.toStringBinary(hriEntry.getKey().getRegionName())%></td>
-  <td><a href="<%= urlRegionServer %>"><%= hriEntry.getValue().getHostname().toString() + ":" + infoPort %></a></td>
+  <td><a href="<%= urlRegionServer %>"><%= hriEntry.getValue().getHostname().toString() + ":" + rsInfoPort %></a></td>
   <td><%= Bytes.toStringBinary(hriEntry.getKey().getStartKey())%></td>
   <td><%= Bytes.toStringBinary(hriEntry.getKey().getEndKey())%></td>
 </tr>

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/TestSerialization.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/TestSerialization.java?rev=1363178&r1=1363177&r2=1363178&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/TestSerialization.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/TestSerialization.java Wed Jul 18 23:51:24 2012
@@ -137,8 +137,7 @@ public class TestSerialization extends H
    * @throws Exception
    */
   public void testServerInfo() throws Exception {
-    HServerInfo hsi = new HServerInfo(new HServerAddress("0.0.0.0:123"), -1,
-      1245, "default name");
+    HServerInfo hsi = new HServerInfo(new HServerAddress("0.0.0.0:123"), -1, "default name");
     byte [] b = Writables.getBytes(hsi);
     HServerInfo deserializedHsi =
       (HServerInfo)Writables.getWritable(b, new HServerInfo());

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/master/TestKillingServersFromMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/master/TestKillingServersFromMaster.java?rev=1363178&r1=1363177&r2=1363178&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/master/TestKillingServersFromMaster.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/master/TestKillingServersFromMaster.java Wed Jul 18 23:51:24 2012
@@ -68,8 +68,7 @@ public class TestKillingServersFromMaste
       (MiniHBaseClusterRegionServer)cluster.getRegionServer(0);
     HServerInfo hsi = firstServer.getServerInfo();
     // This constructor creates a new startcode
-    firstServer.setHServerInfo(new HServerInfo(hsi.getServerAddress(),
-      hsi.getInfoPort(), hsi.getHostname()));
+    firstServer.setHServerInfo(new HServerInfo(hsi.getServerAddress(), hsi.getHostname()));
     cluster.waitOnRegionServer(0);
     assertEquals(1, cluster.getLiveRegionServerThreads().size());
   }