kazoo
kazoo copied to clipboard
Possibility to create nodes with TTL
Hi,
Current versions of Zookeeper allow to specify a TTL for node removal. What about making this library compatible with that?
Thanks in advance, Daniel
Pull requests are welcome. Currently I (and AFAIK the other maintainers) don't have much bandwidth to add new features, but I do try to review PRs.
What work would this entail? If someone could describe this better and if it's not a crazy amount of work, I could pick it up.
From quick first review, it seems like we'd be adding support for https://zookeeper.apache.org/doc/r3.5.4-beta/zookeeperProgrammers.html#TTL+Nodes.
The code would go somewhere here https://github.com/python-zk/kazoo/blob/master/kazoo/client.py#L812-L963 (along with changes to test). I can't find the API call to make in the API/Java Client https://zookeeper.apache.org/doc/r3.4.6/api/org/apache/zookeeper/ZooKeeper.html#create(java.lang.String,%20byte[],%20java.util.List,%20org.apache.zookeeper.CreateMode). Any tips on what the API call would look like will be helpful!
Other info: Seems like it's only supported for PERSISTENT and PERSISTENT_SEQUENTIAL type nodes. And that it's not enabled by default in zookeeper right now (mentioned in the TTL Node description link above)
@nakulpathak3 I think you are right, a new parameter ttl
could be added to the create()
and create_async()
methods with, I guess, default to None
.
I think you didn't find the ttl
parameter in the Java client because this feature was added for the 3.5.3 version and you were looking at the 3.4.6 version. I found the method here: https://zookeeper.apache.org/doc/r3.5.4-beta/api/org/apache/zookeeper/ZooKeeper.html#create-java.lang.String-byte:A-java.util.List-org.apache.zookeeper.CreateMode-org.apache.zookeeper.data.Stat-long-
As far as I can see in the code (https://github.com/apache/zookeeper/blob/release-3.5.4/src/java/main/org/apache/zookeeper/ZooKeeper.java#L1634), it requires the CreateTTL
request that we currently don't have in the client. You will need to add it the kazoo.protocol.serialization
module with type=21
(https://github.com/apache/zookeeper/blob/cb9f303bda9137d1aebe8eff3eab85c8a59f3cdd/zookeeper-server/src/main/java/org/apache/zookeeper/ZooDefs.java#L75 & https://github.com/apache/zookeeper/blob/release-3.5.4/src/zookeeper.jute#L130).
Since you need a specific zookeeper configuration for the test, I suggest you to use what I developed when I added the SASL support (https://github.com/python-zk/kazoo/blob/master/kazoo/testing/harness.py#L42-L51)
I won't have time to tackle this for the next few weeks unfortunately so if someone else sees this and wants to until then, go ahead. If not, I'll come back around mid February.
I will take this up.
I am also interested in this feature. What is the current state?
It is complete.
The upstream bug which we discovered while writing tests (CREATE2 in Transaction) is actually just fixed in 3.8.2. https://issues.apache.org/jira/browse/ZOOKEEPER-4026
We should rebase and merge.
Cheers,
On Mon, Aug 7, 2023 at 9:52 AM rei-ber @.***> wrote:
I am also interested in this feature. What is the current state?
— Reply to this email directly, view it on GitHub https://github.com/python-zk/kazoo/issues/496#issuecomment-1667900461, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIFTHV45Y6QLZVFR77P7KLXUDXJTANCNFSM4ETSOVQQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
-- Charles-Henri de Boysson
When do you plan to merge it? And when do you plan a new kazoo release?