HBASE-1816 Master rewrite; remove safe-mode
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@830447 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0d5da71571
commit
fd02c343fa
|
@ -86,10 +86,9 @@ public class TestTHLogRecovery extends HBaseClusterTestCase {
|
|||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
/*FileSystem lfs = FileSystem.getLocal(conf);
|
||||
FileSystem lfs = FileSystem.getLocal(conf);
|
||||
Path p = new Path(conf.get(HConstants.HBASE_DIR));
|
||||
if (lfs.exists(p)) lfs.delete(p, true);
|
||||
*/
|
||||
super.setUp();
|
||||
|
||||
HTableDescriptor desc = new HTableDescriptor(TABLE_NAME);
|
||||
|
|
|
@ -907,10 +907,7 @@ public class HConnectionManager implements HConstants {
|
|||
while (rootRegionAddress == null && localTimeouts < numRetries) {
|
||||
// Don't read root region until we're out of safe mode so we know
|
||||
// that the meta regions have been assigned.
|
||||
boolean outOfSafeMode = zk.checkOutOfSafeMode();
|
||||
if (outOfSafeMode) {
|
||||
rootRegionAddress = zk.readRootRegionLocation();
|
||||
}
|
||||
rootRegionAddress = zk.readRootRegionLocation();
|
||||
if (rootRegionAddress == null) {
|
||||
try {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
|
|
|
@ -66,9 +66,7 @@ public class RegionManager implements HConstants {
|
|||
|
||||
private AtomicReference<HServerAddress> rootRegionLocation =
|
||||
new AtomicReference<HServerAddress>(null);
|
||||
|
||||
private volatile boolean safeMode = true;
|
||||
|
||||
|
||||
final Lock splitLogLock = new ReentrantLock();
|
||||
|
||||
private final RootScanner rootScannerThread;
|
||||
|
@ -201,11 +199,7 @@ public class RegionManager implements HConstants {
|
|||
regionsAwaitingAssignment(info.getServerAddress(), isSingleServer);
|
||||
if (regionsToAssign.size() == 0) {
|
||||
// There are no regions waiting to be assigned.
|
||||
if (!inSafeMode()) {
|
||||
// We only do load balancing once all regions are assigned.
|
||||
// This prevents churn while the cluster is starting up.
|
||||
loadBalancer.loadBalancing(info, mostLoadedRegions, returnMsgs);
|
||||
}
|
||||
this.loadBalancer.loadBalancing(info, mostLoadedRegions, returnMsgs);
|
||||
} else {
|
||||
// if there's only one server, just give it all the regions
|
||||
if (isSingleServer) {
|
||||
|
@ -1066,39 +1060,6 @@ public class RegionManager implements HConstants {
|
|||
return metaScannerThread.isInitialScanComplete();
|
||||
}
|
||||
|
||||
private boolean tellZooKeeperOutOfSafeMode() {
|
||||
for (int attempt = 0; attempt < zooKeeperNumRetries; ++attempt) {
|
||||
if (zooKeeperWrapper.writeOutOfSafeMode()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
sleep(attempt);
|
||||
}
|
||||
|
||||
LOG.error("Failed to tell ZooKeeper we're out of safe mode after " +
|
||||
zooKeeperNumRetries + " retries");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the initial meta scan is complete and there are no
|
||||
* unassigned or pending regions
|
||||
*/
|
||||
public boolean inSafeMode() {
|
||||
if (safeMode) {
|
||||
if(isInitialMetaScanComplete() && regionsInTransition.size() == 0 &&
|
||||
tellZooKeeperOutOfSafeMode()) {
|
||||
master.getServerConnection().unsetRootRegionLocation();
|
||||
safeMode = false;
|
||||
LOG.info("exiting safe mode");
|
||||
} else {
|
||||
LOG.info("in safe mode");
|
||||
}
|
||||
}
|
||||
return safeMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the root region location.
|
||||
* @return HServerAddress describing root region server.
|
||||
|
|
|
@ -575,10 +575,8 @@ public class ServerManager implements HConstants {
|
|||
|
||||
// Store the Root Region location (in memory)
|
||||
HServerAddress rootServer = serverInfo.getServerAddress();
|
||||
if (this.master.getRegionManager().inSafeMode()) {
|
||||
this.master.getServerConnection().setRootRegionLocation(
|
||||
new HRegionLocation(region, rootServer));
|
||||
}
|
||||
this.master.getServerConnection().setRootRegionLocation(
|
||||
new HRegionLocation(region, rootServer));
|
||||
this.master.getRegionManager().setRootRegionLocation(rootServer);
|
||||
} else {
|
||||
// Note that the table has been assigned and is waiting for the
|
||||
|
|
|
@ -486,15 +486,7 @@ public class HRegionServer implements HConstants, HRegionInterface,
|
|||
!restart && !stopRequested.get() && i < msgs.length;
|
||||
i++) {
|
||||
LOG.info(msgs[i].toString());
|
||||
if (safeMode.get()) {
|
||||
if (zooKeeperWrapper.checkOutOfSafeMode()) {
|
||||
this.connection.unsetRootRegionLocation();
|
||||
synchronized (safeMode) {
|
||||
safeMode.set(false);
|
||||
safeMode.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
this.connection.unsetRootRegionLocation();
|
||||
switch(msgs[i].getType()) {
|
||||
case MSG_CALL_SERVER_STARTUP:
|
||||
// We the MSG_CALL_SERVER_STARTUP on startup but we can also
|
||||
|
|
|
@ -62,7 +62,6 @@ public class ZooKeeperWrapper implements HConstants {
|
|||
|
||||
private final String parentZNode;
|
||||
private final String rootRegionZNode;
|
||||
private final String outOfSafeModeZNode;
|
||||
private final String rsZNode;
|
||||
private final String masterElectionZNode;
|
||||
public final String clusterStateZNode;
|
||||
|
@ -94,8 +93,6 @@ public class ZooKeeperWrapper implements HConstants {
|
|||
|
||||
String rootServerZNodeName = conf.get("zookeeper.znode.rootserver",
|
||||
"root-region-server");
|
||||
String outOfSafeModeZNodeName = conf.get("zookeeper.znode.safemode",
|
||||
"safe-mode");
|
||||
String rsZNodeName = conf.get("zookeeper.znode.rs", "rs");
|
||||
String masterAddressZNodeName = conf.get("zookeeper.znode.master",
|
||||
"master");
|
||||
|
@ -103,7 +100,6 @@ public class ZooKeeperWrapper implements HConstants {
|
|||
"shutdown");
|
||||
|
||||
rootRegionZNode = getZNode(parentZNode, rootServerZNodeName);
|
||||
outOfSafeModeZNode = getZNode(parentZNode, outOfSafeModeZNodeName);
|
||||
rsZNode = getZNode(parentZNode, rsZNodeName);
|
||||
masterElectionZNode = getZNode(parentZNode, masterAddressZNodeName);
|
||||
clusterStateZNode = getZNode(parentZNode, stateZNodeName);
|
||||
|
@ -169,7 +165,6 @@ public class ZooKeeperWrapper implements HConstants {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("\nHBase tree in ZooKeeper is rooted at ").append(parentZNode);
|
||||
sb.append("\n Cluster up? ").append(exists(clusterStateZNode));
|
||||
sb.append("\n In safe mode? ").append(!checkOutOfSafeMode());
|
||||
sb.append("\n Master address: ").append(readMasterAddress(null));
|
||||
sb.append("\n Region server holding ROOT: ").append(readRootRegionLocation());
|
||||
sb.append("\n Region servers:");
|
||||
|
@ -469,42 +464,6 @@ public class ZooKeeperWrapper implements HConstants {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we're out of safe mode. Being out of safe mode is signified by an
|
||||
* ephemeral ZNode existing in ZooKeeper.
|
||||
* @return true if we're out of safe mode, false otherwise.
|
||||
*/
|
||||
public boolean checkOutOfSafeMode() {
|
||||
if (!ensureParentExists(outOfSafeModeZNode)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return checkExistenceOf(outOfSafeModeZNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create ephemeral ZNode signifying that we're out of safe mode.
|
||||
* @return true if ephemeral ZNode created successfully, false otherwise.
|
||||
*/
|
||||
public boolean writeOutOfSafeMode() {
|
||||
if (!ensureParentExists(outOfSafeModeZNode)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
zooKeeper.create(outOfSafeModeZNode, new byte[0], Ids.OPEN_ACL_UNSAFE,
|
||||
CreateMode.EPHEMERAL);
|
||||
LOG.debug("Wrote out of safe mode");
|
||||
return true;
|
||||
} catch (InterruptedException e) {
|
||||
LOG.warn("Failed to create out of safe mode in ZooKeeper: " + e);
|
||||
} catch (KeeperException e) {
|
||||
LOG.warn("Failed to create out of safe mode in ZooKeeper: " + e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write in ZK this RS startCode and address.
|
||||
* Ensures that the full path exists.
|
||||
|
|
|
@ -54,9 +54,6 @@ public class TestZooKeeper extends HBaseClusterTestCase {
|
|||
public void testWritesRootRegionLocation() throws IOException {
|
||||
ZooKeeperWrapper zooKeeper = new ZooKeeperWrapper(conf, EmptyWatcher.instance);
|
||||
|
||||
boolean outOfSafeMode = zooKeeper.checkOutOfSafeMode();
|
||||
assertFalse(outOfSafeMode);
|
||||
|
||||
HServerAddress zooKeeperRootAddress = zooKeeper.readRootRegionLocation();
|
||||
assertNull(zooKeeperRootAddress);
|
||||
|
||||
|
@ -66,9 +63,6 @@ public class TestZooKeeper extends HBaseClusterTestCase {
|
|||
|
||||
new HTable(conf, HConstants.META_TABLE_NAME);
|
||||
|
||||
outOfSafeMode = zooKeeper.checkOutOfSafeMode();
|
||||
assertTrue(outOfSafeMode);
|
||||
|
||||
zooKeeperRootAddress = zooKeeper.readRootRegionLocation();
|
||||
assertNotNull(zooKeeperRootAddress);
|
||||
|
||||
|
@ -76,17 +70,6 @@ public class TestZooKeeper extends HBaseClusterTestCase {
|
|||
assertEquals(masterRootAddress, zooKeeperRootAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IOException
|
||||
*/
|
||||
public void testParentExists() throws IOException {
|
||||
String oldValue = conf.get("zookeeper.znode.safemode");
|
||||
conf.set("zookeeper.znode.safemode", "/a/b/c/d/e");
|
||||
ZooKeeperWrapper zooKeeper = new ZooKeeperWrapper(conf, EmptyWatcher.instance);
|
||||
assertTrue(zooKeeper.writeOutOfSafeMode());
|
||||
conf.set("zookeeper.znode.safemode", oldValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* See HBASE-1232 and http://wiki.apache.org/hadoop/ZooKeeper/FAQ#4.
|
||||
* @throws IOException
|
||||
|
|
Loading…
Reference in New Issue