You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Emmanuel Lecharny <el...@apache.org> on 2009/02/15 09:29:53 UTC

UUID generator : which one ?

Hi guys,

we need to generate UUIDs for every single entry we store in the 
backend. The UUID is defined in a RFC [1]. There are 3 available UUID 
generators [2] I know of :
- standard Java UUID generator[3] (which only support version 3 and 4 - 
ie using a hashed URI or a random number - )
- JUG [4] which support all the version but 2
- UUID [5] which only support version 1 (MAC address based)

Here is a short comparison : [6]


The question is to determinate which generator we should use, assuming 
the licenses are compatible ?

Wdyt ?


[1] http://www.rfc-editor.org/rfc/rfc4122.txt
[2] http://en.wikipedia.org/wiki/UUID
[3] http://java.sun.com/j2se/1.5.0/docs/api/java/util/UUID.html
[4] http://jug.safehaus.org/
[5] http://johannburkard.de/software/uuid/
[6] 
http://johannburkard.de/blog/programming/java/Java-UUID-generators-compared.html

-- 
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org



Re: UUID generator : which one ?

Posted by Emmanuel Lecharny <el...@apache.org>.
Some more insights :

o there are 5 different versions for an UUID :
 - MAC address based (v1)
 - DCE Security based (v2)
 - Name based + MD5 hash ( v3)
 - Random (v4)
 - Name based + SHA1 hash (v5)

As we need a Unique identifier, obviously, V4 can't be a good candidate 
(the collision is still possible, even if not likely). MAC address can 
be discovered in JAVA, but as you only have one MAC address per ethernet 
card, if you want more than one instance of ADS installed on a local 
server, you also may have some collision. So V1 is not a good candidate.
 I don't know how V2 differs from V1.

My guess is that we should use a V3 or V5 UUID, with V5 to be prefered 
over V3.

This shorten the list of possible UUID generator to JDK and Jug.


Stefan Seelmann wrote:
> I'd choose java.util.UUID because it is included in each JDK, no extra
> lib needed.
>   
I agree.

> Maybe we shouldn't use one implementation directly but use a factory
> method. This makes it easier to switch the choosen implementation.
>
> Example:
>   public String generateUUID(String input);
> or
>   public String generateUUID(byte[] input);
>
> The input would only be used to generate version 3 or 5 UUIDs.
>   
I like the factory idea. We can do it easily.

Thanks !

-- 
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org



Re: UUID generator : which one ?

Posted by Emmanuel Lecharny <el...@apache.org>.
Alex Karasulu wrote:
> On Sun, Feb 15, 2009 at 4:51 AM, Stefan Seelmann <se...@apache.org>wrote:
>
>   
>> I'd choose java.util.UUID because it is included in each JDK, no extra
>> lib needed.
>>
>>     
>
> Yeah but this is unfortunately only available in JDK 6 and would lock us
> into that.  I personally don't mind because 1.5 is almost at it's end.
>   
It's available in Java 5. The only problem is that it's slow and can't 
generate UUID based on the MAC address.

-- 
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org



Re: UUID generator : which one ?

Posted by Alex Karasulu <ak...@gmail.com>.
On Sun, Feb 15, 2009 at 4:51 AM, Stefan Seelmann <se...@apache.org>wrote:

> I'd choose java.util.UUID because it is included in each JDK, no extra
> lib needed.
>

Yeah but this is unfortunately only available in JDK 6 and would lock us
into that.  I personally don't mind because 1.5 is almost at it's end.


>
> Maybe we shouldn't use one implementation directly but use a factory
> method. This makes it easier to switch the choosen implementation.
>
> Example:
>  public String generateUUID(String input);
> or
>  public String generateUUID(byte[] input);
>

Yep this is what I was going to do but did not have time.  If JDK 6 is
available it should default to the stuff provided.  Otherwise it can use
some of the libraries out there to do this.

Alex

Re: UUID generator : which one ?

Posted by Stefan Seelmann <se...@apache.org>.
I'd choose java.util.UUID because it is included in each JDK, no extra
lib needed.

Maybe we shouldn't use one implementation directly but use a factory
method. This makes it easier to switch the choosen implementation.

Example:
  public String generateUUID(String input);
or
  public String generateUUID(byte[] input);

The input would only be used to generate version 3 or 5 UUIDs.

Kind Regards,
Stefan


Emmanuel Lecharny wrote:
> Hi guys,
> 
> we need to generate UUIDs for every single entry we store in the
> backend. The UUID is defined in a RFC [1]. There are 3 available UUID
> generators [2] I know of :
> - standard Java UUID generator[3] (which only support version 3 and 4 -
> ie using a hashed URI or a random number - )
> - JUG [4] which support all the version but 2
> - UUID [5] which only support version 1 (MAC address based)
> 
> Here is a short comparison : [6]
> 
> 
> The question is to determinate which generator we should use, assuming
> the licenses are compatible ?
> 
> Wdyt ?
> 
> 
> [1] http://www.rfc-editor.org/rfc/rfc4122.txt
> [2] http://en.wikipedia.org/wiki/UUID
> [3] http://java.sun.com/j2se/1.5.0/docs/api/java/util/UUID.html
> [4] http://jug.safehaus.org/
> [5] http://johannburkard.de/software/uuid/
> [6]
> http://johannburkard.de/blog/programming/java/Java-UUID-generators-compared.html
> 
>