From 349a56ae2c88e62917ba8923283ad4ca0c83841c Mon Sep 17 00:00:00 2001 From: Ted Yu Date: Fri, 17 Oct 2014 20:52:55 +0000 Subject: [PATCH] HBASE-12263 RegionServer listens on localhost in distributed cluster when DNS is unavailable (Shaohui) --- .../java/org/apache/hadoop/hbase/master/HMaster.java | 2 +- .../hadoop/hbase/regionserver/RSRpcServices.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index 831c4dacc27..507d31d6792 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -275,7 +275,7 @@ public class HMaster extends HRegionServer implements MasterServices, Server { conf.getLong("hbase.master.buffer.for.rs.fatals", 1*1024*1024)); LOG.info("hbase.rootdir=" + FSUtils.getRootDir(this.conf) + - ", hbase.cluster.distributed=" + this.conf.getBoolean("hbase.cluster.distributed", false)); + ", hbase.cluster.distributed=" + this.conf.getBoolean(HConstants.CLUSTER_DISTRIBUTED, false)); Replication.decorateMasterConfiguration(this.conf); 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 dc4bf7b7683..bf94cdbd877 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 @@ -767,6 +767,17 @@ public class RSRpcServices implements HBaseRPCErrorHandler, Strings.domainNamePointerToHostName(DNS.getDefaultHost( rs.conf.get("hbase.regionserver.dns.interface", "default"), rs.conf.get("hbase.regionserver.dns.nameserver", "default")))); + + boolean mode = + rs.conf.getBoolean(HConstants.CLUSTER_DISTRIBUTED, HConstants.DEFAULT_CLUSTER_DISTRIBUTED); + if (mode == HConstants.CLUSTER_IS_DISTRIBUTED && hostname.equals(HConstants.LOCALHOST)) { + String msg = + "The hostname of regionserver cannot be set to localhost " + + "in a fully-distributed setup because it won't be reachable. " + + "See \"Getting Started\" for more information."; + LOG.fatal(msg); + throw new IOException(msg); + } int port = rs.conf.getInt(HConstants.REGIONSERVER_PORT, HConstants.DEFAULT_REGIONSERVER_PORT); // Creation of a HSA will force a resolve.