You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Muthu <mu...@gmail.com> on 2017/06/09 17:27:41 UTC

Grid/Cluster unique UUID possible with IgniteUuid?

Hi Folks,

Is it possible to generate a Grid/Cluster unique UUID using IgniteUuid. I
looked at the source code & static factory method *randomUuid
<https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/lang/IgniteUuid.html#randomUuid%28%29>*().
It looks like it generates one with with a java.util.UUID (generated with
its randomUUID) & an AutomicLong's incrementAndGet

Can i safely assume that given that it uses a combination of UUID & long on
the individual VMs that are part of the Grid/Cluster it will be unique or
is there a better way?

Regards,
Muthu

Re: Grid/Cluster unique UUID possible with IgniteUuid?

Posted by vkulichenko <va...@gmail.com>.
Muthu,

IgniteAtomicSequence generates unique long value, while IgniteUuid is a
heavier object. Other than that, they provide similar guarantees.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Grid-Cluster-unique-UUID-possible-with-IgniteUuid-tp13574p14281.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Grid/Cluster unique UUID possible with IgniteUuid?

Posted by Muthu <mu...@gmail.com>.
Hi Nikolai,

I looked at the code for this method earlier (reproduced below)...the UUID
is generated once (via VM_ID) per cluster node JVM & the atomic long again
is local to the cluster node JVM (unlike the *igniteAtomicSequence*). Do
you think its still okay to use it...i thought we at least need the
*igniteAtomicSequence *for cluster level uniqueness...

/** VM ID. */
public static final UUID VM_ID = UUID.randomUUID();

public static IgniteUuid randomUuid() {
return new IgniteUuid(VM_ID, cntGen.incrementAndGet());
}

Regards,
Muthu

On Tue, Jun 13, 2017 at 6:32 AM, Nikolai Tikhonov <nt...@apache.org>
wrote:

> Muthu,
>
> Look at Ignite Uuid#randomUuid() method. I think it will provide needed
> guarantees for your case.
>
> On Mon, Jun 12, 2017 at 9:53 PM, Muthu <mu...@gmail.com> wrote:
>
>> Thanks Nikolai..this is what i am doing...not sure if this is too
>> much..what do you think..the goal is to make sure that a UUID is unique
>> across the entire application (the problem is each node that is part of the
>> cluster would be doing this for different entities that it owns)
>>
>> ...
>> ...
>> System.out.println("==== in ObjectCacheMgrService.insertDepartment ====
>> for dept : " + dept);
>> long t1 = System.currentTimeMillis();
>> *String uUID = new IgniteUuid(UUID.randomUUID(),
>> igniteAtomicSequence.incrementAndGet()).toString();*
>> long t2 = System.currentTimeMillis();
>> System.out.println("Time for UUID generation (millis) : " + (t2 - t1));
>> *dept.setId(uUID);*
>> * deptCache.getAndPut(uUID, dept);*
>> System.out.println("==== in ObjectCacheMgrService.insertDepartment :
>> department ==== inserted successfully : " + dept);
>> ...
>> ...
>>
>> Regards,
>> Muthu
>>
>> On Mon, Jun 12, 2017 at 3:24 AM, Nikolai Tikhonov <nt...@apache.org>
>> wrote:
>>
>>> Muthu,
>>>
>>> Yes, you can use IgniteUUID as unique ID generator. What you will use
>>> depends your requirements. IgniteAtomicSequence takes one long and
>>> IgniteUUID takes 3 long. But getting new range sequence is distributed
>>> operation. You need to decied what more critical for your.
>>>
>>> On Fri, Jun 9, 2017 at 8:46 PM, Muthu <mu...@gmail.com> wrote:
>>>
>>>>
>>>> Missed adding this one...i know there is support for ID generation with
>>>> IgniteAtomicSequence @ https://apacheignite.readme.io/docs/id-generator
>>>>
>>>> The question is which one should i use...i want to use this to generate
>>>> unique ids for entities that are to be cached & persisted..
>>>>
>>>> Regards,
>>>> Muthu
>>>>
>>>>
>>>> On Fri, Jun 9, 2017 at 10:27 AM, Muthu <mu...@gmail.com>
>>>> wrote:
>>>>
>>>>> Hi Folks,
>>>>>
>>>>> Is it possible to generate a Grid/Cluster unique UUID using
>>>>> IgniteUuid. I looked at the source code & static factory method *randomUuid
>>>>> <https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/lang/IgniteUuid.html#randomUuid%28%29>*().
>>>>> It looks like it generates one with with a java.util.UUID (generated with
>>>>> its randomUUID) & an AutomicLong's incrementAndGet
>>>>>
>>>>> Can i safely assume that given that it uses a combination of UUID &
>>>>> long on the individual VMs that are part of the Grid/Cluster it will be
>>>>> unique or is there a better way?
>>>>>
>>>>> Regards,
>>>>> Muthu
>>>>>
>>>>
>>>>
>>>
>>
>

Re: Grid/Cluster unique UUID possible with IgniteUuid?

Posted by Nikolai Tikhonov <nt...@apache.org>.
Muthu,

Look at Ignite Uuid#randomUuid() method. I think it will provide needed
guarantees for your case.

On Mon, Jun 12, 2017 at 9:53 PM, Muthu <mu...@gmail.com> wrote:

> Thanks Nikolai..this is what i am doing...not sure if this is too
> much..what do you think..the goal is to make sure that a UUID is unique
> across the entire application (the problem is each node that is part of the
> cluster would be doing this for different entities that it owns)
>
> ...
> ...
> System.out.println("==== in ObjectCacheMgrService.insertDepartment ====
> for dept : " + dept);
> long t1 = System.currentTimeMillis();
> *String uUID = new IgniteUuid(UUID.randomUUID(),
> igniteAtomicSequence.incrementAndGet()).toString();*
> long t2 = System.currentTimeMillis();
> System.out.println("Time for UUID generation (millis) : " + (t2 - t1));
> *dept.setId(uUID);*
> * deptCache.getAndPut(uUID, dept);*
> System.out.println("==== in ObjectCacheMgrService.insertDepartment :
> department ==== inserted successfully : " + dept);
> ...
> ...
>
> Regards,
> Muthu
>
> On Mon, Jun 12, 2017 at 3:24 AM, Nikolai Tikhonov <nt...@apache.org>
> wrote:
>
>> Muthu,
>>
>> Yes, you can use IgniteUUID as unique ID generator. What you will use
>> depends your requirements. IgniteAtomicSequence takes one long and
>> IgniteUUID takes 3 long. But getting new range sequence is distributed
>> operation. You need to decied what more critical for your.
>>
>> On Fri, Jun 9, 2017 at 8:46 PM, Muthu <mu...@gmail.com> wrote:
>>
>>>
>>> Missed adding this one...i know there is support for ID generation with
>>> IgniteAtomicSequence @ https://apacheignite.readme.io/docs/id-generator
>>>
>>> The question is which one should i use...i want to use this to generate
>>> unique ids for entities that are to be cached & persisted..
>>>
>>> Regards,
>>> Muthu
>>>
>>>
>>> On Fri, Jun 9, 2017 at 10:27 AM, Muthu <mu...@gmail.com>
>>> wrote:
>>>
>>>> Hi Folks,
>>>>
>>>> Is it possible to generate a Grid/Cluster unique UUID using IgniteUuid.
>>>> I looked at the source code & static factory method *randomUuid
>>>> <https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/lang/IgniteUuid.html#randomUuid%28%29>*().
>>>> It looks like it generates one with with a java.util.UUID (generated with
>>>> its randomUUID) & an AutomicLong's incrementAndGet
>>>>
>>>> Can i safely assume that given that it uses a combination of UUID &
>>>> long on the individual VMs that are part of the Grid/Cluster it will be
>>>> unique or is there a better way?
>>>>
>>>> Regards,
>>>> Muthu
>>>>
>>>
>>>
>>
>

Re: Grid/Cluster unique UUID possible with IgniteUuid?

Posted by Muthu <mu...@gmail.com>.
Thanks Nikolai..this is what i am doing...not sure if this is too
much..what do you think..the goal is to make sure that a UUID is unique
across the entire application (the problem is each node that is part of the
cluster would be doing this for different entities that it owns)

...
...
System.out.println("==== in ObjectCacheMgrService.insertDepartment ==== for
dept : " + dept);
long t1 = System.currentTimeMillis();
*String uUID = new IgniteUuid(UUID.randomUUID(),
igniteAtomicSequence.incrementAndGet()).toString();*
long t2 = System.currentTimeMillis();
System.out.println("Time for UUID generation (millis) : " + (t2 - t1));
*dept.setId(uUID);*
* deptCache.getAndPut(uUID, dept);*
System.out.println("==== in ObjectCacheMgrService.insertDepartment :
department ==== inserted successfully : " + dept);
...
...

Regards,
Muthu

On Mon, Jun 12, 2017 at 3:24 AM, Nikolai Tikhonov <nt...@apache.org>
wrote:

> Muthu,
>
> Yes, you can use IgniteUUID as unique ID generator. What you will use
> depends your requirements. IgniteAtomicSequence takes one long and
> IgniteUUID takes 3 long. But getting new range sequence is distributed
> operation. You need to decied what more critical for your.
>
> On Fri, Jun 9, 2017 at 8:46 PM, Muthu <mu...@gmail.com> wrote:
>
>>
>> Missed adding this one...i know there is support for ID generation with
>> IgniteAtomicSequence @ https://apacheignite.readme.io/docs/id-generator
>>
>> The question is which one should i use...i want to use this to generate
>> unique ids for entities that are to be cached & persisted..
>>
>> Regards,
>> Muthu
>>
>>
>> On Fri, Jun 9, 2017 at 10:27 AM, Muthu <mu...@gmail.com> wrote:
>>
>>> Hi Folks,
>>>
>>> Is it possible to generate a Grid/Cluster unique UUID using IgniteUuid.
>>> I looked at the source code & static factory method *randomUuid
>>> <https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/lang/IgniteUuid.html#randomUuid%28%29>*().
>>> It looks like it generates one with with a java.util.UUID (generated with
>>> its randomUUID) & an AutomicLong's incrementAndGet
>>>
>>> Can i safely assume that given that it uses a combination of UUID & long
>>> on the individual VMs that are part of the Grid/Cluster it will be unique
>>> or is there a better way?
>>>
>>> Regards,
>>> Muthu
>>>
>>
>>
>

Re: Grid/Cluster unique UUID possible with IgniteUuid?

Posted by Nikolai Tikhonov <nt...@apache.org>.
Muthu,

Yes, you can use IgniteUUID as unique ID generator. What you will use
depends your requirements. IgniteAtomicSequence takes one long and
IgniteUUID takes 3 long. But getting new range sequence is distributed
operation. You need to decied what more critical for your.

On Fri, Jun 9, 2017 at 8:46 PM, Muthu <mu...@gmail.com> wrote:

>
> Missed adding this one...i know there is support for ID generation with
> IgniteAtomicSequence @ https://apacheignite.readme.io/docs/id-generator
>
> The question is which one should i use...i want to use this to generate
> unique ids for entities that are to be cached & persisted..
>
> Regards,
> Muthu
>
>
> On Fri, Jun 9, 2017 at 10:27 AM, Muthu <mu...@gmail.com> wrote:
>
>> Hi Folks,
>>
>> Is it possible to generate a Grid/Cluster unique UUID using IgniteUuid. I
>> looked at the source code & static factory method *randomUuid
>> <https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/lang/IgniteUuid.html#randomUuid%28%29>*().
>> It looks like it generates one with with a java.util.UUID (generated with
>> its randomUUID) & an AutomicLong's incrementAndGet
>>
>> Can i safely assume that given that it uses a combination of UUID & long
>> on the individual VMs that are part of the Grid/Cluster it will be unique
>> or is there a better way?
>>
>> Regards,
>> Muthu
>>
>
>

Re: Grid/Cluster unique UUID possible with IgniteUuid?

Posted by Muthu <mu...@gmail.com>.
Missed adding this one...i know there is support for ID generation with
IgniteAtomicSequence @ https://apacheignite.readme.io/docs/id-generator

The question is which one should i use...i want to use this to generate
unique ids for entities that are to be cached & persisted..

Regards,
Muthu


On Fri, Jun 9, 2017 at 10:27 AM, Muthu <mu...@gmail.com> wrote:

> Hi Folks,
>
> Is it possible to generate a Grid/Cluster unique UUID using IgniteUuid. I
> looked at the source code & static factory method *randomUuid
> <https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/lang/IgniteUuid.html#randomUuid%28%29>*().
> It looks like it generates one with with a java.util.UUID (generated with
> its randomUUID) & an AutomicLong's incrementAndGet
>
> Can i safely assume that given that it uses a combination of UUID & long
> on the individual VMs that are part of the Grid/Cluster it will be unique
> or is there a better way?
>
> Regards,
> Muthu
>