[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-104?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12617243#action_12617243
 ] 

Patrick Hunt commented on ZOOKEEPER-104:
----------------------------------------

Great idea, +1

I agree with flavio, this should go into contrib, unfort we don't have one yet. 
Makes sense to me that this should be part of the recipes
src/contrib/recipes/src/java/org/apache/zookeeper/recipes/util/KeptSet.java
package org.apache.zookeeper.recipes.util.KeptSet
how's that sound?

Anthony, I think there's an issue in the watcher - it doesn't handle the case 
where the client is re-connected (disconnected then reconnected) - ie the set 
is not resync'd with the server after disconnect.

(the following doc hasn't been moved to apache yet)
http://zookeeper.wiki.sourceforge.net/ZooKeeperWatches
specifically:
"when a client gets a disconnect event, it must consider that an implicit 
trigger of all watches. When a client reconnects to a new server, the client 
should re-set any watches that it is still interested in"

Also, this is a leaky abstraction (not that that's necessarily bad). Notice 
that if two clients add the same, new, string to the same set (relative to the 
znode path on the zk server) one of the clients will succeed and the other will 
get a runtime exception (wrapping keeperexception) (rather than add returning 
false, which would happen if the client added a string that was already 
present). Also note that the set is updated via a watch (even for changes made 
by this client), so you could add a string and an immediate check for existence 
may fail. Might be confusing for ppl expecting Set semantics, would be a good 
idea to document.


> KeptSet: a distributed data stucture backed by the children of a ZooKeeper 
> node
> -------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-104
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-104
>             Project: Zookeeper
>          Issue Type: New Feature
>          Components: java client
>            Reporter: Anthony Urso
>            Assignee: Anthony Urso
>            Priority: Minor
>         Attachments: ZOOKEEPER-104.patch
>
>
> Here is an implementation of a ZooKeeper backed Java Set. It should be 
> generally useful.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to