jira-importer commented on issue #554: URL: https://github.com/apache/curator/issues/554#issuecomment-2604695513
<i><a href="https://issues.apache.org/jira/secure/ViewProfile.jspa?name=githubbot">githubbot</a>:</i> <p>Github user dragonsinth commented on a diff in the pull request:</p> <p> <a href="https://github.com/apache/curator/pull/17#discussion_r15127479" class="external-link" target="_blank" rel="nofollow noopener">https://github.com/apache/curator/pull/17#discussion_r15127479</a></p> <p> — Diff: curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCacheEvent.java —<br/> @@ -0,0 +1,126 @@<br/> +/**<br/> + * Licensed to the Apache Software Foundation (ASF) under one<br/> + * or more contributor license agreements. See the NOTICE file<br/> + * distributed with this work for additional information<br/> + * regarding copyright ownership. The ASF licenses this file<br/> + * to you under the Apache License, Version 2.0 (the<br/> + * "License"); you may not use this file except in compliance<br/> + * with the License. You may obtain a copy of the License at<br/> + *<br/> + * <a href="http://www.apache.org/licenses/LICENSE-2.0" class="external-link" target="_blank" rel="nofollow noopener">http://www.apache.org/licenses/LICENSE-2.0</a><br/> + *<br/> + * Unless required by applicable law or agreed to in writing,<br/> + * software distributed under the License is distributed on an<br/> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY<br/> + * KIND, either express or implied. See the License for the<br/> + * specific language governing permissions and limitations<br/> + * under the License.<br/> + */<br/> +<br/> +package org.apache.curator.framework.recipes.cache;<br/> +<br/> +/**<br/> + * POJO that abstracts a change to a path<br/> + */<br/> +public class TreeCacheEvent<br/> +{<br/> + private final Type type;<br/> + private final ChildData data;<br/> +<br/> + /**<br/> + * Type of change<br/> + */<br/> + public enum Type<br/> + {<br/> +/**<br/> + * A node was added.<br/> + */<br/> +NODE_ADDED,<br/> +<br/> +/**<br/> + * A node's data was changed<br/> + */<br/> +NODE_UPDATED,<br/> +<br/> +/**<br/> + * A node was removed from the tree<br/> + */<br/> +NODE_REMOVED,<br/> +<br/> +/**<br/> + * Called when the connection has changed to </p> {@link org.apache.curator.framework.state.ConnectionState#SUSPENDED} <p> + * <p/><br/> + * This is exposed so that users of the class can be notified of issues that <b>might</b> affect normal operation.<br/> + * The TreeCache is written such that listeners are not expected to do anything special on this<br/> + * event, except for those people who want to cause some application-specific logic to fire when this occurs.<br/> + * While the connection is down, the TreeCache will continue to have its state from before it lost<br/> + * the connection and after the connection is restored, the TreeCache will emit normal child events<br/> + * for all of the adds, deletes and updates that happened during the time that it was disconnected.<br/> + */<br/> +CONNECTION_SUSPENDED,<br/> +<br/> +/**<br/> + * Called when the connection has changed to </p> {@link org.apache.curator.framework.state.ConnectionState#RECONNECTED} <p> + * <p/><br/> + * This is exposed so that users of the class can be notified of issues that <b>might</b> affect normal operation.<br/> + * The TreeCache is written such that listeners are not expected to do anything special on this<br/> + * event, except for those people who want to cause some application-specific logic to fire when this occurs.<br/> + * While the connection is down, the TreeCache will continue to have its state from before it lost<br/> + * the connection and after the connection is restored, the TreeCache will emit normal child events<br/> + * for all of the adds, deletes and updates that happened during the time that it was disconnected.<br/> + */<br/> +CONNECTION_RECONNECTED,<br/> +<br/> +/**<br/> + * Called when the connection has changed to </p> {@link org.apache.curator.framework.state.ConnectionState#LOST} <p> + * <p/><br/> + * This is exposed so that users of the class can be notified of issues that <b>might</b> affect normal operation.<br/> + * The TreeCache is written such that listeners are not expected to do anything special on this<br/> + * event, except for those people who want to cause some application-specific logic to fire when this occurs.<br/> + * While the connection is down, the TreeCache will continue to have its state from before it lost<br/> + * the connection and after the connection is restored, the TreeCache will emit normal child events<br/> + * for all of the adds, deletes and updates that happened during the time that it was disconnected.<br/> + */<br/> +CONNECTION_LOST,<br/> +<br/> +/**<br/> + * Posted when the initial cache has been populated.<br/> — End diff –</p> <p> Yeah, exactly the same. It fires events as it builds the tree, followed by an initialized event when the first pass is complete. The test code should be fairly illuminating, but it needs to be in javadoc too since the tests don't ship.</p> <p> The only difference is TreeCache doesn't have the startup mode options, I just wanted to simplify things and make it work the way that made the most sense. So you can either just stream events from TreeCache and build your own representation without worry about the details, responding to add/remove/update events; or else you can wait for the initialized event and then pull the tree data.</p> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@curator.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org