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

Benjamin Reed commented on ZOOKEEPER-78:
----------------------------------------

Fantastic work! I second Hiram's suggestion to implement the Lock interface. 
(You could probably throw unsupported exception for the condition method.) It 
would make your naming more symmetric anyway :)

I love the whenOwner field! Excellent idea. I think it would be good to allow 
it to be passed in the constructor.

I have a problem with your use of the facade. Here is the problematic scenario: 
your application waits for a lock and once acquired becomes the master. This 
master thread services clients but more importantly updates stuff in ZooKeeper. 
If the session expires and reconnects automatically, it is very easy for your 
master thread to make changes without actually being a master using the new 
session. If you don't use the facade, things fail properly: the connection 
expires, the master is no longer the master in ZooKeeper, and (most 
importantly) the master thread cannot do any ZooKeeper operations with the 
ZooKeeper object.

I realize the facade may seem convenient, but I think we need to encourage safe 
behavior especially with the first high level primitives and since yours will 
be the very first I'd like to make sure we get off to a safe start. (It's a 
great first example by the way!)

> added a high level protocol/feature - for easy Leader Election or exclusive 
> Write Lock creation
> -----------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-78
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-78
>             Project: Zookeeper
>          Issue Type: New Feature
>          Components: java client
>    Affects Versions: 3.0.0
>            Reporter: james strachan
>         Attachments: patch_with_including_Benjamin's_fix.patch, 
> using_zookeeper_facade.patch
>
>
> Here's a patch which adds a little WriteLock helper class for performing 
> leader elections or creating exclusive locks in some directory znode. Note 
> its an early cut; am sure we can improve it over time. The aim is to avoid 
> folks having to use the low level ZK stuff but provide a simpler high level 
> abstraction.

-- 
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