HBASE-1191 ZooKeeper ensureParentExists calls fail

on absolute path (via Nitay Joffe)
HBASE-1187  After disabling/enabling a table, the regions seems to
               be assigned to only 1-2 region servers


git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@742137 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jean-Daniel Cryans 2009-02-08 18:37:00 +00:00
parent b741d8940c
commit 31823ff1a3
4 changed files with 40 additions and 12 deletions

View File

@ -46,6 +46,10 @@ Release 0.20.0 - Unreleased
(Toby White via Andrew Purtell)
HBASE-1180 Add missing import statements to SampleUploader and remove
unnecessary @Overrides (Ryan Smith via Andrew Purtell)
HBASE-1191 ZooKeeper ensureParentExists calls fail
on absolute path (via Nitay Joffe)
HBASE-1187 After disabling/enabling a table, the regions seems to
be assigned to only 1-2 region servers
Release 0.19.0 - 01/21/2009
INCOMPATIBLE CHANGES

View File

@ -225,6 +225,13 @@
takes longer than this interval, assign to a new regionserver.
</description>
</property>
<property>
<name>hbase.regions.percheckin</name>
<value>10</value>
<description>Maximum number of regions that can be assigned in a single go
to a region server.
</description>
</property>
<property>
<name>hbase.server.thread.wakefrequency</name>
<value>10000</value>

View File

@ -214,29 +214,38 @@ public class ZooKeeperWrapper implements HConstants {
return address;
}
private boolean ensureZNodeExists(String path) {
private boolean ensureExists(final String znode) {
try {
zooKeeper.create(path, new byte[0],
zooKeeper.create(znode, new byte[0],
Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
LOG.debug("Created ZNode " + path);
LOG.debug("Created ZNode " + znode);
return true;
} catch (KeeperException.NodeExistsException e) {
return true; // ok, move on.
} catch (KeeperException.NoNodeException e) {
return ensureParentExists(znode) && ensureExists(znode);
} catch (KeeperException e) {
LOG.warn("Failed to create " + parentZNode + ": " + e);
LOG.warn("Failed to create " + znode + ":", e);
} catch (InterruptedException e) {
LOG.warn("Failed to create " + parentZNode + ": " + e);
LOG.warn("Failed to create " + znode + ":", e);
}
return false;
}
private boolean ensureParentExists(final String znode) {
int index = znode.lastIndexOf(ZNODE_PATH_SEPARATOR);
if (index <= 0) { // Parent is root, which always exists.
return true;
}
return ensureExists(znode.substring(0, index));
}
/**
* Delete ZNode containing root region location.
* @return true if operation succeeded, false otherwise.
*/
public boolean deleteRootRegionLocation() {
if (!ensureZNodeExists(parentZNode)) {
if (!ensureParentExists(rootRegionZNode)) {
return false;
}
@ -297,7 +306,7 @@ public class ZooKeeperWrapper implements HConstants {
return deleteRootRegionLocation();
}
if (!ensureZNodeExists(parentZNode)) {
if (!ensureParentExists(rootRegionZNode)) {
return false;
}
@ -316,7 +325,7 @@ public class ZooKeeperWrapper implements HConstants {
* @return true if we're out of safe mode, false otherwise.
*/
public boolean checkOutOfSafeMode() {
if (!ensureZNodeExists(parentZNode)) {
if (!ensureParentExists(outOfSafeModeZNode)) {
return false;
}
@ -328,7 +337,7 @@ public class ZooKeeperWrapper implements HConstants {
* @return true if ephemeral ZNode created successfully, false otherwise.
*/
public boolean writeOutOfSafeMode() {
if (!ensureZNodeExists(parentZNode)) {
if (!ensureParentExists(outOfSafeModeZNode)) {
return false;
}
@ -353,8 +362,7 @@ public class ZooKeeperWrapper implements HConstants {
* @return true if the location was written, false if it failed
*/
public boolean writeRSLocation(HServerInfo info) {
ensureZNodeExists(parentZNode);
ensureZNodeExists(rsZNode);
ensureExists(rsZNode);
byte[] data = Bytes.toBytes(info.getServerAddress().getBindAddress());
String znode = rsZNode + ZNODE_PATH_SEPARATOR + info.getStartCode();
try {

View File

@ -62,4 +62,13 @@ public class TestZooKeeper extends HBaseClusterTestCase {
masterRootAddress = master.getRootRegionLocation();
assertEquals(masterRootAddress, zooKeeperRootAddress);
}
/**
* @throws IOException
*/
public void testParentExists() throws IOException {
conf.set("zookeeper.znode.safemode", "/a/b/c/d/e");
ZooKeeperWrapper zooKeeper = new ZooKeeperWrapper(conf);
assertTrue(zooKeeper.writeOutOfSafeMode());
}
}