jira-importer commented on issue #554: URL: https://github.com/apache/curator/issues/554#issuecomment-2604695459
<i><a href="https://issues.apache.org/jira/secure/ViewProfile.jspa?name=githubbot">githubbot</a>:</i> <p>Github user cconroy commented on a diff in the pull request:</p> <p> <a href="https://github.com/apache/curator/pull/17#discussion_r15123089" class="external-link" target="_blank" rel="nofollow noopener">https://github.com/apache/curator/pull/17#discussion_r15123089</a></p> <p> — Diff: curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java —<br/> @@ -0,0 +1,600 @@<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/> +import com.google.common.base.Function;<br/> +import com.google.common.collect.ImmutableSortedSet;<br/> +import com.google.common.collect.Maps;<br/> +import org.apache.curator.framework.CuratorFramework;<br/> +import org.apache.curator.framework.api.BackgroundCallback;<br/> +import org.apache.curator.framework.api.CuratorEvent;<br/> +import org.apache.curator.framework.listen.ListenerContainer;<br/> +import org.apache.curator.framework.state.ConnectionState;<br/> +import org.apache.curator.framework.state.ConnectionStateListener;<br/> +import org.apache.curator.utils.CloseableExecutorService;<br/> +import org.apache.curator.utils.ThreadUtils;<br/> +import org.apache.curator.utils.ZKPaths;<br/> +import org.apache.zookeeper.KeeperException;<br/> +import org.apache.zookeeper.WatchedEvent;<br/> +import org.apache.zookeeper.Watcher;<br/> +import org.apache.zookeeper.data.Stat;<br/> +import org.slf4j.Logger;<br/> +import org.slf4j.LoggerFactory;<br/> +import java.io.Closeable;<br/> +import java.io.IOException;<br/> +import java.util.ArrayList;<br/> +import java.util.Collections;<br/> +import java.util.List;<br/> +import java.util.SortedSet;<br/> +import java.util.concurrent.ConcurrentMap;<br/> +import java.util.concurrent.ExecutorService;<br/> +import java.util.concurrent.Executors;<br/> +import java.util.concurrent.ThreadFactory;<br/> +import java.util.concurrent.atomic.AtomicLong;<br/> +import java.util.concurrent.atomic.AtomicReference;<br/> +<br/> +/**<br/> + * <p>A utility that attempts to keep all data from all children of a ZK path locally cached. This class<br/> + * will watch the ZK path, respond to update/create/delete events, pull down the data, etc. You can<br/> + * register a listener that will get notified when changes occur.</p><br/> + * <p></p><br/> + * <p><b>IMPORTANT</b> - it's not possible to stay transactionally in sync. Users of this class must<br/> — End diff –</p> <p> I know this comment comes form path and node cache, but I find it very unhelpful. I think it would be more clear to note that a sequence of updates to any two nodes may be delivered in any sequence by the cache. </p> <p> But, it also seems like we should be able to offer a much stronger consistency guarantee. Watches are guaranteed to fire in order from the ZK protocol level, and therefore we should be able to give consistent delivery of e.g. a recursive delete bottom up, tree creation top-down, etc. TreeCache is potentially in a much better position to do this since it need not segment the listener for each path into its own single threaded executor. </p> <p> The only major caveat I see here is on a disconnect/reconnect case where we have to re-read the tree, but the events could still be synthesized in correct tree order for add/remove.</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