hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject hbase git commit: HBASE-13481 Master should respect master (old) DNS/bind related configurations
Date Sat, 18 Apr 2015 01:14:50 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 b655a9909 -> 49bf9aec8


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/49bf9aec
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/49bf9aec
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/49bf9aec

Branch: refs/heads/branch-1
Commit: 49bf9aec8b1c8f25f74053cb62e2b98fa7ede13f
Parents: b655a99
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:13:47 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/49bf9aec/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 27b6e8d..b8fecb2 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
@@ -404,7 +404,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.
@@ -526,7 +528,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);
@@ -1730,13 +1736,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/49bf9aec/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 a10e0c3..cf2f34b 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
@@ -824,17 +824,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);
     }
@@ -866,12 +872,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;
@@ -1521,6 +1530,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/49bf9aec/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/49bf9aec/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 1dbb1ce..15ff5a1 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
@@ -48,7 +48,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) {
@@ -80,7 +80,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