@Before public void setup() throws Exception { zk = newZooKeeper(); // be sure that the lock-place is created ZkUtils.recursiveSafeDelete(zk, baseLockPath, -1); zk.create(baseLockPath, new byte[] {}, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); zkSessionManager = new BaseZkSessionManager(zk); }
@After public void tearDown() throws Exception { try { List<String> children = zk.getChildren(baseLockPath, false); for (String child : children) { ZkUtils.safeDelete(zk, baseLockPath + "/" + child, -1); } ZkUtils.safeDelete(zk, baseLockPath, -1); } catch (KeeperException ke) { // suppress because who cares what went wrong after our tests did their thing? } finally { closeZooKeeper(zk); } }
private static void closeZooKeeper(ZooKeeper zk) throws InterruptedException { System.out.printf("%s: Closing ZooKeeper%n", Thread.currentThread().getName()); zk.close(); }