HBASE-16087 Replication shouldn't start on a master if if only hosts system tables

This commit is contained in:
Elliott Clark 2016-06-22 15:40:28 -07:00
parent 1318e84e14
commit ff8c2fcac0
2 changed files with 25 additions and 6 deletions

View File

@ -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);

View File

@ -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.