hadoop-zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mahadev Konar <maha...@yahoo-inc.com>
Subject Re: is there a good pattern for leases ?
Date Wed, 24 Feb 2010 19:22:38 GMT
I am not sure if I was clear enoguh in my last message.

What is suggested was this:

Create a client with a timeout of lets say 10 seconds!

Zookeeper zk = new ZooKeeper(10000); (for brevity ignoring other parameters)

Zk.create("/parent/ephemeral", data, EPEMERAL);

//create a another thread that triggeers at 120 seconds

On a trigger from this thread call zk.delete("/parent/ephemeral");

That's how lease can be done at the application side.

Obviously your lease expires on a session close and other events as well,
you need to be monitoring.

Thanks
mahadev


On 2/24/10 11:09 AM, "Martin Waite" <waite.134@googlemail.com> wrote:

> Hi Mahadev,
> 
> That is interesting.  All I need to do is hold the connection for the
> required time of a session that created an ephemeral node.
> 
> Zookeeper is an interesting tool.
> 
> Thanks again,
> Martin
> 
> On 24 February 2010 17:00, Mahadev Konar <mahadev@yahoo-inc.com> wrote:
> 
>> Hi Martin,
>>  There isnt an inherent model for leases in the zookeeper library itself.
>> To implement leases you will have to implement them at your application
>> side
>> with timeouts triggers (lease triggers) leading to session close at the
>> client.
>> 
>> 
>> Thanks
>> mahadev
>> 
>> 
>> On 2/24/10 3:40 AM, "Martin Waite" <waite.134@googlemail.com> wrote:
>> 
>>> Hi,
>>> 
>>> Is there a good model for implementing leases in Zookeeper ?
>>> 
>>> What I want to achieve is for a client to create a lock, and for that
>> lock
>>> to disappear two minutes later - regardless of whether the client is
>> still
>>> connected to zk.   Like ephemeral nodes - but with a time delay.
>>> 
>>> regards,
>>> Martin
>> 
>> 


Mime
View raw message