i'm not exactly clear how you use these ideas, but one source of unique ids that are longs is the zxid. if you create a znode, everytime you write to it, you will get a unique zxid in the mzxid member of the stat structure. (you get the stat structure back in the response to the setData.)


Mahadev Konar wrote:
Hi Satish,
 Most of the sequences (versions of nodes ) and the sequence flags are ints.
We do have plans to move it to long.
But in your case I can imagine you can split a long into 2 32 bits -

Parent (which is int) -> child(which is int)
Now after you run out of child epehemarls then you should create a node
Parent + 1
Remove parent And then start creating an ephemeral child

(so parent (32 bits) and child (32 bits)) would form a long.

I don't think this should be very hard to implement. Their is nothing in
zookeeper (out of the box) currently that would help you out.

On 4/23/09 4:52 PM, "Satish Bhatti" <cthd2...@gmail.com> wrote:

We currently use a database sequence to generate unique ids for use by our
application.  I was thinking about using ZooKeeper instead so I can get rid
of the database.  My plan was to use the sequential id from ephemeral nodes,
but looking at the code it appears that this is an int, not a long.  Is
there any other straightforward way to generate ids using ZooKeeper?


Reply via email to