You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Kallin Nagelberg <ka...@gmail.com> on 2011/02/07 22:57:36 UTC

unique key generation

Hey,

I am developing a session management system using Cassandra and need
to generate unique sessionIDs (cassandra columnfamily keys). Does
anyone know of an elegant/simple way to accomplish this? I am not sure
about using time based uuids on the client as there a chance that
multiple clients could generate the same ID. I've heard suggestions of
using zookeeper as a source for the IDs, but was just hoping that
there might be something simpler for my purposes.

Thanks,
-Kal

Re: unique key generation

Posted by Victor Kabdebon <vi...@gmail.com>.
It depends on the way you generate your UUID.

Here is a random and very efficient way to generate UUID with a good package
:

http://johannburkard.de/software/uuid/

Best regards,
Victor Kabdebon
http://www.voxnucleus.fr

2011/2/7 Kallin Nagelberg <ka...@gmail.com>

> Pretty sure it also uses mac address, so chances are very slim. I'll check
> out time uuid too, thanks.
>
> On 7 Feb 2011 17:11, "Victor Kabdebon" <vi...@gmail.com> wrote:
>
> Hello Kallin.
> If you use timeUUID the chance to generate two time the same uuid is the
> following :
> considering that both client generate the uuid at the *same millisecond*,
> the chance of generating the same uuid is :
>
> 1/1.84467441 × 1019Which is equal to the probability for winning a
> national lottery for 1e11 days in a row ( for 270 million years).
> Well if you do have a collision you should play the lottery :).
>
> Best regards,
> Victor Kabdebon
> http://www.voxnucleus.fr
>
> 2011/2/7 Kallin Nagelberg <ka...@gmail.com>
>
>
> >
> > Hey,
> >
> > I am developing a session management system using Cassandra and need
> > to generate uni...
>
>

Re: unique key generation

Posted by Kallin Nagelberg <ka...@gmail.com>.
Pretty sure it also uses mac address, so chances are very slim. I'll check
out time uuid too, thanks.

On 7 Feb 2011 17:11, "Victor Kabdebon" <vi...@gmail.com> wrote:

Hello Kallin.
If you use timeUUID the chance to generate two time the same uuid is the
following :
considering that both client generate the uuid at the *same millisecond*,
the chance of generating the same uuid is :

1/1.84467441 × 1019Which is equal to the probability for winning a national
lottery for 1e11 days in a row ( for 270 million years).
Well if you do have a collision you should play the lottery :).

Best regards,
Victor Kabdebon
http://www.voxnucleus.fr

2011/2/7 Kallin Nagelberg <ka...@gmail.com>


>
> Hey,
>
> I am developing a session management system using Cassandra and need
> to generate uni...

Re: unique key generation

Posted by Victor Kabdebon <vi...@gmail.com>.
Hello Kallin.
If you use timeUUID the chance to generate two time the same uuid is the
following :
considering that both client generate the uuid at the *same millisecond*,
the chance of generating the same uuid is :

1/1.84467441 × 1019Which is equal to the probability for winning a national
lottery for 1e11 days in a row ( for 270 million years).
Well if you do have a collision you should play the lottery :).

Best regards,
Victor Kabdebon
http://www.voxnucleus.fr

2011/2/7 Kallin Nagelberg <ka...@gmail.com>

> Hey,
>
> I am developing a session management system using Cassandra and need
> to generate unique sessionIDs (cassandra columnfamily keys). Does
> anyone know of an elegant/simple way to accomplish this? I am not sure
> about using time based uuids on the client as there a chance that
> multiple clients could generate the same ID. I've heard suggestions of
> using zookeeper as a source for the IDs, but was just hoping that
> there might be something simpler for my purposes.
>
> Thanks,
> -Kal
>

Re: unique key generation

Posted by Patricio Echagüe <pa...@gmail.com>.
If you are a Hector user, TimeUUIDUtils can be used to create Time UUIDs.

https://github.com/rantav/hector/blob/master/core/src/main/java/me/prettyprint/cassandra/utils/TimeUUIDUtils.java


On Mon, Feb 7, 2011 at 2:11 PM, Kallin Nagelberg <kallin.nagelberg@gmail.com
> wrote:

> Maybe I can just use java5's UUID.. Need to research how this is
> effective across multiple clients..
>
> On Mon, Feb 7, 2011 at 4:57 PM, Kallin Nagelberg
> <ka...@gmail.com> wrote:
> > Hey,
> >
> > I am developing a session management system using Cassandra and need
> > to generate unique sessionIDs (cassandra columnfamily keys). Does
> > anyone know of an elegant/simple way to accomplish this? I am not sure
> > about using time based uuids on the client as there a chance that
> > multiple clients could generate the same ID. I've heard suggestions of
> > using zookeeper as a source for the IDs, but was just hoping that
> > there might be something simpler for my purposes.
> >
> > Thanks,
> > -Kal
> >
>

Re: unique key generation

Posted by Kallin Nagelberg <ka...@gmail.com>.
Maybe I can just use java5's UUID.. Need to research how this is
effective across multiple clients..

On Mon, Feb 7, 2011 at 4:57 PM, Kallin Nagelberg
<ka...@gmail.com> wrote:
> Hey,
>
> I am developing a session management system using Cassandra and need
> to generate unique sessionIDs (cassandra columnfamily keys). Does
> anyone know of an elegant/simple way to accomplish this? I am not sure
> about using time based uuids on the client as there a chance that
> multiple clients could generate the same ID. I've heard suggestions of
> using zookeeper as a source for the IDs, but was just hoping that
> there might be something simpler for my purposes.
>
> Thanks,
> -Kal
>