curator-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jordan Zimmerman <jor...@jordanzimmerman.com>
Subject Re: Atomically setting a node's data while having leadership
Date Wed, 11 Sep 2013 16:09:30 GMT
I think it could be done with a transaction. i.e. 

            client.inTransaction()
                .check().forPath("/leader/path/...")
                    .and()
                .setData().forPath("/some/other/path...", data)
                    .and()
                .commit()

So, we'd need to either expose the path/name of the leader's lock ZNode or make this a method
of LeaderSelector (and other lock-oriented recipes).

-JZ

On Sep 11, 2013, at 3:40 AM, Arie Zilberstein <azilberstein@salesforce.com> wrote:

> Hi,
> 
> I wonder if it is possible to achieve the following behavior: Assume a leader election
scenario where a certain process has been elected as leader and its takeLeadership() method
was called. Inside that method the process wishes to perform a Zookeeper operation, e.g.,
to set data in a node. But, the leader may receive a message saying to relinquish leadership
immediately at any point in time. So the question is, is it possible to set this data while
making sure that we're still the leader?
> Can Curator support this sort of an atomic "test-and-set" operation?
> 
> Thanks,
> Arie


Mime
View raw message