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 d3a4c9555c9..7a4ba3da583 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 @@ -186,6 +186,7 @@ import org.apache.hadoop.hbase.replication.master.ReplicationHFileCleaner; import org.apache.hadoop.hbase.replication.master.ReplicationLogCleaner; import org.apache.hadoop.hbase.replication.master.ReplicationPeerConfigUpgrader; import org.apache.hadoop.hbase.replication.regionserver.ReplicationStatus; +import org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint; import org.apache.hadoop.hbase.rsgroup.RSGroupBasedLoadBalancer; import org.apache.hadoop.hbase.rsgroup.RSGroupInfoManager; import org.apache.hadoop.hbase.security.AccessDeniedException; @@ -800,6 +801,17 @@ public class HMaster extends HRegionServer implements MasterServices { this.splitOrMergeTracker = new SplitOrMergeTracker(zooKeeper, conf, this); this.splitOrMergeTracker.start(); + // This is for backwards compatible. We do not need the CP for rs group now but if user want to + // load it, we need to enable rs group. + String[] cpClasses = conf.getStrings(MasterCoprocessorHost.MASTER_COPROCESSOR_CONF_KEY); + if (cpClasses != null) { + for (String cpClass : cpClasses) { + if (RSGroupAdminEndpoint.class.getName().equals(cpClass)) { + conf.setBoolean(RSGroupInfoManager.RS_GROUP_ENABLED, true); + break; + } + } + } this.rsGroupInfoManager = RSGroupInfoManager.create(this); this.replicationPeerManager = ReplicationPeerManager.create(zooKeeper, conf); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/DisabledRSGroupInfoManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/DisabledRSGroupInfoManager.java new file mode 100644 index 00000000000..0762750ebfb --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/DisabledRSGroupInfoManager.java @@ -0,0 +1,109 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.rsgroup; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; +import org.apache.hadoop.hbase.DoNotRetryIOException; +import org.apache.hadoop.hbase.ServerName; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.master.ServerManager; +import org.apache.hadoop.hbase.net.Address; +import org.apache.yetus.audience.InterfaceAudience; + +/** + * A dummy RSGroupInfoManager which only contains a default rs group. + */ +@InterfaceAudience.Private +class DisabledRSGroupInfoManager implements RSGroupInfoManager { + + private final ServerManager serverManager; + + public DisabledRSGroupInfoManager(ServerManager serverManager) { + this.serverManager = serverManager; + } + + @Override + public void start() { + } + + @Override + public void addRSGroup(RSGroupInfo rsGroupInfo) throws IOException { + throw new DoNotRetryIOException("RSGroup is disabled"); + } + + @Override + public void removeRSGroup(String groupName) throws IOException { + throw new DoNotRetryIOException("RSGroup is disabled"); + } + + @Override + public Set
moveServers(Set
servers, String srcGroup, String dstGroup) + throws IOException { + throw new DoNotRetryIOException("RSGroup is disabled"); + } + + private SortedSet
getOnlineServers() { + SortedSet
onlineServers = new TreeSet
(); + serverManager.getOnlineServers().keySet().stream().map(ServerName::getAddress) + .forEach(onlineServers::add); + return onlineServers; + } + + @Override + public RSGroupInfo getRSGroupOfServer(Address serverHostPort) throws IOException { + SortedSet
onlineServers = getOnlineServers(); + if (onlineServers.contains(serverHostPort)) { + return new RSGroupInfo(RSGroupInfo.DEFAULT_GROUP, onlineServers); + } else { + return null; + } + } + + @Override + public RSGroupInfo getRSGroup(String groupName) throws IOException { + if (RSGroupInfo.DEFAULT_GROUP.equals(groupName)) { + return new RSGroupInfo(RSGroupInfo.DEFAULT_GROUP, getOnlineServers()); + } else { + return null; + } + } + + @Override + public List listRSGroups() throws IOException { + return Arrays.asList(new RSGroupInfo(RSGroupInfo.DEFAULT_GROUP, getOnlineServers())); + } + + @Override + public boolean isOnline() { + return true; + } + + @Override + public void removeServers(Set
servers) throws IOException { + } + + @Override + public RSGroupInfo getRSGroupForTable(TableName tableName) throws IOException { + return null; + } +} diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManager.java index a46fa4bcb1a..3f73f783770 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManager.java @@ -32,6 +32,8 @@ import org.apache.yetus.audience.InterfaceAudience; @InterfaceAudience.Private public interface RSGroupInfoManager { + static final String RS_GROUP_ENABLED = "hbase.balancer.rsgroup.enabled"; + void start(); /** @@ -90,6 +92,10 @@ public interface RSGroupInfoManager { RSGroupInfo getRSGroupForTable(TableName tableName) throws IOException; static RSGroupInfoManager create(MasterServices master) throws IOException { - return RSGroupInfoManagerImpl.getInstance(master); + if (master.getConfiguration().getBoolean(RS_GROUP_ENABLED, false)) { + return RSGroupInfoManagerImpl.getInstance(master); + } else { + return new DisabledRSGroupInfoManager(master.getServerManager()); + } } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestNamespace.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestNamespace.java index df161c9853a..9eb7d819a97 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestNamespace.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestNamespace.java @@ -117,8 +117,7 @@ public class TestNamespace { assertEquals(2, admin.listNamespaceDescriptors().length); //verify existence of system tables - Set systemTables = Sets.newHashSet( - TableName.META_TABLE_NAME, TableName.valueOf("hbase:rsgroup")); + Set systemTables = Sets.newHashSet(TableName.META_TABLE_NAME); List descs = admin.listTableDescriptorsByNamespace( Bytes.toBytes(NamespaceDescriptor.SYSTEM_NAMESPACE.getName())); assertEquals(systemTables.size(), descs.size()); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/AbstractTestDLS.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/AbstractTestDLS.java index fc2e9f79c38..a576adc8d19 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/AbstractTestDLS.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/AbstractTestDLS.java @@ -504,14 +504,14 @@ public abstract class AbstractTestDLS { for (String oregion : regions) LOG.debug("Region still online: " + oregion); } - assertEquals(2 + existingRegions, regions.size()); + assertEquals(1 + existingRegions, regions.size()); LOG.debug("Enabling table\n"); TEST_UTIL.getAdmin().enableTable(tableName); LOG.debug("Waiting for no more RIT\n"); blockUntilNoRIT(); LOG.debug("Verifying there are " + numRegions + " assigned on cluster\n"); regions = HBaseTestingUtility.getAllOnlineRegions(cluster); - assertEquals(numRegions + 2 + existingRegions, regions.size()); + assertEquals(numRegions + 1 + existingRegions, regions.size()); return table; } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestClusterRestart.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestClusterRestart.java index a8d80b6068d..e880f979047 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestClusterRestart.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestClusterRestart.java @@ -43,7 +43,7 @@ public class TestClusterRestart extends AbstractTestRestartCluster { private static final Logger LOG = LoggerFactory.getLogger(TestClusterRestart.class); - private static final int NUM_REGIONS = 4; + private static final int NUM_REGIONS = 3; @Override protected boolean splitWALCoordinatedByZk() { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java index 61720df33f2..75d9ee199b9 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java @@ -25,7 +25,6 @@ import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.MiniHBaseCluster; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.StartMiniClusterOption; -import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.test.MetricsAssertHelper; import org.apache.hadoop.hbase.testclassification.MasterTests; import org.apache.hadoop.hbase.testclassification.MediumTests; @@ -91,7 +90,6 @@ public class TestMasterMetrics { cluster = TEST_UTIL.getHBaseCluster(); LOG.info("Waiting for active/ready master"); cluster.waitForActiveAndReadyMaster(); - TEST_UTIL.waitTableAvailable(TableName.valueOf("hbase:rsgroup")); master = cluster.getMaster(); } @@ -133,7 +131,7 @@ public class TestMasterMetrics { MetricsMasterSource masterSource = master.getMasterMetrics().getMetricsSource(); boolean tablesOnMaster = LoadBalancer.isTablesOnMaster(TEST_UTIL.getConfiguration()); metricsHelper.assertGauge("numRegionServers", 1 + (tablesOnMaster ? 1 : 0), masterSource); - metricsHelper.assertGauge("averageLoad", 2, masterSource); + metricsHelper.assertGauge("averageLoad", 1, masterSource); metricsHelper.assertGauge("numDeadRegionServers", 0, masterSource); metricsHelper.assertGauge("masterStartTime", master.getMasterStartTime(), masterSource); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java index 2d0af3e9750..fca2866e380 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java @@ -92,7 +92,7 @@ public class TestMasterRestartAfterDisablingTable { NavigableSet regions = HBaseTestingUtility.getAllOnlineRegions(cluster); assertEquals("The number of regions for the table tableRestart should be 0 and only" + - "the catalog table should be present.", 2, regions.size()); + "the catalog table should be present.", 1, regions.size()); List masterThreads = cluster.getMasterThreads(); MasterThread activeMaster = null; @@ -120,7 +120,7 @@ public class TestMasterRestartAfterDisablingTable { log("Verifying there are " + numRegions + " assigned on cluster\n"); regions = HBaseTestingUtility.getAllOnlineRegions(cluster); assertEquals("The assigned regions were not onlined after master" + - " switch except for the catalog table.", 6, regions.size()); + " switch except for the catalog table.", 5, regions.size()); assertTrue("The table should be in enabled state", cluster.getMaster().getTableStateManager() .isTableState(TableName.valueOf(name.getMethodName()), TableState.State.ENABLED)); ht.close(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRollingRestart.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRollingRestart.java index 2dc1b6c7a0e..0aba4874782 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRollingRestart.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRollingRestart.java @@ -121,7 +121,7 @@ public class TestRollingRestart { log("Region still online: " + oregion); } } - assertEquals(2, regions.size()); + assertEquals(1, regions.size()); log("Enabling table\n"); TEST_UTIL.getAdmin().enableTable(tableName); log("Waiting for no more RIT\n"); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionOpen.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionOpen.java index 2503825a218..7d525086d81 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionOpen.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionOpen.java @@ -86,7 +86,6 @@ public class TestRegionOpen { final TableName tableName = TableName.valueOf(TestRegionOpen.class.getSimpleName()); ThreadPoolExecutor exec = getRS().getExecutorService() .getExecutorThreadPool(ExecutorType.RS_OPEN_PRIORITY_REGION); - HTU.waitTableAvailable(TableName.valueOf("hbase:rsgroup")); long completed = exec.getCompletedTaskCount(); HTableDescriptor htd = new HTableDescriptor(tableName); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionReplicasWithRestartScenarios.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionReplicasWithRestartScenarios.java index 6211db680b6..d4e250708e2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionReplicasWithRestartScenarios.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionReplicasWithRestartScenarios.java @@ -156,7 +156,7 @@ public class TestRegionReplicasWithRestartScenarios { assertFalse(res); int totalRegions = HTU.getMiniHBaseCluster().getLiveRegionServerThreads().stream(). mapToInt(l -> l.getRegionServer().getOnlineRegions().size()).sum(); - assertEquals(62, totalRegions); + assertEquals(61, totalRegions); } private boolean checkDuplicates(Collection onlineRegions3) throws Exception { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java index 8361d58de00..833e78ba3b0 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java @@ -231,7 +231,7 @@ public class TestRegionServerMetrics { @Test public void testRegionCount() throws Exception { - metricsHelper.assertGauge("regionCount", TABLES_ON_MASTER ? 1 : 3, serverSource); + metricsHelper.assertGauge("regionCount", TABLES_ON_MASTER ? 1 : 2, serverSource); } @Test @@ -341,7 +341,7 @@ public class TestRegionServerMetrics { TEST_UTIL.getAdmin().flush(tableName); metricsRegionServer.getRegionServerWrapper().forceRecompute(); - assertGauge("storeCount", TABLES_ON_MASTER ? 1 : 6); + assertGauge("storeCount", TABLES_ON_MASTER ? 1 : 5); assertGauge("storeFileCount", 1); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestTablePermissions.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestTablePermissions.java index 3de38a7fc4c..79436d3aee1 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestTablePermissions.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestTablePermissions.java @@ -102,7 +102,7 @@ public class TestTablePermissions { // Wait for the ACL table to become available UTIL.waitTableEnabled(PermissionStorage.ACL_TABLE_NAME); - UTIL.waitTableAvailable(TableName.valueOf("hbase:rsgroup")); + UTIL.waitTableAvailable(TableName.valueOf("hbase:acl")); ZKW = new ZKWatcher(UTIL.getConfiguration(), "TestTablePermissions", ABORTABLE); @@ -223,7 +223,7 @@ public class TestTablePermissions { // check full load Map> allPerms = PermissionStorage.loadAll(conf); assertEquals("Full permission map should have entries for both test tables", - 3, allPerms.size()); + 2, allPerms.size()); userPerms = allPerms.get(TEST_TABLE.getName()).get("hubert"); assertNotNull(userPerms); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckReplication.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckReplication.java index 0ac07d869aa..316a321f2b7 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckReplication.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckReplication.java @@ -24,7 +24,6 @@ import java.util.stream.Stream; import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.ServerName; -import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.replication.ReplicationPeerConfig; import org.apache.hadoop.hbase.replication.ReplicationPeerStorage; import org.apache.hadoop.hbase.replication.ReplicationQueueStorage; @@ -53,7 +52,6 @@ public class TestHBaseFsckReplication { public static void setUp() throws Exception { UTIL.getConfiguration().setBoolean("hbase.write.hbck1.lock.file", false); UTIL.startMiniCluster(1); - UTIL.waitTableAvailable(TableName.valueOf("hbase:rsgroup")); } @AfterClass