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; 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 @Override
public void setConf(Configuration conf) { public void setConf(Configuration conf) {
setSlop(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.HMaster;
import org.apache.hadoop.hbase.master.RegionState.State; import org.apache.hadoop.hbase.master.RegionState.State;
import org.apache.hadoop.hbase.master.TableLockManager; 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.procedure.RegionServerProcedureManagerHost;
import org.apache.hadoop.hbase.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.RequestConverter; import org.apache.hadoop.hbase.protobuf.RequestConverter;
@ -2622,6 +2623,11 @@ public class HRegionServer extends HasThread implements
return; return;
} }
if ((server instanceof HMaster) &&
(!BaseLoadBalancer.userTablesOnMaster(conf))) {
return;
}
// read in the name of the source replication class from the config file. // read in the name of the source replication class from the config file.
String sourceClassname = conf.get(HConstants.REPLICATION_SOURCE_SERVICE_CLASSNAME, String sourceClassname = conf.get(HConstants.REPLICATION_SOURCE_SERVICE_CLASSNAME,
HConstants.REPLICATION_SERVICE_CLASSNAME_DEFAULT); HConstants.REPLICATION_SERVICE_CLASSNAME_DEFAULT);