Use Mzxid to determine node change
Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/0fc0cbec Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/0fc0cbec Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/0fc0cbec Branch: refs/heads/CURATOR-351 Commit: 0fc0cbec1ad65d108e2c239f7a6ddfb93f3ed2b0 Parents: 127efd5 Author: randgalt <[email protected]> Authored: Sun Mar 12 15:24:56 2017 -0700 Committer: randgalt <[email protected]> Committed: Sun Mar 12 15:24:56 2017 -0700 ---------------------------------------------------------------------- .../framework/recipes/cache/PathChildrenCache.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/0fc0cbec/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java index c39b2c7..26d7801 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java @@ -45,7 +45,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.Closeable; import java.io.IOException; -import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Set; @@ -695,7 +694,7 @@ public class PathChildrenCache implements Closeable { offerOperation(new EventOperation(this, new PathChildrenCacheEvent(PathChildrenCacheEvent.Type.CHILD_ADDED, data))); } - else if ( hasChanged(stat, previousData, data) ) + else if ( stat.getMzxid() != previousData.getStat().getMzxid() ) { offerOperation(new EventOperation(this, new PathChildrenCacheEvent(PathChildrenCacheEvent.Type.CHILD_UPDATED, data))); } @@ -703,15 +702,6 @@ public class PathChildrenCache implements Closeable } } - private boolean hasChanged(Stat stat, ChildData previousData, ChildData newData) - { - if ( cacheData ) - { - return !Arrays.equals(previousData.getData(), newData.getData()); - } - return previousData.getStat().getVersion() != stat.getVersion(); - } - private void updateInitialSet(String name, ChildData data) { Map<String, ChildData> localInitialSet = initialSet.get();
