HBASE-26288 Revisit the usage of MetaTableLocator when HRegionServer.TEST_SKIP_REPORTING_TRANSITION is true (#3689)
Signed-off-by: Yulin Niu <niuyulin@apache.org>
This commit is contained in:
parent
dd58fdb4ba
commit
a9abdf4936
|
@ -103,7 +103,6 @@ import org.apache.hadoop.hbase.ipc.RpcServer;
|
||||||
import org.apache.hadoop.hbase.ipc.ServerNotRunningYetException;
|
import org.apache.hadoop.hbase.ipc.ServerNotRunningYetException;
|
||||||
import org.apache.hadoop.hbase.ipc.ServerRpcController;
|
import org.apache.hadoop.hbase.ipc.ServerRpcController;
|
||||||
import org.apache.hadoop.hbase.log.HBaseMarkers;
|
import org.apache.hadoop.hbase.log.HBaseMarkers;
|
||||||
import org.apache.hadoop.hbase.master.RegionState;
|
|
||||||
import org.apache.hadoop.hbase.mob.MobFileCache;
|
import org.apache.hadoop.hbase.mob.MobFileCache;
|
||||||
import org.apache.hadoop.hbase.namequeues.NamedQueueRecorder;
|
import org.apache.hadoop.hbase.namequeues.NamedQueueRecorder;
|
||||||
import org.apache.hadoop.hbase.namequeues.SlowLogTableOpsChore;
|
import org.apache.hadoop.hbase.namequeues.SlowLogTableOpsChore;
|
||||||
|
@ -151,7 +150,6 @@ import org.apache.hadoop.hbase.wal.AbstractFSWALProvider;
|
||||||
import org.apache.hadoop.hbase.wal.WAL;
|
import org.apache.hadoop.hbase.wal.WAL;
|
||||||
import org.apache.hadoop.hbase.wal.WALFactory;
|
import org.apache.hadoop.hbase.wal.WALFactory;
|
||||||
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker;
|
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker;
|
||||||
import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
|
|
||||||
import org.apache.hadoop.hbase.zookeeper.RegionServerAddressTracker;
|
import org.apache.hadoop.hbase.zookeeper.RegionServerAddressTracker;
|
||||||
import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
|
import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
|
||||||
import org.apache.hadoop.hbase.zookeeper.ZKNodeTracker;
|
import org.apache.hadoop.hbase.zookeeper.ZKNodeTracker;
|
||||||
|
@ -2048,13 +2046,9 @@ public class HRegionServer extends HBaseServerBase<RSRpcServices>
|
||||||
if (code == TransitionCode.OPENED) {
|
if (code == TransitionCode.OPENED) {
|
||||||
Preconditions.checkArgument(hris != null && hris.length == 1);
|
Preconditions.checkArgument(hris != null && hris.length == 1);
|
||||||
if (hris[0].isMetaRegion()) {
|
if (hris[0].isMetaRegion()) {
|
||||||
try {
|
LOG.warn(
|
||||||
MetaTableLocator.setMetaLocation(getZooKeeper(), serverName,
|
"meta table location is stored in master local store, so we can not skip reporting");
|
||||||
hris[0].getReplicaId(), RegionState.State.OPEN);
|
return false;
|
||||||
} catch (KeeperException e) {
|
|
||||||
LOG.info("Failed to update meta location", e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
MetaTableAccessor.updateRegionLocation(asyncClusterConnection.toConnection(), hris[0],
|
MetaTableAccessor.updateRegionLocation(asyncClusterConnection.toConnection(), hris[0],
|
||||||
|
|
|
@ -210,7 +210,7 @@ public class TestReplicasClient {
|
||||||
|
|
||||||
// No master
|
// No master
|
||||||
LOG.info("Master is going to be stopped");
|
LOG.info("Master is going to be stopped");
|
||||||
TestRegionServerNoMaster.stopMasterAndAssignMeta(HTU);
|
TestRegionServerNoMaster.stopMasterAndCacheMetaLocation(HTU);
|
||||||
Configuration c = new Configuration(HTU.getConfiguration());
|
Configuration c = new Configuration(HTU.getConfiguration());
|
||||||
c.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1);
|
c.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1);
|
||||||
LOG.info("Master has stopped");
|
LOG.info("Master has stopped");
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class TestRegionReplicas {
|
||||||
hriSecondary = RegionReplicaUtil.getRegionInfoForReplica(hriPrimary, 1);
|
hriSecondary = RegionReplicaUtil.getRegionInfoForReplica(hriPrimary, 1);
|
||||||
|
|
||||||
// No master
|
// No master
|
||||||
TestRegionServerNoMaster.stopMasterAndAssignMeta(HTU);
|
TestRegionServerNoMaster.stopMasterAndCacheMetaLocation(HTU);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class TestRegionReplicasAreDistributed {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void before() throws Exception {
|
public static void before() throws Exception {
|
||||||
HTU.getConfiguration().setInt(">hbase.master.wait.on.regionservers.mintostart", 3);
|
HTU.getConfiguration().setInt("hbase.master.wait.on.regionservers.mintostart", 3);
|
||||||
|
|
||||||
HTU.startMiniCluster(NB_SERVERS);
|
HTU.startMiniCluster(NB_SERVERS);
|
||||||
Thread.sleep(3000);
|
Thread.sleep(3000);
|
||||||
|
|
|
@ -102,7 +102,6 @@ public class TestRegionReplicasWithRestartScenarios {
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void afterClass() throws Exception {
|
public static void afterClass() throws Exception {
|
||||||
HRegionServer.TEST_SKIP_REPORTING_TRANSITION = false;
|
|
||||||
HTU.shutdownMiniCluster();
|
HTU.shutdownMiniCluster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ import org.apache.hadoop.hbase.ServerName;
|
||||||
import org.apache.hadoop.hbase.TableName;
|
import org.apache.hadoop.hbase.TableName;
|
||||||
import org.apache.hadoop.hbase.client.Put;
|
import org.apache.hadoop.hbase.client.Put;
|
||||||
import org.apache.hadoop.hbase.client.RegionInfo;
|
import org.apache.hadoop.hbase.client.RegionInfo;
|
||||||
import org.apache.hadoop.hbase.client.RegionInfoBuilder;
|
|
||||||
import org.apache.hadoop.hbase.client.RegionLocator;
|
import org.apache.hadoop.hbase.client.RegionLocator;
|
||||||
import org.apache.hadoop.hbase.client.Table;
|
import org.apache.hadoop.hbase.client.Table;
|
||||||
import org.apache.hadoop.hbase.client.TableDescriptor;
|
import org.apache.hadoop.hbase.client.TableDescriptor;
|
||||||
|
@ -35,10 +34,9 @@ import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler;
|
||||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
|
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
|
import org.apache.hadoop.hbase.util.JVMClusterUtil;
|
||||||
import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
|
import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
|
||||||
import org.apache.hadoop.hbase.util.Threads;
|
import org.apache.hadoop.hbase.util.Threads;
|
||||||
import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
|
|
||||||
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
|
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
@ -90,15 +88,24 @@ public class TestRegionServerNoMaster {
|
||||||
}
|
}
|
||||||
regionName = hri.getRegionName();
|
regionName = hri.getRegionName();
|
||||||
|
|
||||||
stopMasterAndAssignMeta(HTU);
|
stopMasterAndCacheMetaLocation(HTU);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void stopMasterAndAssignMeta(HBaseTestingUtil HTU)
|
public static void stopMasterAndCacheMetaLocation(HBaseTestingUtil HTU)
|
||||||
throws IOException, InterruptedException {
|
throws IOException, InterruptedException {
|
||||||
|
// cache meta location, so we will not go to master to lookup meta region location
|
||||||
|
for (JVMClusterUtil.RegionServerThread t : HTU.getMiniHBaseCluster().getRegionServerThreads()) {
|
||||||
|
try (RegionLocator locator =
|
||||||
|
t.getRegionServer().getConnection().getRegionLocator(TableName.META_TABLE_NAME)) {
|
||||||
|
locator.getAllRegionLocations();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try (RegionLocator locator = HTU.getConnection().getRegionLocator(TableName.META_TABLE_NAME)) {
|
||||||
|
locator.getAllRegionLocations();
|
||||||
|
}
|
||||||
// Stop master
|
// Stop master
|
||||||
HMaster master = HTU.getHBaseCluster().getMaster();
|
HMaster master = HTU.getHBaseCluster().getMaster();
|
||||||
Thread masterThread = HTU.getHBaseCluster().getMasterThread();
|
Thread masterThread = HTU.getHBaseCluster().getMasterThread();
|
||||||
ServerName masterAddr = master.getServerName();
|
|
||||||
master.stopMaster();
|
master.stopMaster();
|
||||||
|
|
||||||
LOG.info("Waiting until master thread exits");
|
LOG.info("Waiting until master thread exits");
|
||||||
|
@ -107,27 +114,6 @@ public class TestRegionServerNoMaster {
|
||||||
}
|
}
|
||||||
|
|
||||||
HRegionServer.TEST_SKIP_REPORTING_TRANSITION = true;
|
HRegionServer.TEST_SKIP_REPORTING_TRANSITION = true;
|
||||||
// Master is down, so is the meta. We need to assign it somewhere
|
|
||||||
// so that regions can be assigned during the mocking phase.
|
|
||||||
HRegionServer hrs = HTU.getHBaseCluster()
|
|
||||||
.getLiveRegionServerThreads().get(0).getRegionServer();
|
|
||||||
ZKWatcher zkw = hrs.getZooKeeper();
|
|
||||||
ServerName sn = MetaTableLocator.getMetaRegionLocation(zkw);
|
|
||||||
if (sn != null && !masterAddr.equals(sn)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProtobufUtil.openRegion(null, hrs.getRSRpcServices(),
|
|
||||||
hrs.getServerName(), RegionInfoBuilder.FIRST_META_REGIONINFO);
|
|
||||||
while (true) {
|
|
||||||
sn = MetaTableLocator.getMetaRegionLocation(zkw);
|
|
||||||
if (sn != null && sn.equals(hrs.getServerName())
|
|
||||||
&& hrs.getOnlineRegions().containsKey(
|
|
||||||
RegionInfoBuilder.FIRST_META_REGIONINFO.getEncodedName())) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Thread.sleep(100);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Flush the given region in the mini cluster. Since no master, we cannot use HBaseAdmin.flush() */
|
/** Flush the given region in the mini cluster. Since no master, we cannot use HBaseAdmin.flush() */
|
||||||
|
|
|
@ -134,19 +134,20 @@ public class TestRegionReplicaReplicationEndpointNoMaster {
|
||||||
hriSecondary = RegionReplicaUtil.getRegionInfoForReplica(hriPrimary, 1);
|
hriSecondary = RegionReplicaUtil.getRegionInfoForReplica(hriPrimary, 1);
|
||||||
|
|
||||||
// No master
|
// No master
|
||||||
TestRegionServerNoMaster.stopMasterAndAssignMeta(HTU);
|
TestRegionServerNoMaster.stopMasterAndCacheMetaLocation(HTU);
|
||||||
rs0 = HTU.getMiniHBaseCluster().getRegionServer(0);
|
rs0 = HTU.getMiniHBaseCluster().getRegionServer(0);
|
||||||
rs1 = HTU.getMiniHBaseCluster().getRegionServer(1);
|
rs1 = HTU.getMiniHBaseCluster().getRegionServer(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void afterClass() throws Exception {
|
public static void afterClass() throws Exception {
|
||||||
|
HRegionServer.TEST_SKIP_REPORTING_TRANSITION = false;
|
||||||
table.close();
|
table.close();
|
||||||
HTU.shutdownMiniCluster();
|
HTU.shutdownMiniCluster();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() throws Exception{
|
public void before() throws Exception {
|
||||||
entries.clear();
|
entries.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue