HBASE-26230 Start an in process HRegionServer in maintenance mode (#3659)
Signed-off-by: Yi Mei <myimeiyi@gmail.com>
This commit is contained in:
parent
ec747bcb29
commit
dd293c8ba9
|
@ -215,6 +215,7 @@ import org.apache.hadoop.hbase.util.FutureUtils;
|
||||||
import org.apache.hadoop.hbase.util.HBaseFsck;
|
import org.apache.hadoop.hbase.util.HBaseFsck;
|
||||||
import org.apache.hadoop.hbase.util.HFileArchiveUtil;
|
import org.apache.hadoop.hbase.util.HFileArchiveUtil;
|
||||||
import org.apache.hadoop.hbase.util.IdLock;
|
import org.apache.hadoop.hbase.util.IdLock;
|
||||||
|
import org.apache.hadoop.hbase.util.JVMClusterUtil;
|
||||||
import org.apache.hadoop.hbase.util.ModifyRegionUtils;
|
import org.apache.hadoop.hbase.util.ModifyRegionUtils;
|
||||||
import org.apache.hadoop.hbase.util.Pair;
|
import org.apache.hadoop.hbase.util.Pair;
|
||||||
import org.apache.hadoop.hbase.util.RetryCounter;
|
import org.apache.hadoop.hbase.util.RetryCounter;
|
||||||
|
@ -415,6 +416,9 @@ public class HMaster extends HRegionServer implements MasterServices {
|
||||||
private final boolean maintenanceMode;
|
private final boolean maintenanceMode;
|
||||||
static final String MAINTENANCE_MODE = "hbase.master.maintenance_mode";
|
static final String MAINTENANCE_MODE = "hbase.master.maintenance_mode";
|
||||||
|
|
||||||
|
// the in process region server for carry system regions in maintenanceMode
|
||||||
|
private JVMClusterUtil.RegionServerThread maintenanceRegionServer;
|
||||||
|
|
||||||
// Cached clusterId on stand by masters to serve clusterID requests from clients.
|
// Cached clusterId on stand by masters to serve clusterID requests from clients.
|
||||||
private final CachedClusterId cachedClusterId;
|
private final CachedClusterId cachedClusterId;
|
||||||
|
|
||||||
|
@ -623,9 +627,6 @@ public class HMaster extends HRegionServer implements MasterServices {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void waitForMasterActive() {
|
protected void waitForMasterActive() {
|
||||||
if (maintenanceMode) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while (!isStopped() && !isAborted()) {
|
while (!isStopped() && !isAborted()) {
|
||||||
sleeper.sleep();
|
sleeper.sleep();
|
||||||
}
|
}
|
||||||
|
@ -669,9 +670,6 @@ public class HMaster extends HRegionServer implements MasterServices {
|
||||||
protected void configureInfoServer() {
|
protected void configureInfoServer() {
|
||||||
infoServer.addUnprivilegedServlet("master-status", "/master-status", MasterStatusServlet.class);
|
infoServer.addUnprivilegedServlet("master-status", "/master-status", MasterStatusServlet.class);
|
||||||
infoServer.setAttribute(MASTER, this);
|
infoServer.setAttribute(MASTER, this);
|
||||||
if (maintenanceMode) {
|
|
||||||
super.configureInfoServer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -966,6 +964,11 @@ public class HMaster extends HRegionServer implements MasterServices {
|
||||||
// initialize master side coprocessors before we start handling requests
|
// initialize master side coprocessors before we start handling requests
|
||||||
status.setStatus("Initializing master coprocessors");
|
status.setStatus("Initializing master coprocessors");
|
||||||
this.cpHost = new MasterCoprocessorHost(this, this.conf);
|
this.cpHost = new MasterCoprocessorHost(this, this.conf);
|
||||||
|
} else {
|
||||||
|
// start an in process region server for carrying system regions
|
||||||
|
maintenanceRegionServer =
|
||||||
|
JVMClusterUtil.createRegionServerThread(getConfiguration(), HRegionServer.class, 0);
|
||||||
|
maintenanceRegionServer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checking if meta needs initializing.
|
// Checking if meta needs initializing.
|
||||||
|
@ -1553,9 +1556,11 @@ public class HMaster extends HRegionServer implements MasterServices {
|
||||||
cleanerPool.shutdownNow();
|
cleanerPool.shutdownNow();
|
||||||
cleanerPool = null;
|
cleanerPool = null;
|
||||||
}
|
}
|
||||||
|
if (maintenanceRegionServer != null) {
|
||||||
|
maintenanceRegionServer.getRegionServer().stop(HBASE_MASTER_CLEANER_INTERVAL);
|
||||||
|
}
|
||||||
|
|
||||||
LOG.debug("Stopping service threads");
|
LOG.debug("Stopping service threads");
|
||||||
|
|
||||||
// stop procedure executor prior to other services such as server manager and assignment
|
// stop procedure executor prior to other services such as server manager and assignment
|
||||||
// manager, as these services are important for some running procedures. See HBASE-24117 for
|
// manager, as these services are important for some running procedures. See HBASE-24117 for
|
||||||
// example.
|
// example.
|
||||||
|
@ -3873,10 +3878,7 @@ public class HMaster extends HRegionServer implements MasterServices {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ReplicationStatus> getWalGroupsReplicationStatus() {
|
public Map<String, ReplicationStatus> getWalGroupsReplicationStatus() {
|
||||||
if (!this.isOnline() || !maintenanceMode) {
|
return new HashMap<>();
|
||||||
return new HashMap<>();
|
|
||||||
}
|
|
||||||
return super.getWalGroupsReplicationStatus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HbckChore getHbckChore() {
|
public HbckChore getHbckChore() {
|
||||||
|
|
|
@ -735,7 +735,8 @@ public class ServerManager {
|
||||||
*/
|
*/
|
||||||
private int getMinToStart() {
|
private int getMinToStart() {
|
||||||
if (master.isInMaintenanceMode()) {
|
if (master.isInMaintenanceMode()) {
|
||||||
// If in maintenance mode, then master hosting meta will be the only server available
|
// If in maintenance mode, then in process region server hosting meta will be the only server
|
||||||
|
// available
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ public class TestMasterNoCluster {
|
||||||
conf.set(HConstants.CLIENT_ZOOKEEPER_QUORUM, HConstants.LOCALHOST);
|
conf.set(HConstants.CLIENT_ZOOKEEPER_QUORUM, HConstants.LOCALHOST);
|
||||||
conf.setInt(HConstants.CLIENT_ZOOKEEPER_CLIENT_PORT,
|
conf.setInt(HConstants.CLIENT_ZOOKEEPER_CLIENT_PORT,
|
||||||
TESTUTIL.getZkCluster().getClientPort() + 1);
|
TESTUTIL.getZkCluster().getClientPort() + 1);
|
||||||
// need to enable maintenance mode so we will start master as a region server
|
// need to enable maintenance mode so we will start master and an in process region server
|
||||||
conf.setBoolean(HMaster.MAINTENANCE_MODE, true);
|
conf.setBoolean(HMaster.MAINTENANCE_MODE, true);
|
||||||
// settings to allow us not to start additional RS
|
// settings to allow us not to start additional RS
|
||||||
conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, 1);
|
conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, 1);
|
||||||
|
|
Loading…
Reference in New Issue