zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From afine <...@git.apache.org>
Subject [GitHub] zookeeper pull request #191: ZOOKEEPER-2722: fix flaky testSessionEstablishm...
Date Tue, 21 Mar 2017 19:35:19 GMT
Github user afine commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/191#discussion_r107254406
  
    --- Diff: src/java/test/org/apache/zookeeper/test/ClientBase.java ---
    @@ -96,24 +96,34 @@ public void process(WatchedEvent event) { /* nada */ }
         public static class CountdownWatcher implements Watcher {
             // XXX this doesn't need to be volatile! (Should probably be final)
             volatile CountDownLatch clientConnected;
    +        // Set to true when connected to a read-only server, or a read-write (quorum)
server.
             volatile boolean connected;
    +        // Set to true when connected to a quorum server.
    +        volatile boolean syncConnected;
     
             public CountdownWatcher() {
                 reset();
             }
             synchronized public void reset() {
                 clientConnected = new CountDownLatch(1);
                 connected = false;
    +            syncConnected = false;
             }
             synchronized public void process(WatchedEvent event) {
    -            if (event.getState() == KeeperState.SyncConnected ||
    -                event.getState() == KeeperState.ConnectedReadOnly) {
    +            KeeperState state = event.getState();
    +            if (state == KeeperState.SyncConnected) {
    +                connected = true;
    +                syncConnected = true;
    +            } else if (state == KeeperState.ConnectedReadOnly) {
                     connected = true;
    --- End diff --
    
    but what if some event happens that causes the state to drop from syncconnected ->
connectedreadonly during a test (before reset is ever called). If expecting a reset call was
sufficient, we would not need the "else" clause in that if statement right?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message