Repository: hbase Updated Branches: refs/heads/branch-1 1318e84e1 -> ff8c2fcac
HBASE-16087 Replication shouldn't start on a master if if only hosts system tables Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/ff8c2fca Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/ff8c2fca Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/ff8c2fca Branch: refs/heads/branch-1 Commit: ff8c2fcac0324a1cfa5608062e0e5fc263cb8160 Parents: 1318e84 Author: Elliott Clark <ecl...@apache.org> Authored: Wed Jun 22 15:40:28 2016 -0700 Committer: Elliott Clark <ecl...@apache.org> Committed: Tue Jul 5 13:47:49 2016 -0700 ---------------------------------------------------------------------- .../hbase/master/balancer/BaseLoadBalancer.java | 13 +++++++++++++ .../hadoop/hbase/regionserver/HRegionServer.java | 18 ++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/ff8c2fca/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java ---------------------------------------------------------------------- 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 15c0fc2..0a61839 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); http://git-wip-us.apache.org/repos/asf/hbase/blob/ff8c2fca/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 4d6b9b8..5e7ce5a 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.