HBASE-19937 Ensure createRSGroupTable be called after ProcedureExecutor and LoadBalancer are initialized
Signed-off-by: tedyu <yuzhihong@gmail.com> Amending-Author: Andrew Purtell <apurtell@apache.org> Conflicts: hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java
This commit is contained in:
parent
0cbb19201c
commit
1911461a56
|
@ -387,6 +387,12 @@ public class RSGroupBasedLoadBalancer implements RSGroupableBalancer, LoadBalanc
|
|||
throw new HBaseIOException(msg);
|
||||
}
|
||||
infoManager = cps.get(0).getGroupInfoManager();
|
||||
if(infoManager == null){
|
||||
String msg = "RSGroupInfoManager hasn't been initialized";
|
||||
LOG.error(msg);
|
||||
throw new HBaseIOException(msg);
|
||||
}
|
||||
infoManager.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.
|
||||
*/
|
||||
|
|
|
@ -137,7 +137,6 @@ public class RSGroupInfoManagerImpl implements RSGroupInfoManager, ServerListene
|
|||
public void init() throws IOException{
|
||||
rsGroupStartupWorker = new RSGroupStartupWorker(this, master, conn);
|
||||
refresh();
|
||||
rsGroupStartupWorker.start();
|
||||
defaultServerUpdater = new DefaultServerUpdater(this);
|
||||
Threads.setDaemonThreadRunning(defaultServerUpdater);
|
||||
failedOpenUpdater = new FailedOpenUpdater(this);
|
||||
|
@ -150,6 +149,11 @@ public class RSGroupInfoManagerImpl implements RSGroupInfoManager, ServerListene
|
|||
return isInit;
|
||||
}
|
||||
|
||||
public void start(){
|
||||
// create system table of rsgroup
|
||||
rsGroupStartupWorker.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the group.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
/**
|
||||
* 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 org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.Waiter;
|
||||
import org.apache.hadoop.hbase.Waiter.ExplainingPredicate;
|
||||
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.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Test enable RSGroup
|
||||
*/
|
||||
@Category({ MediumTests.class })
|
||||
public class TestEnableRSGroup {
|
||||
|
||||
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 {
|
||||
TEST_UTIL.startMiniCluster();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() throws Exception {
|
||||
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
|
||||
Waiter.waitFor(TEST_UTIL.getConfiguration(), 60000, new ExplainingPredicate<IOException>() {
|
||||
@Override
|
||||
public boolean evaluate() throws IOException {
|
||||
return TEST_UTIL.getMiniHBaseCluster().getMaster() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String explainFailure() throws IOException {
|
||||
return "Master failed to start up";
|
||||
}
|
||||
});
|
||||
|
||||
// wait RSGroupBasedLoadBalancer online
|
||||
Waiter.waitFor(TEST_UTIL.getConfiguration(), 60000, new ExplainingPredicate<IOException>() {
|
||||
@Override
|
||||
public boolean evaluate() throws IOException {
|
||||
RSGroupBasedLoadBalancer loadBalancer =
|
||||
(RSGroupBasedLoadBalancer) TEST_UTIL.getMiniHBaseCluster().getMaster().getLoadBalancer();
|
||||
return loadBalancer != null && loadBalancer.isOnline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String explainFailure() throws IOException {
|
||||
return "RSGroupBasedLoadBalancer failed to come online";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue