You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by anmolnar <gi...@git.apache.org> on 2018/09/04 13:57:34 UTC

[GitHub] zookeeper pull request #590: [ZOOKEEPER-1177] Add the memory optimized watch...

Github user anmolnar commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/590#discussion_r214890207
  
    --- Diff: src/java/main/org/apache/zookeeper/server/watch/WatchManager.java ---
    @@ -46,15 +48,26 @@
         private final Map<Watcher, Set<String>> watch2Paths =
             new HashMap<Watcher, Set<String>>();
     
    -    synchronized int size(){
    +    @Override
    +    public synchronized int size(){
             int result = 0;
             for(Set<Watcher> watches : watchTable.values()) {
                 result += watches.size();
             }
             return result;
         }
     
    -    synchronized void addWatch(String path, Watcher watcher) {
    +    boolean isDeadWatcher(Watcher watcher) {
    --- End diff --
    
    Looks like this patch is not just an improvement, but it also fixes the edge case of adding dead watchers.
    Previously stale client connections haven't been checked while registering watchers.
    Is that correct?


---