You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by Diego Oliveira <lo...@gmail.com> on 2012/04/26 05:01:52 UTC

ZNODE time to live

Hello,

    The zookeeper project is just amazing, I'm using it in production and
is a big break trough int the way distributed software can be developed,
but and I'm in a situation that I think there is a better approach.

    I have some information that is stored in a znode to control a group of
servers, if the znode with a given name exists a action can NOT be
performed again, but this is time relative, after some interval I don't
need that information any more.


+---------+
|   SRV A |  (1) +---------------+
+---------+ ---->|   ZK ZNODE(1) |
                 +---------------+
     +---------+(2)|     |(3)
     |   SRV B |---+  +---------+
     +---------+      |  SRV C  |
                      +---------+

1) The server A create the ZNODE(1)
2) The server B will not try to do the JOB because the ZNODE(1) that
controls that job was created by the other server.
2) The server C will not try to do the JOB because the ZNODE(1) that
controls that job was created by the other server.

After some time the ZNODE(1) must be removed to clean the information from
zookeeper memory, so I have a thread to do this cleaning. But, from time to
time, I'm listing all znodes in an parent znode, reading it's data and
remove if the date that is written in the data is less then now. I think
that may be some sort of "time to live" information associated with a znode
that the zookeeper itself could do the auto cleanup.

Does some one know how the auto cleanup may be done or if the way I'm
currently doing is the right one?

-- 
Att.
Diego de Oliveira
System Architect
diego@diegooliveira.com
www.diegooliveira.com
Never argue with a fool -- people might not be able to tell the difference

Re: ZNODE time to live

Posted by Patrick Hunt <ph...@apache.org>.
What you're currently doing sounds correct based on current
functionality. There is no TTL like feature in the current
implementation.

Patrick

On Wed, Apr 25, 2012 at 8:01 PM, Diego Oliveira <lo...@gmail.com> wrote:
> Hello,
>
>    The zookeeper project is just amazing, I'm using it in production and
> is a big break trough int the way distributed software can be developed,
> but and I'm in a situation that I think there is a better approach.
>
>    I have some information that is stored in a znode to control a group of
> servers, if the znode with a given name exists a action can NOT be
> performed again, but this is time relative, after some interval I don't
> need that information any more.
>
>
> +---------+
> |   SRV A |  (1) +---------------+
> +---------+ ---->|   ZK ZNODE(1) |
>                 +---------------+
>     +---------+(2)|     |(3)
>     |   SRV B |---+  +---------+
>     +---------+      |  SRV C  |
>                      +---------+
>
> 1) The server A create the ZNODE(1)
> 2) The server B will not try to do the JOB because the ZNODE(1) that
> controls that job was created by the other server.
> 2) The server C will not try to do the JOB because the ZNODE(1) that
> controls that job was created by the other server.
>
> After some time the ZNODE(1) must be removed to clean the information from
> zookeeper memory, so I have a thread to do this cleaning. But, from time to
> time, I'm listing all znodes in an parent znode, reading it's data and
> remove if the date that is written in the data is less then now. I think
> that may be some sort of "time to live" information associated with a znode
> that the zookeeper itself could do the auto cleanup.
>
> Does some one know how the auto cleanup may be done or if the way I'm
> currently doing is the right one?
>
> --
> Att.
> Diego de Oliveira
> System Architect
> diego@diegooliveira.com
> www.diegooliveira.com
> Never argue with a fool -- people might not be able to tell the difference