curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dragonsinth <...@git.apache.org>
Subject [GitHub] curator pull request: CURATOR-33 recursive TreeCache recipe
Date Fri, 18 Jul 2014 18:52:47 GMT
Github user dragonsinth commented on a diff in the pull request:

    https://github.com/apache/curator/pull/17#discussion_r15127479
  
    --- Diff: curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCacheEvent.java
---
    @@ -0,0 +1,126 @@
    +/**
    + * 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.cache;
    +
    +/**
    + * POJO that abstracts a change to a path
    + */
    +public class TreeCacheEvent
    +{
    +    private final Type type;
    +    private final ChildData data;
    +
    +    /**
    +     * Type of change
    +     */
    +    public enum Type
    +    {
    +        /**
    +         * A node was added.
    +         */
    +        NODE_ADDED,
    +
    +        /**
    +         * A node's data was changed
    +         */
    +        NODE_UPDATED,
    +
    +        /**
    +         * A node was removed from the tree
    +         */
    +        NODE_REMOVED,
    +
    +        /**
    +         * Called when the connection has changed to {@link org.apache.curator.framework.state.ConnectionState#SUSPENDED}
    +         * <p/>
    +         * This is exposed so that users of the class can be notified of issues that
*might* affect normal operation.
    +         * The TreeCache is written such that listeners are not expected to do anything
special on this
    +         * event, except for those people who want to cause some application-specific
logic to fire when this occurs.
    +         * 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.
    +         */
    +        CONNECTION_SUSPENDED,
    +
    +        /**
    +         * Called when the connection has changed to {@link org.apache.curator.framework.state.ConnectionState#RECONNECTED}
    +         * <p/>
    +         * This is exposed so that users of the class can be notified of issues that
*might* affect normal operation.
    +         * The TreeCache is written such that listeners are not expected to do anything
special on this
    +         * event, except for those people who want to cause some application-specific
logic to fire when this occurs.
    +         * 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.
    +         */
    +        CONNECTION_RECONNECTED,
    +
    +        /**
    +         * Called when the connection has changed to {@link org.apache.curator.framework.state.ConnectionState#LOST}
    +         * <p/>
    +         * This is exposed so that users of the class can be notified of issues that
*might* affect normal operation.
    +         * The TreeCache is written such that listeners are not expected to do anything
special on this
    +         * event, except for those people who want to cause some application-specific
logic to fire when this occurs.
    +         * 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.
    +         */
    +        CONNECTION_LOST,
    +
    +        /**
    +         * Posted when the initial cache has been populated.
    --- End diff --
    
    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.
    
    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.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message