fail("Unexpected exception code for createin: " + ke.getMessage());
}
}
Thread.sleep(5000);
WatchedEvent event = events.poll(10, TimeUnit.SECONDS);
if (event == null) {
throw new IOException("No event was delivered promptly");
}
if (event.getType() != EventType.NodeChildrenChanged
|| !event.getPath().equalsIgnoreCase(parentName)) {
fail("Unexpected event was delivered: " + event.toString());
}
stat_node = zk_1.exists(nodeName, false);
if (stat_node == null) {
fail("node " + nodeName + " should exist");
}
try {
zk.delete(parentName, -1);
fail("Should be impossible to delete a non-empty node " + parentName);
} catch (KeeperException ke) {
Code code = ke.code();
boolean valid = code == KeeperException.Code.NOTEMPTY;
if (!valid) {
fail("Unexpected exception code for delete: " + code);
}
}
try {
zk.create(nodeName + "/def", null, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
fail("Should be impossible to create child off Ephemeral node " + nodeName);
} catch (KeeperException ke) {
Code code = ke.code();
boolean valid = code == KeeperException.Code.NOCHILDRENFOREPHEMERALS;
if (!valid) {
fail("Unexpected exception code for createin: " + code);
}
}
try {
List<String> children1 = zk.getChildren(nodeName, false);
List<String> children2 = zk.getChildren(nodeName, false, null);
if (!children1.equals(children2)) {
fail("children lists from getChildren()/getChildren2() does not match");
}
if (children1.size() > 0) {
fail("ephemeral node " + nodeName + " should not have children");
}
} catch (KeeperException ke) {
Code code = ke.code();
boolean valid = code == KeeperException.Code.NONODE;
if (!valid) {
fail("Unexpected exception code for createin: " + code);
}
}
firstGen1 = zk_1.getChildren(parentName, true);
firstGen2 = zk_1.getChildren(parentName, true, null);
if (!firstGen1.equals(firstGen2)) {
fail("children list from getChildren()/getChildren2() does not match");
}
stat_node = zk_1.exists(nodeName, true);
if (stat_node == null) {
fail("node " + nodeName + " should exist");
}
System.out.println("session id of zk: " + zk.getSessionId());
System.out.println("session id of zk_1: " + zk_1.getSessionId());
zk.close();
Stat no_stat = zk_1.exists("nosuchnode", false);
event = this.getEvent(10);
if (event == null) {
throw new Error("First event was not delivered promptly");
}
if (!((event.getType() == EventType.NodeChildrenChanged &&
event.getPath().equalsIgnoreCase(parentName)) ||
(event.getType() == EventType.NodeDeleted &&
event.getPath().equalsIgnoreCase(nodeName)))) {
System.out.print(parentName + " "
+ EventType.NodeChildrenChanged + " " + nodeName + " " + EventType.NodeDeleted);
fail("Unexpected first event was delivered: " + event.toString());
}
event = this.getEvent(10);
if (event == null) {
throw new Error("Second event was not delivered promptly");
}
if (!((event.getType() == EventType.NodeChildrenChanged &&
event.getPath().equalsIgnoreCase(parentName)) ||
(event.getType() == EventType.NodeDeleted &&
event.getPath().equalsIgnoreCase(nodeName)))) {
System.out.print(parentName + " "
+ EventType.NodeChildrenChanged + " " + nodeName + " " + EventType.NodeDeleted);
fail("Unexpected second event was delivered: " + event.toString());
}
firstGen1 = zk_1.getChildren(parentName, false);
stat_node = zk_1.exists(nodeName, false);
if (stat_node != null) {