Repository: curator Updated Branches: refs/heads/persistent-watch 076583d14 -> 38c766310
refactoring Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/5b0a9f56 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/5b0a9f56 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/5b0a9f56 Branch: refs/heads/persistent-watch Commit: 5b0a9f56e7d050eedfea0618f90c58d718441d3f Parents: 076583d Author: randgalt <randg...@apache.org> Authored: Fri Dec 30 14:09:53 2016 -0500 Committer: randgalt <randg...@apache.org> Committed: Fri Dec 30 14:09:53 2016 -0500 ---------------------------------------------------------------------- .../framework/recipes/watch/CacheAction.java | 5 +- .../framework/recipes/watch/CacheFilter.java | 2 +- .../framework/recipes/watch/CacheFilters.java | 45 +++++++++++++++ .../recipes/watch/CuratorCacheBuilder.java | 23 ++++---- .../recipes/watch/InternalCuratorCache.java | 47 +++++++++++++--- .../recipes/watch/InternalNodeCache.java | 8 +-- .../recipes/watch/NoDataCacheFilter.java | 4 +- .../framework/recipes/watch/RefreshFilter.java | 2 +- .../framework/recipes/watch/RefreshFilters.java | 36 ++++++++++++ .../recipes/watch/SingleLevelCacheFilter.java | 59 -------------------- .../recipes/watch/SingleLevelRefreshFilter.java | 37 ------------ .../recipes/watch/StandardCacheFilter.java | 46 +++++++++++++++ .../recipes/watch/StatsOnlyCacheFilter.java | 28 ---------- .../recipes/watch/TreeRefreshFilter.java | 28 ---------- .../watch/TestSingleLevelCuratorCache.java | 5 +- 15 files changed, 190 insertions(+), 185 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/5b0a9f56/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CacheAction.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CacheAction.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CacheAction.java index a59fe99..b39457a 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CacheAction.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CacheAction.java @@ -22,6 +22,7 @@ public enum CacheAction { NOT_STORED, PATH_ONLY, - PATH_AND_DATA, - PATH_AND_COMPRESSED_DATA + STAT_ONLY, + STAT_AND_DATA, + STAT_AND_COMPRESSED_DATA } http://git-wip-us.apache.org/repos/asf/curator/blob/5b0a9f56/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CacheFilter.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CacheFilter.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CacheFilter.java index 9923174..6cccc88 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CacheFilter.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CacheFilter.java @@ -20,5 +20,5 @@ package org.apache.curator.framework.recipes.watch; public interface CacheFilter { - CacheAction actionForPath(String path); + CacheAction actionForPath(String mainPath, String checkPath); } http://git-wip-us.apache.org/repos/asf/curator/blob/5b0a9f56/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CacheFilters.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CacheFilters.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CacheFilters.java new file mode 100644 index 0000000..171dea4 --- /dev/null +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CacheFilters.java @@ -0,0 +1,45 @@ +package org.apache.curator.framework.recipes.watch; + +public class CacheFilters +{ + private static final CacheFilter statAndData = new StandardCacheFilter(CacheAction.STAT_AND_DATA); + private static final CacheFilter compressedStatAndData = new StandardCacheFilter(CacheAction.STAT_AND_COMPRESSED_DATA); + private static final CacheFilter statOnly = new StandardCacheFilter(CacheAction.STAT_ONLY); + private static final CacheFilter pathOnly = new StandardCacheFilter(CacheAction.PATH_ONLY); + + public static CacheFilter statAndData() + { + return statAndData; + } + + public static CacheFilter compressedData() + { + return compressedStatAndData; + } + + public static CacheFilter statOnly() + { + return statOnly; + } + + public static CacheFilter pathOnly() + { + return pathOnly; + } + + public static CacheFilter full(final CacheAction cacheAction) + { + return new CacheFilter() + { + @Override + public CacheAction actionForPath(String mainPath, String checkPath) + { + return cacheAction; + } + }; + } + + private CacheFilters() + { + } +} http://git-wip-us.apache.org/repos/asf/curator/blob/5b0a9f56/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CuratorCacheBuilder.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CuratorCacheBuilder.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CuratorCacheBuilder.java index e22aa1c..341ac23 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CuratorCacheBuilder.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/CuratorCacheBuilder.java @@ -18,6 +18,7 @@ */ package org.apache.curator.framework.recipes.watch; +import com.google.common.base.Preconditions; import com.google.common.cache.CacheBuilder; import org.apache.curator.framework.CuratorFramework; import java.util.Objects; @@ -28,18 +29,11 @@ public class CuratorCacheBuilder private final CuratorFramework client; private final String path; private CacheBuilder<Object, Object> cacheBuilder = CacheBuilder.newBuilder(); - private boolean singleNode; - private RefreshFilter refreshFilter; + private boolean singleNode = false; + private RefreshFilter refreshFilter = null; private boolean sendRefreshEvents = true; private boolean refreshOnStart = true; - private CacheFilter cacheFilter = new CacheFilter() - { - @Override - public CacheAction actionForPath(String path) - { - return CacheAction.PATH_AND_DATA; - } - }; + private CacheFilter cacheFilter = CacheFilters.statAndData(); public static CuratorCacheBuilder builder(CuratorFramework client, String path) { @@ -51,6 +45,7 @@ public class CuratorCacheBuilder { if ( singleNode ) { + Preconditions.checkState(refreshFilter == null, "Single node caches do not use RefreshFilters"); return new InternalNodeCache(client, path, cacheFilter, cacheBuilder.<String, CachedNode>build(), sendRefreshEvents, refreshOnStart); } return new InternalCuratorCache(client, path, cacheFilter, refreshFilter, cacheBuilder.<String, CachedNode>build(), sendRefreshEvents, refreshOnStart); @@ -60,21 +55,23 @@ public class CuratorCacheBuilder { singleNode = true; refreshFilter = null; + cacheFilter = CacheFilters.statAndData(); return this; } public CuratorCacheBuilder forSingleLevel() { singleNode = false; - refreshFilter = new SingleLevelRefreshFilter(path); - cacheFilter = new SingleLevelCacheFilter(path); + refreshFilter = RefreshFilters.singleLevel(); + cacheFilter = CacheFilters.statAndData(); return this; } public CuratorCacheBuilder forTree() { singleNode = false; - refreshFilter = new TreeRefreshFilter(); + refreshFilter = RefreshFilters.tree(); + cacheFilter = CacheFilters.statAndData(); return this; } http://git-wip-us.apache.org/repos/asf/curator/blob/5b0a9f56/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/InternalCuratorCache.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/InternalCuratorCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/InternalCuratorCache.java index aa47363..303ebb1 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/InternalCuratorCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/InternalCuratorCache.java @@ -46,7 +46,7 @@ class InternalCuratorCache extends CuratorCacheBase implements Watcher private static final RefreshFilter nopRefreshFilter = new RefreshFilter() { @Override - public boolean descend(String path) + public boolean descend(String mainPath, String checkPath) { return false; } @@ -157,7 +157,7 @@ class InternalCuratorCache extends CuratorCacheBase implements Watcher { CacheAction cacheAction = (CacheAction)event.getContext(); CachedNode newNode = new CachedNode(event.getStat(), event.getData()); - CachedNode oldNode = cache.asMap().put(path, (cacheAction == CacheAction.PATH_ONLY) ? new CachedNode(event.getStat()) : newNode); + CachedNode oldNode = putNewNode(path, cacheAction, newNode); if ( oldNode == null ) { notifyListeners(CacheEvent.NODE_CREATED, path, newNode); @@ -187,7 +187,7 @@ class InternalCuratorCache extends CuratorCacheBase implements Watcher } }; - CacheAction cacheAction = cacheFilter.actionForPath(path); + CacheAction cacheAction = cacheFilter.actionForPath(basePath, path); switch ( cacheAction ) { case NOT_STORED: @@ -196,8 +196,8 @@ class InternalCuratorCache extends CuratorCacheBase implements Watcher break; } - case PATH_ONLY: - case PATH_AND_DATA: + case STAT_ONLY: + case STAT_AND_DATA: { try { @@ -212,7 +212,7 @@ class InternalCuratorCache extends CuratorCacheBase implements Watcher break; } - case PATH_AND_COMPRESSED_DATA: + case STAT_AND_COMPRESSED_DATA: { try { @@ -228,7 +228,7 @@ class InternalCuratorCache extends CuratorCacheBase implements Watcher } } - if ( refreshFilter.descend(path) ) + if ( refreshFilter.descend(basePath, path) ) { refresher.increment(); try @@ -243,6 +243,39 @@ class InternalCuratorCache extends CuratorCacheBase implements Watcher } } + private CachedNode putNewNode(String path, CacheAction cacheAction, CachedNode newNode) + { + CachedNode putNode; + switch ( cacheAction ) + { + default: + case NOT_STORED: + { + throw new IllegalStateException(String.format("Should not be here with action %s for path %s", cacheAction, path)); + } + + case PATH_ONLY: + { + putNode = nullNode; + break; + } + + case STAT_ONLY: + { + putNode = new CachedNode(newNode.getStat()); + break; + } + + case STAT_AND_DATA: + case STAT_AND_COMPRESSED_DATA: + { + putNode = newNode; + break; + } + } + return cache.asMap().put(path, putNode); + } + private void decrementOutstanding(SettableFuture<Boolean> task, AtomicInteger outstandingCount) { if ( outstandingCount.decrementAndGet() <= 0 ) http://git-wip-us.apache.org/repos/asf/curator/blob/5b0a9f56/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/InternalNodeCache.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/InternalNodeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/InternalNodeCache.java index b78480a..b4a7b16 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/InternalNodeCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/InternalNodeCache.java @@ -179,7 +179,7 @@ class InternalNodeCache extends CuratorCacheBase } else if ( event.getResultCode() == KeeperException.Code.OK.intValue() ) { - switch ( cacheFilter.actionForPath(path) ) + switch ( cacheFilter.actionForPath(path, path) ) { default: case NOT_STORED: @@ -187,20 +187,20 @@ class InternalNodeCache extends CuratorCacheBase throw new UnsupportedOperationException("Single node cache does not support action: IGNORE"); } - case PATH_ONLY: + case STAT_ONLY: { setNewData(nullNode); break; } - case PATH_AND_DATA: + case STAT_AND_DATA: { refresher.increment(); client.getData().usingWatcher(watcher).inBackground(backgroundCallback, refresher).forPath(path); break; } - case PATH_AND_COMPRESSED_DATA: + case STAT_AND_COMPRESSED_DATA: { refresher.increment(); client.getData().decompressed().usingWatcher(watcher).inBackground(backgroundCallback, refresher).forPath(path); http://git-wip-us.apache.org/repos/asf/curator/blob/5b0a9f56/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/NoDataCacheFilter.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/NoDataCacheFilter.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/NoDataCacheFilter.java index b68402d..97e86da 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/NoDataCacheFilter.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/NoDataCacheFilter.java @@ -21,8 +21,8 @@ package org.apache.curator.framework.recipes.watch; public class NoDataCacheFilter implements CacheFilter { @Override - public CacheAction actionForPath(String path) + public CacheAction actionForPath(String mainPath, String checkPath) { - return CacheAction.PATH_ONLY; + return CacheAction.STAT_ONLY; } } http://git-wip-us.apache.org/repos/asf/curator/blob/5b0a9f56/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/RefreshFilter.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/RefreshFilter.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/RefreshFilter.java index 5b7fa7f..8a29826 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/RefreshFilter.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/RefreshFilter.java @@ -20,5 +20,5 @@ package org.apache.curator.framework.recipes.watch; public interface RefreshFilter { - boolean descend(String path); + boolean descend(String mainPath, String checkPath); } http://git-wip-us.apache.org/repos/asf/curator/blob/5b0a9f56/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/RefreshFilters.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/RefreshFilters.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/RefreshFilters.java new file mode 100644 index 0000000..c1581c4 --- /dev/null +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/RefreshFilters.java @@ -0,0 +1,36 @@ +package org.apache.curator.framework.recipes.watch; + +public class RefreshFilters +{ + private static final RefreshFilter singleLevel = new RefreshFilter() + { + @Override + public boolean descend(String mainPath, String checkPath) + { + return mainPath.equals(checkPath); + } + }; + + private static final RefreshFilter tree = new RefreshFilter() + { + @Override + public boolean descend(String mainPath, String checkPath) + { + return true; + } + }; + + public static RefreshFilter singleLevel() + { + return singleLevel; + } + + public static RefreshFilter tree() + { + return tree; + } + + private RefreshFilters() + { + } +} http://git-wip-us.apache.org/repos/asf/curator/blob/5b0a9f56/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/SingleLevelCacheFilter.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/SingleLevelCacheFilter.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/SingleLevelCacheFilter.java deleted file mode 100644 index 615a292..0000000 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/SingleLevelCacheFilter.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.curator.framework.recipes.watch; - -import org.apache.curator.utils.ZKPaths; - -public class SingleLevelCacheFilter implements CacheFilter -{ - private final String levelPath; - private final CacheAction defaultAction; - private final boolean isRoot; - - public SingleLevelCacheFilter(String levelPath) - { - this(levelPath, CacheAction.PATH_AND_DATA); - } - - public SingleLevelCacheFilter(String levelPath, CacheAction defaultAction) - { - this.levelPath = levelPath; - this.defaultAction = defaultAction; - isRoot = levelPath.equals(ZKPaths.PATH_SEPARATOR); - } - - @Override - public CacheAction actionForPath(String path) - { - if ( isRoot && path.equals(ZKPaths.PATH_SEPARATOR) ) // special case. The parent of "/" is "/" - { - return CacheAction.NOT_STORED; - } - else if ( ZKPaths.getPathAndNode(path).getPath().equals(levelPath) ) - { - return actionForMatchedPath(); - } - return CacheAction.NOT_STORED; - } - - protected CacheAction actionForMatchedPath() - { - return defaultAction; - } -} http://git-wip-us.apache.org/repos/asf/curator/blob/5b0a9f56/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/SingleLevelRefreshFilter.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/SingleLevelRefreshFilter.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/SingleLevelRefreshFilter.java deleted file mode 100644 index f023a3e..0000000 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/SingleLevelRefreshFilter.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.curator.framework.recipes.watch; - -import java.util.Objects; - -public class SingleLevelRefreshFilter implements RefreshFilter -{ - private final String basePath; - - public SingleLevelRefreshFilter(String basePath) - { - this.basePath = Objects.requireNonNull(basePath, "basePath cannot be null"); - } - - @Override - public boolean descend(String path) - { - return basePath.equals(path); - } -} http://git-wip-us.apache.org/repos/asf/curator/blob/5b0a9f56/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/StandardCacheFilter.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/StandardCacheFilter.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/StandardCacheFilter.java new file mode 100644 index 0000000..e27355d --- /dev/null +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/StandardCacheFilter.java @@ -0,0 +1,46 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.curator.framework.recipes.watch; + +import org.apache.curator.utils.ZKPaths; + +class StandardCacheFilter implements CacheFilter +{ + private final CacheAction cacheAction; + + StandardCacheFilter(CacheAction cacheAction) + { + this.cacheAction = cacheAction; + } + + @Override + public CacheAction actionForPath(String mainPath, String checkPath) + { + boolean mainPathIsRoot = mainPath.endsWith(ZKPaths.PATH_SEPARATOR); + if ( mainPathIsRoot && checkPath.equals(ZKPaths.PATH_SEPARATOR) ) // special case. The parent of "/" is "/" + { + return CacheAction.NOT_STORED; + } + else if ( ZKPaths.getPathAndNode(checkPath).getPath().equals(mainPath) ) + { + return cacheAction; + } + return CacheAction.NOT_STORED; + } +} http://git-wip-us.apache.org/repos/asf/curator/blob/5b0a9f56/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/StatsOnlyCacheFilter.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/StatsOnlyCacheFilter.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/StatsOnlyCacheFilter.java deleted file mode 100644 index bba145a..0000000 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/StatsOnlyCacheFilter.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.curator.framework.recipes.watch; - -public class StatsOnlyCacheFilter implements CacheFilter -{ - @Override - public CacheAction actionForPath(String path) - { - return CacheAction.PATH_ONLY; - } -} http://git-wip-us.apache.org/repos/asf/curator/blob/5b0a9f56/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/TreeRefreshFilter.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/TreeRefreshFilter.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/TreeRefreshFilter.java deleted file mode 100644 index dda49b4..0000000 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/watch/TreeRefreshFilter.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.curator.framework.recipes.watch; - -public class TreeRefreshFilter implements RefreshFilter -{ - @Override - public boolean descend(String path) - { - return true; - } -} http://git-wip-us.apache.org/repos/asf/curator/blob/5b0a9f56/curator-recipes/src/test/java/org/apache/curator/framework/recipes/watch/TestSingleLevelCuratorCache.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/watch/TestSingleLevelCuratorCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/watch/TestSingleLevelCuratorCache.java index 4ccf3b7..c3cc327 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/watch/TestSingleLevelCuratorCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/watch/TestSingleLevelCuratorCache.java @@ -284,8 +284,7 @@ public class TestSingleLevelCuratorCache extends BaseClassForTests final CountDownLatch updatedLatch = new CountDownLatch(1); final CountDownLatch addedLatch = new CountDownLatch(1); client.create().creatingParentsIfNeeded().forPath("/test"); - SingleLevelCacheFilter cacheFilter = new SingleLevelCacheFilter("/test", CacheAction.PATH_ONLY); - cache = CuratorCacheBuilder.builder(client, "/test").forSingleLevel().withCacheFilter(cacheFilter).build(); + cache = CuratorCacheBuilder.builder(client, "/test").forSingleLevel().withCacheFilter(CacheFilters.statOnly()).build(); cache.getListenable().addListener(new CacheListener() { @Override @@ -724,7 +723,7 @@ public class TestSingleLevelCuratorCache extends BaseClassForTests private void internalTestMode(CuratorFramework client, boolean cacheData) throws Exception { - CacheFilter cacheFilter = new SingleLevelCacheFilter("/test", cacheData ? CacheAction.PATH_AND_DATA : CacheAction.PATH_ONLY); + CacheFilter cacheFilter = cacheData ? CacheFilters.statAndData() : CacheFilters.statOnly(); try (CuratorCache cache = CuratorCacheBuilder.builder(client, "/test").forSingleLevel().withCacheFilter(cacheFilter).build() ) { final CountDownLatch latch = new CountDownLatch(2);