Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Zookeeper >> mail # user >> Multi question on using previous ops results

Joe Gamache 2012-05-16, 15:59
Ted Dunning 2012-05-16, 23:21
Joe Gamache 2012-05-17, 00:06
Joe Gamache 2012-05-18, 15:43
Ted Dunning 2012-05-18, 16:46
Joe Gamache 2012-05-18, 17:55
Copy link to this message
Re: Multi question on using previous ops results
On Fri, May 18, 2012 at 1:55 PM, Joe Gamache <[EMAIL PROTECTED]>wrote:

> ...
> I have a one process that is trying to create some "work" that will be
> represented via a ZNode.   A large number of other processes are looking
> for work.   The node that represents the work will be sequential.  Most
> importantly, it will be incomplete until the structure below it is
> completed.
That is easy.  Just create the lower structures first.  If the upper
structure needs to have an indicator that it is under construction, just
set a bit inside it using the atomic update method.  Or create a separate
node to do leader election.
> Thus, I would like to be able to create that node and lock it atomically
> OR create the entire structure below it atomically.
Remember ZK doesn't do locks.

You can create the node with the "under-construction" bit set.   Or you can
use a multi to create the parent and children simultaneously.   You can
create the parent with references to a version in another node by getting
the version of the parent, getting the versions of the children, updating
the parent with the version specified.  Retry with backoff on failure.

I would like to avoid hacking in another parallel node structure solely for
> the purpose of locking (as there will be many 1000's of these created)

As you like.  This can be handled pretty easily.  Setting watches on the
release of a node is a bit trickier, but can be handled as well.

> All I am really wondering is can Zookeeper do this?   If not, I can find
> alternate ways around - they just seem less elegant to me.

It can.
Joe Gamache 2012-05-20, 12:39