HBASE-9918: MasterAddressTracker & ZKNamespaceManager ZK listeners are missed after master recovery
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1540933 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
477072f7f0
commit
f8f0a927e3
|
@ -202,7 +202,6 @@ import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.Regio
|
|||
import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.ReportRSFatalErrorRequest;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.ReportRSFatalErrorResponse;
|
||||
import org.apache.hadoop.hbase.replication.regionserver.Replication;
|
||||
import org.apache.hadoop.hbase.security.User;
|
||||
import org.apache.hadoop.hbase.security.UserProvider;
|
||||
import org.apache.hadoop.hbase.snapshot.ClientSnapshotDescriptionUtils;
|
||||
import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils;
|
||||
|
@ -573,7 +572,6 @@ MasterServices, Server {
|
|||
startupStatus.setDescription("Master startup");
|
||||
masterStartTime = System.currentTimeMillis();
|
||||
try {
|
||||
this.registeredZKListenersBeforeRecovery = this.zooKeeper.getListeners();
|
||||
this.masterAddressManager = new MasterAddressTracker(getZooKeeperWatcher(), this);
|
||||
this.masterAddressManager.start();
|
||||
|
||||
|
@ -588,6 +586,7 @@ MasterServices, Server {
|
|||
this.infoServer.start();
|
||||
}
|
||||
|
||||
this.registeredZKListenersBeforeRecovery = this.zooKeeper.getListeners();
|
||||
/*
|
||||
* Block on becoming the active master.
|
||||
*
|
||||
|
@ -913,10 +912,10 @@ MasterServices, Server {
|
|||
this.balancerChore = getAndStartBalancerChore(this);
|
||||
this.catalogJanitorChore = new CatalogJanitor(this, this);
|
||||
startCatalogJanitorChore();
|
||||
}
|
||||
|
||||
status.setStatus("Starting namespace manager");
|
||||
initNamespace();
|
||||
}
|
||||
|
||||
if (this.cpHost != null) {
|
||||
try {
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.apache.hadoop.hbase.master.HMaster;
|
|||
import org.apache.hadoop.hbase.master.LoadBalancer;
|
||||
import org.apache.hadoop.hbase.master.balancer.SimpleLoadBalancer;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.hbase.util.FSUtils;
|
||||
import org.apache.hadoop.hbase.util.Threads;
|
||||
import org.apache.hadoop.hbase.zookeeper.EmptyWatcher;
|
||||
import org.apache.hadoop.hbase.zookeeper.ZKAssign;
|
||||
|
@ -60,6 +61,7 @@ import org.apache.zookeeper.ZooKeeper;
|
|||
import org.apache.zookeeper.ZooKeeper.States;
|
||||
import org.apache.zookeeper.data.ACL;
|
||||
import org.apache.zookeeper.data.Stat;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -83,12 +85,12 @@ public class TestZooKeeper {
|
|||
public static void setUpBeforeClass() throws Exception {
|
||||
// Test we can first start the ZK cluster by itself
|
||||
Configuration conf = TEST_UTIL.getConfiguration();
|
||||
TEST_UTIL.startMiniDFSCluster(2);
|
||||
TEST_UTIL.startMiniZKCluster();
|
||||
conf.setBoolean("dfs.support.append", true);
|
||||
conf.setInt(HConstants.ZK_SESSION_TIMEOUT, 1000);
|
||||
conf.setClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, MockLoadBalancer.class,
|
||||
LoadBalancer.class);
|
||||
TEST_UTIL.startMiniCluster(2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,9 +106,18 @@ public class TestZooKeeper {
|
|||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
TEST_UTIL.ensureSomeRegionServersAvailable(2);
|
||||
TEST_UTIL.startMiniHBaseCluster(1, 2);
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
try {
|
||||
TEST_UTIL.shutdownMiniHBaseCluster();
|
||||
} finally {
|
||||
TEST_UTIL.getTestFileSystem().delete(FSUtils.getRootDir(TEST_UTIL.getConfiguration()), true);
|
||||
ZKUtil.deleteNodeRecursively(TEST_UTIL.getZooKeeperWatcher(), "/hbase");
|
||||
}
|
||||
}
|
||||
|
||||
private ZooKeeperWatcher getZooKeeperWatcher(HConnection c)
|
||||
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||
|
@ -473,6 +484,7 @@ public class TestZooKeeper {
|
|||
public void testRegionAssignmentAfterMasterRecoveryDueToZKExpiry() throws Exception {
|
||||
MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
|
||||
cluster.startRegionServer();
|
||||
cluster.waitForActiveAndReadyMaster(10000);
|
||||
HMaster m = cluster.getMaster();
|
||||
ZooKeeperWatcher zkw = m.getZooKeeperWatcher();
|
||||
int expectedNumOfListeners = zkw.getNumberOfListeners();
|
||||
|
@ -495,6 +507,8 @@ public class TestZooKeeper {
|
|||
// clean startup.
|
||||
assertFalse("Retain assignment should not be called", MockLoadBalancer.retainAssignCalled);
|
||||
// number of listeners should be same as the value before master aborted
|
||||
// wait for new master is initialized
|
||||
cluster.waitForActiveAndReadyMaster(10000);
|
||||
assertEquals(expectedNumOfListeners, zkw.getNumberOfListeners());
|
||||
} finally {
|
||||
admin.close();
|
||||
|
|
Loading…
Reference in New Issue