hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mberto...@apache.org
Subject [16/19] hbase git commit: HBASE-13481 Master should respect master (old) DNS/bind related configurations
Date Sat, 18 Apr 2015 09:26:19 GMT
HBASE-13481 Master should respect master (old) DNS/bind related configurations


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/66e55ff3
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/66e55ff3
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/66e55ff3

Branch: refs/heads/hbase-12439
Commit: 66e55ff38898560385dcd7406e805ed7fad2f000
Parents: abe3796
Author: Enis Soztutar <enis@apache.org>
Authored: Fri Apr 17 18:11:26 2015 -0700
Committer: Enis Soztutar <enis@apache.org>
Committed: Fri Apr 17 18:11:26 2015 -0700

----------------------------------------------------------------------
 .../hbase/regionserver/HRegionServer.java       | 15 ++++++--
 .../hbase/regionserver/RSRpcServices.java       | 36 +++++++++++++-------
 .../compactions/RatioBasedCompactionPolicy.java |  4 ++-
 .../regionserver/TestRegionServerHostname.java  |  4 +--
 4 files changed, 40 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/66e55ff3/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
index 0cc1e51..2e22e33 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -408,7 +408,9 @@ public class HRegionServer extends HasThread implements
   // key to the config parameter of server hostname
   // the specification of server hostname is optional. The hostname should be resolvable
from
   // both master and region server
-  final static String HOSTNAME_KEY = "hbase.regionserver.hostname";
+  final static String RS_HOSTNAME_KEY = "hbase.regionserver.hostname";
+
+  final static String MASTER_HOSTNAME_KEY = "hbase.master.hostname";
 
   /**
    * This servers startcode.
@@ -528,7 +530,11 @@ public class HRegionServer extends HasThread implements
 
     rpcServices = createRpcServices();
     this.startcode = System.currentTimeMillis();
-    useThisHostnameInstead = conf.get(HOSTNAME_KEY);
+    if (this instanceof HMaster) {
+      useThisHostnameInstead = conf.get(MASTER_HOSTNAME_KEY);
+    } else {
+      useThisHostnameInstead = conf.get(RS_HOSTNAME_KEY);
+    }
     String hostName = shouldUseThisHostnameInstead() ? useThisHostnameInstead :
       rpcServices.isa.getHostName();
     serverName = ServerName.valueOf(hostName, rpcServices.isa.getPort(), startcode);
@@ -1734,13 +1740,16 @@ public class HRegionServer extends HasThread implements
   private int putUpWebUI() throws IOException {
     int port = this.conf.getInt(HConstants.REGIONSERVER_INFO_PORT,
       HConstants.DEFAULT_REGIONSERVER_INFOPORT);
+    String addr = this.conf.get("hbase.regionserver.info.bindAddress", "0.0.0.0");
+
     if(this instanceof HMaster) {
       port = conf.getInt(HConstants.MASTER_INFO_PORT,
           HConstants.DEFAULT_MASTER_INFOPORT);
+      addr = this.conf.get("hbase.master.info.bindAddress", "0.0.0.0");
     }
     // -1 is for disabling info server
     if (port < 0) return port;
-    String addr = this.conf.get("hbase.regionserver.info.bindAddress", "0.0.0.0");
+
     if (!Addressing.isLocalAddress(InetAddress.getByName(addr))) {
       String msg =
           "Failed to start http info server. Address " + addr

http://git-wip-us.apache.org/repos/asf/hbase/blob/66e55ff3/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
index f322862..d09bd8d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
@@ -822,17 +822,23 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
       throw new IllegalArgumentException(e);
     }
     // Server to handle client requests.
-    String hostname = getHostname(rs.conf);
-    int port = rs.conf.getInt(HConstants.REGIONSERVER_PORT,
-      HConstants.DEFAULT_REGIONSERVER_PORT);
+    InetSocketAddress initialIsa;
+    InetSocketAddress bindAddress;
     if(this instanceof MasterRpcServices) {
-      port = rs.conf.getInt(HConstants.MASTER_PORT,
-          HConstants.DEFAULT_MASTER_PORT);
+      String hostname = getHostname(rs.conf, true);
+      int port = rs.conf.getInt(HConstants.MASTER_PORT, HConstants.DEFAULT_MASTER_PORT);
+      // Creation of a HSA will force a resolve.
+      initialIsa = new InetSocketAddress(hostname, port);
+      bindAddress = new InetSocketAddress(rs.conf.get("hbase.master.ipc.address", hostname),
port);
+    } else {
+      String hostname = getHostname(rs.conf, false);
+      int port = rs.conf.getInt(HConstants.REGIONSERVER_PORT,
+        HConstants.DEFAULT_REGIONSERVER_PORT);
+      // Creation of a HSA will force a resolve.
+      initialIsa = new InetSocketAddress(hostname, port);
+      bindAddress = new InetSocketAddress(
+        rs.conf.get("hbase.regionserver.ipc.address", hostname), port);
     }
-    // Creation of a HSA will force a resolve.
-    InetSocketAddress initialIsa = new InetSocketAddress(hostname, port);
-    InetSocketAddress bindAddress = new InetSocketAddress(
-      rs.conf.get("hbase.regionserver.ipc.address", hostname), port);
     if (initialIsa.getAddress() == null) {
       throw new IllegalArgumentException("Failed resolve of " + initialIsa);
     }
@@ -864,12 +870,15 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
     rs.setName(name);
   }
 
-  public static String getHostname(Configuration conf) throws UnknownHostException {
-    String hostname = conf.get(HRegionServer.HOSTNAME_KEY);
+  public static String getHostname(Configuration conf, boolean isMaster)
+      throws UnknownHostException {
+    String hostname = conf.get(isMaster? HRegionServer.MASTER_HOSTNAME_KEY :
+      HRegionServer.RS_HOSTNAME_KEY);
     if (hostname == null || hostname.isEmpty()) {
+      String masterOrRS = isMaster ? "master" : "regionserver";
       return Strings.domainNamePointerToHostName(DNS.getDefaultHost(
-        conf.get("hbase.regionserver.dns.interface", "default"),
-        conf.get("hbase.regionserver.dns.nameserver", "default")));
+        conf.get("hbase." + masterOrRS + ".dns.interface", "default"),
+        conf.get("hbase." + masterOrRS + ".dns.nameserver", "default")));
     } else {
       LOG.info("hostname is configured to be " + hostname);
       return hostname;
@@ -1493,6 +1502,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
    * @param request the request
    * @throws ServiceException
    */
+  @Override
   public WarmupRegionResponse warmupRegion(final RpcController controller,
       final WarmupRegionRequest request) throws ServiceException {
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/66e55ff3/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/RatioBasedCompactionPolicy.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/RatioBasedCompactionPolicy.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/RatioBasedCompactionPolicy.java
index 0db5c00..5aeff5c 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/RatioBasedCompactionPolicy.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/RatioBasedCompactionPolicy.java
@@ -277,6 +277,7 @@ public class RatioBasedCompactionPolicy extends CompactionPolicy {
    * @param filesToCompact Files to compact. Can be null.
    * @return True if we should run a major compaction.
    */
+  @Override
   public boolean isMajorCompaction(final Collection<StoreFile> filesToCompact)
       throws IOException {
     boolean result = false;
@@ -300,7 +301,7 @@ public class RatioBasedCompactionPolicy extends CompactionPolicy {
         if (sf.isMajorCompaction() &&
             (cfTtl == HConstants.FOREVER || oldest < cfTtl)) {
           float blockLocalityIndex = sf.getHDFSBlockDistribution().getBlockLocalityIndex(
-              RSRpcServices.getHostname(comConf.conf)
+              RSRpcServices.getHostname(comConf.conf, false)
           );
           if (blockLocalityIndex < comConf.getMinLocalityToForceCompact()) {
             if (LOG.isDebugEnabled()) {
@@ -375,6 +376,7 @@ public class RatioBasedCompactionPolicy extends CompactionPolicy {
    * @param compactionSize Total size of some compaction
    * @return whether this should be a large or small compaction
    */
+  @Override
   public boolean throttleCompaction(long compactionSize) {
     return compactionSize > comConf.getThrottlePoint();
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/66e55ff3/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerHostname.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerHostname.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerHostname.java
index 44cc94c..e02090b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerHostname.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerHostname.java
@@ -56,7 +56,7 @@ public class TestRegionServerHostname {
     final int NUM_MASTERS = 1;
     final int NUM_RS = 1;
     String invalidHostname = "hostAddr.invalid";
-    TEST_UTIL.getConfiguration().set(HRegionServer.HOSTNAME_KEY, invalidHostname);
+    TEST_UTIL.getConfiguration().set(HRegionServer.RS_HOSTNAME_KEY, invalidHostname);
     try {
       TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
     } catch (IOException ioe) {
@@ -88,7 +88,7 @@ public class TestRegionServerHostname {
         String hostName = addr.getHostName();
         LOG.info("Found " + hostName + " on " + ni);
         
-        TEST_UTIL.getConfiguration().set(HRegionServer.HOSTNAME_KEY, hostName);
+        TEST_UTIL.getConfiguration().set(HRegionServer.RS_HOSTNAME_KEY, hostName);
         TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
         try {
           ZooKeeperWatcher zkw = TEST_UTIL.getZooKeeperWatcher();


Mime
View raw message