From: Ted D. <tdu...@ve...> - 2008-04-11 23:54:02
|
Hi, First, congrats on a really clean, simple and apparently awesome system. I look forward to using it. I am trying to set up some of our systems to use zookeeper, but am having some problems with very basic things. Here is a summary of grump causing things that I have gotten past: A) common ACL patterns appear to not be declared in a nice accessible way. There are some things in ZooDefs, but they are hard to use due to deep nesting of classes. B) the signature of create requires an ArrayList instead of a List. This makes common idioms very verbose (unnecessarily so). C) the digest authentication scheme is not particularly well documented. A code sample would help. D) the examples don't explain the arguments to the constructor of Zookeeper are. Many examples omit some basic setup code which makes them hard to replicate. My major question is why the following toy program is saying this: com.yahoo.zookeeper.KeeperException: KeeperErrorCode = Unknown error -111 at com.yahoo.zookeeper.ZooKeeper.delete(ZooKeeper.java:306) at TestZooKeeper.delete(TestZooKeeper.java:44) at TestZooKeeper.test1(TestZooKeeper.java:30) Here is the code. All suggestions are welcome. public class TestZooKeeper extends TestCase { static ZooKeeper zk; private ArrayList<ACL> acl; public void test1() throws IOException, KeeperException, InterruptedException { zk = new ZooKeeper("ted-rh:8181", 30000, new LoggingWatcher()); assertTrue(exists("/")); assertEquals("", get("/")); if (exists("/test")) { delete("/test"); } create("/test", ""); assertTrue(exists("/test")); create("/test/foobar", "test data"); } private boolean exists(String path) throws KeeperException, InterruptedException { return zk.exists(path, false) != null; } private void delete(String path) throws KeeperException, InterruptedException { zk.delete(path, -1); } private String get(String path) throws KeeperException, InterruptedException, UnsupportedEncodingException { return new String(zk.getData(path, false, null), "UTF-8"); } private void create(String path, String content) throws KeeperException, InterruptedException, UnsupportedEncodingException { acl = new ArrayList<ACL>(Collections.singletonList(new ACL(ZooDefs.Perms.ALL, new Id("world", "anyone")))); zk.create(path, content.getBytes("UTF-8"), acl, 0); } } |