From ff8c2fcac0324a1cfa5608062e0e5fc263cb8160 Mon Sep 17 00:00:00 2001 From: Elliott Clark Date: Wed, 22 Jun 2016 15:40:28 -0700 Subject: [PATCH] HBASE-16087 Replication shouldn't start on a master if if only hosts system tables --- .../master/balancer/BaseLoadBalancer.java | 13 +++++++++++++ .../hbase/regionserver/HRegionServer.java | 18 ++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java index 15c0fc2e50e..0a61839f9c6 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java @@ -1001,6 +1001,19 @@ public abstract class BaseLoadBalancer implements LoadBalancer { return tables != null && tables.length > 0; } + public static boolean userTablesOnMaster(Configuration conf) { + String[] tables = getTablesOnMaster(conf); + if (tables == null || tables.length == 0) { + return false; + } + for (String tn:tables) { + if (!tn.startsWith("hbase:")) { + return true; + } + } + return false; + } + @Override public void setConf(Configuration conf) { setSlop(conf); 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 4d6b9b8b576..5e7ce5a5da1 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 @@ -107,6 +107,7 @@ import org.apache.hadoop.hbase.ipc.ServerRpcController; import org.apache.hadoop.hbase.master.HMaster; import org.apache.hadoop.hbase.master.RegionState.State; import org.apache.hadoop.hbase.master.TableLockManager; +import org.apache.hadoop.hbase.master.balancer.BaseLoadBalancer; import org.apache.hadoop.hbase.procedure.RegionServerProcedureManagerHost; import org.apache.hadoop.hbase.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.protobuf.RequestConverter; @@ -447,7 +448,7 @@ public class HRegionServer extends HasThread implements private RegionServerCoprocessorHost rsHost; private RegionServerProcedureManagerHost rspmHost; - + private RegionServerQuotaManager rsQuotaManager; // Table level lock manager for locking for region operations @@ -873,7 +874,7 @@ public class HRegionServer extends HasThread implements // Setup the Quota Manager rsQuotaManager = new RegionServerQuotaManager(this); - + // Setup RPC client for master communication rpcClient = RpcClientFactory.createClient(conf, clusterId, new InetSocketAddress( rpcServices.isa.getAddress(), 0), clusterConnection.getConnectionMetrics()); @@ -942,7 +943,7 @@ public class HRegionServer extends HasThread implements // since the server is ready to run rspmHost.start(); } - + // Start the Quota Manager if (this.rsQuotaManager != null) { rsQuotaManager.start(getRpcServer().getScheduler()); @@ -1036,7 +1037,7 @@ public class HRegionServer extends HasThread implements if (rsQuotaManager != null) { rsQuotaManager.stop(); } - + // Stop the snapshot and other procedure handlers, forcefully killing all running tasks if (rspmHost != null) { rspmHost.stop(this.abortRequested || this.killed); @@ -2600,7 +2601,7 @@ public class HRegionServer extends HasThread implements public ChoreService getChoreService() { return choreService; } - + @Override public RegionServerQuotaManager getRegionServerQuotaManager() { return rsQuotaManager; @@ -2622,6 +2623,11 @@ public class HRegionServer extends HasThread implements return; } + if ((server instanceof HMaster) && + (!BaseLoadBalancer.userTablesOnMaster(conf))) { + return; + } + // read in the name of the source replication class from the config file. String sourceClassname = conf.get(HConstants.REPLICATION_SOURCE_SERVICE_CLASSNAME, HConstants.REPLICATION_SERVICE_CLASSNAME_DEFAULT); @@ -2723,7 +2729,7 @@ public class HRegionServer extends HasThread implements } return tableRegions; } - + /** * Gets the online tables in this RS. * This method looks at the in-memory onlineRegions.