Repository: curator Updated Branches: refs/heads/CURATOR-3.0 ec858f282 -> 1f866815a
TreeCache should inform listeners when its fully reconnected. Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/4b59a5bf Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/4b59a5bf Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/4b59a5bf Branch: refs/heads/CURATOR-3.0 Commit: 4b59a5bf8820d402350127779387271b77c68be4 Parents: d124a0a Author: Scott Blum <[email protected]> Authored: Tue Jul 21 21:50:43 2015 -0400 Committer: Scott Blum <[email protected]> Committed: Mon Feb 1 14:17:29 2016 -0500 ---------------------------------------------------------------------- .../org/apache/curator/framework/recipes/cache/TreeCache.java | 1 + .../apache/curator/framework/recipes/cache/TreeCacheEvent.java | 6 ++++++ .../apache/curator/framework/recipes/cache/TestTreeCache.java | 1 + 3 files changed, 8 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/4b59a5bf/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java index 3f7d8d4..127a9f3 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java @@ -779,6 +779,7 @@ public class TreeCache implements Closeable break; case LOST: + isInitialized.set(false); publishEvent(TreeCacheEvent.Type.CONNECTION_LOST); break; http://git-wip-us.apache.org/repos/asf/curator/blob/4b59a5bf/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCacheEvent.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCacheEvent.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCacheEvent.java index c1fb1e5..b151037 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCacheEvent.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCacheEvent.java @@ -69,6 +69,9 @@ public class TreeCacheEvent * While the connection is down, the TreeCache will continue to have its state from before it lost * the connection and after the connection is restored, the TreeCache will emit normal child events * for all of the adds, deletes and updates that happened during the time that it was disconnected. + * </p><p> + * After reconnection, the cache will resynchronize its internal state with the server, then fire a + * {@link #INITIALIZED} event. * </p> */ CONNECTION_RECONNECTED, @@ -94,6 +97,9 @@ public class TreeCacheEvent * the cachehas been fully synchronized, this {@link #INITIALIZED} this event is published. All events * published after this event represent actual server-side mutations. * </p><p> + * On reconnection, the cache will resynchronize its internal state with the server, and fire this event again + * once its internal state is completely refreshed. + * </p><p> * Note: because the initial population is inherently asynchronous, so it's possible to observe server-side changes * (such as a {@link #NODE_UPDATED}) prior to this event being published. * </p> http://git-wip-us.apache.org/repos/asf/curator/blob/4b59a5bf/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java index ad7c417..712e41b 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java @@ -428,6 +428,7 @@ public class TestTreeCache extends BaseTestTreeCache assertEvent(TreeCacheEvent.Type.CONNECTION_LOST); assertEvent(TreeCacheEvent.Type.CONNECTION_RECONNECTED); assertEvent(TreeCacheEvent.Type.NODE_REMOVED, "/test/me", "data".getBytes()); + assertEvent(TreeCacheEvent.Type.INITIALIZED); assertNoMoreEvents(); }
