curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dragonsinth <...@git.apache.org>
Subject [GitHub] curator pull request #278: [CURATOR-477] added support for turning off zk wa...
Date Sun, 23 Sep 2018 16:12:21 GMT
Github user dragonsinth commented on a diff in the pull request:

    https://github.com/apache/curator/pull/278#discussion_r219703563
  
    --- Diff: curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
---
    @@ -263,15 +284,31 @@ private void doRefreshData() throws Exception
                 {
                     if ( dataIsCompressed )
                     {
    -                    client.getData().decompressed().usingWatcher(this).inBackground(this).forPath(path);
    +                    maybeWatch(client.getData().decompressed()).forPath(path);
                     }
                     else
                     {
    -                    client.getData().usingWatcher(this).inBackground(this).forPath(path);
    +                    maybeWatch(client.getData()).forPath(path);
                     }
                 }
             }
     
    +        private ErrorListenerPathable<byte[]> maybeWatch(GetDataWatchBackgroundStatable
dataBuilder) {
    +            if (disableZkWatches) {
    +                return dataBuilder.inBackground(this);
    +            } else {
    +                return dataBuilder.usingWatcher(this).inBackground(this);
    +            }
    +        }
    +
    +        private ErrorListenerPathable<byte[]> maybeWatch(GetDataBuilder dataBuilder)
{
    +            if (disableZkWatches) {
    +                return dataBuilder.inBackground(this);
    +            } else {
    +                return dataBuilder.usingWatcher(this).inBackground(this);
    +            }
    +        }
    +
    --- End diff --
    
    ```java
            private void doRefreshChildren() throws Exception
            {
                if ( treeState.get() == TreeState.STARTED )
                {
                    maybeWatch(client.getChildren()).forPath(path);
                }
            }
    
            private void doRefreshData() throws Exception
            {
                if ( treeState.get() == TreeState.STARTED )
                {
                    if ( dataIsCompressed )
                    {
                        maybeWatch(client.getData().decompressed()).forPath(path);
                    }
                    else
                    {
                        maybeWatch(client.getData()).forPath(path);
                    }
                }
            }
    
            private <T, P extends Watchable<BackgroundPathable<T>> & BackgroundPathable<T>>
Pathable<T> maybeWatch(P dataBuilder)
            {
                if ( disableZkWatches )
                {
                    return dataBuilder.inBackground(this);
                }
                else
                {
                    return dataBuilder.usingWatcher(this).inBackground(this);
                }
            }
    ```


---

Mime
View raw message