You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by ma...@apache.org on 2008/11/18 01:11:14 UTC
svn commit: r718445 - in /hadoop/zookeeper/trunk: CHANGES.txt
src/java/test/org/apache/zookeeper/test/WatcherTest.java
Author: mahadev
Date: Mon Nov 17 16:11:13 2008
New Revision: 718445
URL: http://svn.apache.org/viewvc?rev=718445&view=rev
Log:
ZOOKEEPER-219. fix events.poll timeout in watcher test to be longer. (pat via mahadev)
Modified:
hadoop/zookeeper/trunk/CHANGES.txt
hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherTest.java
Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=718445&r1=718444&r2=718445&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Mon Nov 17 16:11:13 2008
@@ -13,6 +13,9 @@
ZOOKEEPER-213. fix programmer guide C api docs to be in sync with latest
zookeeper.h (pat via mahadev)
+ ZOOKEEPER-219. fix events.poll timeout in watcher test to be longer. (pat
+via mahadev)
+
Release 3.0.0 - 2008-10-21
Non-backward compatible changes:
Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherTest.java?rev=718445&r1=718444&r2=718445&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherTest.java Mon Nov 17 16:11:13 2008
@@ -61,7 +61,7 @@
* case verifies that we see all of the data events on a particular node.
* There was a bug (ZOOKEEPER-137) that resulted in events being dropped
* in some cases (timing).
- *
+ *
* @throws IOException
* @throws InterruptedException
* @throws KeeperException
@@ -74,7 +74,7 @@
try {
MyWatcher watcher = new MyWatcher();
zk = createClient(watcher, hostPort);
-
+
StatCallback scb = new StatCallback() {
public void processResult(int rc, String path, Object ctx,
Stat stat) {
@@ -86,20 +86,20 @@
// don't do anything
}
};
-
+
String names[] = new String[10];
for (int i = 0; i < names.length; i++) {
String name = zk.create("/tc-", "initialvalue".getBytes(),
Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL);
names[i] = name;
-
+
Stat stat = new Stat();
zk.getData(name, watcher, stat);
zk.setData(name, "new".getBytes(), stat.getVersion(), scb, null);
stat = zk.exists(name, watcher);
zk.delete(name, stat.getVersion(), vcb, null);
}
-
+
for (int i = 0; i < names.length; i++) {
String name = names[i];
WatchedEvent event = watcher.events.poll(10, TimeUnit.SECONDS);
@@ -126,7 +126,7 @@
testWatcherAutoReset(zk, watcher, watcher);
zk.close();
}
-
+
@Test
public void testWatcherAutoResetWithLocal() throws Exception {
ZooKeeper zk = null;
@@ -135,20 +135,20 @@
testWatcherAutoReset(zk, watcher, new MyWatcher());
zk.close();
}
-
+
@Test
public void testWatcherAutoResetDisabledWithGlobal() throws Exception {
ClientCnxn.disableAutoWatchReset = true;
testWatcherAutoResetWithGlobal();
}
-
+
@Test
public void testWatcherAutoResetDisabledWithLocal() throws Exception {
ClientCnxn.disableAutoWatchReset = true;
testWatcherAutoResetWithLocal();
}
-
- private void testWatcherAutoReset(ZooKeeper zk, MyWatcher globalWatcher,
+
+ private void testWatcherAutoReset(ZooKeeper zk, MyWatcher globalWatcher,
MyWatcher localWatcher) throws Exception {
boolean isGlobal = (localWatcher == globalWatcher);
// First test to see if the watch survives across reconnects
@@ -163,9 +163,9 @@
zk.getData("/watchtest/child", localWatcher, new Stat());
zk.exists("/watchtest/child2", localWatcher);
}
-
+
assertTrue(localWatcher.events.isEmpty());
-
+
stopServer();
globalWatcher.waitForDisconnected(3000);
localWatcher.waitForDisconnected(500);
@@ -174,21 +174,21 @@
if (!isGlobal && !ClientCnxn.disableAutoWatchReset) {
localWatcher.waitForConnected(500);
}
-
+
assertTrue(localWatcher.events.isEmpty());
zk.setData("/watchtest/child", new byte[1], -1);
zk.create("/watchtest/child2", new byte[0], Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT);
-
- WatchedEvent e = localWatcher.events.poll(1, TimeUnit.MILLISECONDS);
+
+ WatchedEvent e = localWatcher.events.poll(10, TimeUnit.SECONDS);
if (!ClientCnxn.disableAutoWatchReset) {
assertEquals(e.getPath(), EventType.NodeDataChanged, e.getType());
assertEquals("/watchtest/child", e.getPath());
} else {
assertNull("unexpected event", e);
}
-
- e = localWatcher.events.poll(1000, TimeUnit.MILLISECONDS);
+
+ e = localWatcher.events.poll(10, TimeUnit.SECONDS);
if (!ClientCnxn.disableAutoWatchReset) {
// The create will trigger the get children and the exist
// watches
@@ -198,17 +198,17 @@
assertNull("unexpected event", e);
}
- e = localWatcher.events.poll(1000, TimeUnit.MILLISECONDS);
+ e = localWatcher.events.poll(10, TimeUnit.SECONDS);
if (!ClientCnxn.disableAutoWatchReset) {
assertEquals(EventType.NodeChildrenChanged, e.getType());
assertEquals("/watchtest", e.getPath());
} else {
assertNull("unexpected event", e);
}
-
+
// Make sure PINGs don't screw us up!
Thread.sleep(4000);
-
+
assertTrue(localWatcher.events.isEmpty()); // ensure no late arrivals
stopServer();
globalWatcher.waitForDisconnected(3000);
@@ -230,7 +230,7 @@
}
startServer();
globalWatcher.waitForConnected(3000);
-
+
if (isGlobal) {
zk.getChildren("/watchtest", true);
zk.getData("/watchtest/child", true, new Stat());
@@ -240,21 +240,21 @@
zk.getData("/watchtest/child", localWatcher, new Stat());
zk.exists("/watchtest/child2", localWatcher);
}
-
+
// Do trigger an event to make sure that we do not get
// it later
zk.delete("/watchtest/child2", -1);
-
- e = localWatcher.events.poll(1, TimeUnit.MILLISECONDS);
+
+ e = localWatcher.events.poll(10, TimeUnit.SECONDS);
assertEquals(EventType.NodeDeleted, e.getType());
assertEquals("/watchtest/child2", e.getPath());
-
- e = localWatcher.events.poll(1, TimeUnit.MILLISECONDS);
+
+ e = localWatcher.events.poll(10, TimeUnit.SECONDS);
assertEquals(EventType.NodeChildrenChanged, e.getType());
assertEquals("/watchtest", e.getPath());
-
+
assertTrue(localWatcher.events.isEmpty());
-
+
stopServer();
globalWatcher.waitForDisconnected(3000);
localWatcher.waitForDisconnected(500);
@@ -263,22 +263,22 @@
if (!isGlobal && !ClientCnxn.disableAutoWatchReset) {
localWatcher.waitForConnected(500);
}
-
+
zk.delete("/watchtest/child", -1);
zk.delete("/watchtest", -1);
-
- e = localWatcher.events.poll(1, TimeUnit.MILLISECONDS);
+
+ e = localWatcher.events.poll(10, TimeUnit.SECONDS);
if (!ClientCnxn.disableAutoWatchReset) {
assertEquals(EventType.NodeDeleted, e.getType());
assertEquals("/watchtest/child", e.getPath());
} else {
assertNull("unexpected event", e);
}
-
+
// Make sure nothing is straggling!
Thread.sleep(1000);
assertTrue(localWatcher.events.isEmpty());
-
+
}
}