You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2011/04/02 16:41:10 UTC
svn commit: r1088038 - in /hbase/trunk: CHANGES.txt
src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java
Author: stack
Date: Sat Apr 2 14:41:10 2011
New Revision: 1088038
URL: http://svn.apache.org/viewvc?rev=1088038&view=rev
Log:
HBASE-3238 HBase needs to have the CREATE permission on the parent of its ZooKeeper parent znode
Modified:
hbase/trunk/CHANGES.txt
hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
hbase/trunk/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java
Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1088038&r1=1088037&r2=1088038&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Sat Apr 2 14:41:10 2011
@@ -58,6 +58,8 @@ Release 0.91.0 - Unreleased
(Ted Yu via Stack)
HBASE-3712 HTable.close() doesn't shutdown thread pool
(Ted Yu via Stack)
+ HBASE-3238 HBase needs to have the CREATE permission on the parent of its
+ ZooKeeper parent znode (Alex Newman via Stack)
IMPROVEMENTS
HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack)
Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java?rev=1088038&r1=1088037&r2=1088038&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java Sat Apr 2 14:41:10 2011
@@ -902,6 +902,16 @@ public class ZKUtil {
zkw.getZooKeeper().create(znode, new byte[0], Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT);
} catch(KeeperException.NodeExistsException nee) {
+ } catch(KeeperException.NoAuthException nee){
+ try {
+ if (null == zkw.getZooKeeper().exists(znode, false)) {
+ // If we failed to create the file and it does not already exist.
+ throw(nee);
+ }
+ } catch (InterruptedException ie) {
+ zkw.interruptedException(ie);
+ }
+
} catch(InterruptedException ie) {
zkw.interruptedException(ie);
}
Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java?rev=1088038&r1=1088037&r2=1088038&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java Sat Apr 2 14:41:10 2011
@@ -40,7 +40,9 @@ import org.apache.hadoop.hbase.util.Byte
import org.apache.hadoop.hbase.zookeeper.ZKConfig;
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.ZooKeeper.States;
import org.junit.AfterClass;
@@ -234,4 +236,36 @@ public class TestZooKeeper {
String reconstructedKey = ZKUtil.getZooKeeperClusterKey(conf);
assertEquals(key, reconstructedKey);
}
+
+ /**
+ * A test for HBASE-3238
+ * @throws IOException A connection attempt to zk failed
+ * @throws InterruptedException One of the non ZKUtil actions was interrupted
+ * @throws KeeperException Any of the zookeeper connections had a
+ * KeeperException
+ */
+ @Test
+ public void testCreateSilentIsReallySilent() throws InterruptedException,
+ KeeperException, IOException {
+ Configuration c = TEST_UTIL.getConfiguration();
+
+ String aclZnode = "/aclRoot";
+ String quorumServers = ZKConfig.getZKQuorumServersString(c);
+ int sessionTimeout = 5 * 1000; // 5 seconds
+ ZooKeeper zk = new ZooKeeper(quorumServers, sessionTimeout, EmptyWatcher.instance);
+ zk.addAuthInfo("digest", "hbase:rox".getBytes());
+
+ // Assumes the root of the ZooKeeper space is writable as it creates a node
+ // wherever the cluster home is defined.
+ ZooKeeperWatcher zk2 = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
+ "testMasterAddressManagerFromZK",
+ null);
+
+ // I set this acl after the attempted creation of the cluster home node.
+ zk.setACL("/", ZooDefs.Ids.CREATOR_ALL_ACL, -1);
+ zk.create(aclZnode, null, ZooDefs.Ids.CREATOR_ALL_ACL, CreateMode.PERSISTENT);
+ zk.close();
+
+ ZKUtil.createAndFailSilent(zk2, aclZnode);
+ }
}
\ No newline at end of file