HBASE-19937 Ensure createRSGroupTable be called after ProcedureExecutor and LoadBalancer are initialized
Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
parent
4461cb7d7a
commit
285653de3c
|
@ -386,6 +386,12 @@ public class RSGroupBasedLoadBalancer implements RSGroupableBalancer {
|
|||
throw new HBaseIOException(msg);
|
||||
}
|
||||
rsGroupInfoManager = cps.get(0).getGroupInfoManager();
|
||||
if(rsGroupInfoManager == null){
|
||||
String msg = "RSGroupInfoManager hasn't been initialized";
|
||||
LOG.error(msg);
|
||||
throw new HBaseIOException(msg);
|
||||
}
|
||||
rsGroupInfoManager.start();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new HBaseIOException("Failed to initialize GroupInfoManagerImpl", e);
|
||||
|
|
|
@ -48,6 +48,8 @@ public interface RSGroupInfoManager {
|
|||
byte[] META_QUALIFIER_BYTES = Bytes.toBytes("i");
|
||||
byte[] ROW_KEY = {0};
|
||||
|
||||
void start();
|
||||
|
||||
/**
|
||||
* Add given RSGroupInfo to existing list of group infos.
|
||||
*/
|
||||
|
|
|
@ -155,7 +155,6 @@ final class RSGroupInfoManagerImpl implements RSGroupInfoManager {
|
|||
|
||||
private synchronized void init() throws IOException{
|
||||
refresh();
|
||||
rsGroupStartupWorker.start();
|
||||
serverEventsListenerThread.start();
|
||||
masterServices.getServerManager().registerListener(serverEventsListenerThread);
|
||||
failedOpenUpdaterThread = new FailedOpenUpdaterThread(masterServices.getConfiguration());
|
||||
|
@ -169,6 +168,11 @@ final class RSGroupInfoManagerImpl implements RSGroupInfoManager {
|
|||
return instance;
|
||||
}
|
||||
|
||||
public void start(){
|
||||
// create system table of rsgroup
|
||||
rsGroupStartupWorker.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addRSGroup(RSGroupInfo rsGroupInfo) throws IOException {
|
||||
checkGroupName(rsGroupInfo.getName());
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
/**
|
||||
* 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 static java.lang.Thread.sleep;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
|
||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Test enable RSGroup
|
||||
*/
|
||||
@Category({ MediumTests.class })
|
||||
public class TestEnableRSGroup {
|
||||
|
||||
@ClassRule
|
||||
public static final HBaseClassTestRule CLASS_RULE =
|
||||
HBaseClassTestRule.forClass(TestEnableRSGroup.class);
|
||||
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(TestEnableRSGroup.class);
|
||||
|
||||
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
|
||||
private static Configuration conf = TEST_UTIL.getConfiguration();
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
conf.setBoolean(CoprocessorHost.COPROCESSORS_ENABLED_CONF_KEY, true);
|
||||
TEST_UTIL.startMiniCluster(5);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() throws Exception {
|
||||
LOG.info("to stop miniCluster");
|
||||
TEST_UTIL.shutdownMiniCluster();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnableRSGroup() throws IOException, InterruptedException {
|
||||
TEST_UTIL.getMiniHBaseCluster().stopMaster(0);
|
||||
|
||||
LOG.info("stopped master...");
|
||||
conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, RSGroupAdminEndpoint.class.getName());
|
||||
conf.set(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, RSGroupBasedLoadBalancer.class.getName());
|
||||
TEST_UTIL.getMiniHBaseCluster().setConf(conf);
|
||||
|
||||
TEST_UTIL.getMiniHBaseCluster().startMaster();
|
||||
TEST_UTIL.getMiniHBaseCluster().waitForActiveAndReadyMaster(60000);
|
||||
LOG.info("started master...");
|
||||
|
||||
// check if master started successfully
|
||||
assertTrue(TEST_UTIL.getMiniHBaseCluster().getMaster() != null);
|
||||
|
||||
// wait RSGroupBasedLoadBalancer online
|
||||
RSGroupBasedLoadBalancer loadBalancer =
|
||||
(RSGroupBasedLoadBalancer) TEST_UTIL.getMiniHBaseCluster().getMaster().getLoadBalancer();
|
||||
long start = System.currentTimeMillis();
|
||||
while (System.currentTimeMillis() - start <= 60000 && !loadBalancer.isOnline()) {
|
||||
LOG.info("waiting for rsgroup load balancer onLine...");
|
||||
sleep(200);
|
||||
}
|
||||
|
||||
assertTrue(loadBalancer.isOnline());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue