(RPM) Java generation UUID Universal Unique identifier (universally unique Identifier)

Source: Internet
Author: User

(Original link: http://blog.csdn.net/carefree31441/article/details/3998553)The UUID meaning is a universal unique identifier (universally unique Identifier), which is a software construction standard and is also organized by the Open Software Foundation, OSF, in a distributed computing environment ( Distributed Computing Environment, DCE) part of the field. The purpose of the UUID is to allow all elements in a distributed system to have unique identification information without the need to specify the information through the central control terminal. In this way, everyone can create a UUID that does not clash with others. In such a case, there is no need to consider the name duplication problem when the database is established. Currently the most widely used UUID is Microsoft's globally Unique Identifiers (GUIDs), while other important applications are the Linux ext2/ext3 file system, LUKS encryption partition, GNOME, KDE, Mac OS X, and so on.The following is an example of a specific build UUID:
1  Packagetest;2 3 ImportJava.util.UUID;4 5  Public classUuidgenerator {6      PublicUuidgenerator () {7     }8 9      Public StaticString Getuuid () {TenUUID UUID =Uuid.randomuuid (); OneString str =uuid.tostring (); A         //Remove the "-" symbol -String temp = str.replace ("-", ""); -         returnStr+ "," +temp; the     } -     //get a specified number of UUID -      Public StaticString[] Getuuid (intNumber ) { -         if(Number < 1) { +             return NULL; -         } +string[] ss =NewString[number]; A          for(inti = 0; I < number; i++) { atSs[i] =Getuuid (); -         } -         returnSS; -     } -  -      Public Static voidMain (string[] args) { instring[] ss = Getuuid (10); -          for(inti = 0; i < ss.length; i++) { toSystem.out.println ("ss[" +i+ "]=====" +ss[i]); +         } -     } the}

Results:

1ss[0]=====4cdbc040-657a-4847-b266-7e31d9e2c3d9,4cdbc040657a4847b2667e31d9e2c3d92ss[1]=====72297c88-4260-4c05-9b05-d28bfb11d10b,72297c8842604c059b05d28bfb11d10b3ss[2]=====6d513b6a-69bd-4f79-b94c-D65fc841ea95,6d513b6a69bd4f79b94cd65fc841ea954ss[3]=====d897a7d3-87a3-4e38-9e0b-71013a6dbe4c,d897a7d387a34e389e0b71013a6dbe4c5ss[4]=====5709f0ba-31e3-42bd-a28d-03485b257c94,5709f0ba31e342bda28d03485b257c946ss[5]=====530fbb8c-eec9-48d1-ae1b-5f792daf09f3,530fbb8ceec948d1ae1b5f792daf09f37ss[6]=====4bf07297-65b2-45ca-b905-6fc6f2f39158,4bf0729765b245cab9056fc6f2f391588ss[7]=====6e5a0e85-b4a0-485f-be54-a758115317e1,6e5a0e85b4a0485fbe54a758115317e19ss[8]=====245accec-3c12-4642-967f-E476CEF558C4,245ACCEC3C124642967FE476CEF558C4Tenss[9]=====ddd4b5a9-fecd-446c-bd78-63b70bb500a1,ddd4b5a9fecd446cbd7863b70bb500a1

As can be seen, the UUID refers to the number generated on a machine, which guarantees that all machines in the same time and space are unique. Typically, the platform provides the generated APIs. Based on standard calculations developed by the Open Software Foundation (OSF), Ethernet card addresses, nanosecond-seconds, chip ID codes, and many possible numbers are used

The UUID is composed of the following parts:

(1) The current date and time, the first part of the UUID is related to the time, if you generate a UUID after a few seconds to generate a UUID, then the first part is different, the rest is the same.

(2) Clock sequence

(3) Globally unique IEEE machine identification number, if there is a network card, from the network card MAC address obtained, no network card is obtained in other ways.

The only drawback to the UUID is that the resulting string will be longer. The most common use of UUID for this standard is the GUID of Microsoft (Globals Unique Identifiers). In ColdFusion, the UUID can be easily generated using the Createuuid () function in the form of: Xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx (8-4-4-16), where each x is 0-9 or a-f A hexadecimal number within the range. The standard UUID format is: xxxxxxxx-xxxx-xxxx-xxxxxx-xxxxxxxxxx (8-4-4-4-12), which can be converted from cflib download CreateGUID () UDF.

The benefits of using UUID are reflected in distributed software systems (e.g. DCE/RPC, Com+,corba), which ensures that the identities generated by each node are not duplicated, and that the benefits of the UUID will be more pronounced with the development of integrated technologies such as Web services. Depending on the specific mechanism used, the UUID must not only be guaranteed to be different from each other, or at least be very different from any other generic unique identifiers that were generated before the 3400 AD.

The universal unique identifier can also be used to point to most possible objects. Microsoft and some other software companies tend to use the globally unique identifier (GUID), which is a type of universal unique identifier that can be used to point to the Building object module object and other software components. The first universal unique identifier is a component created in the Snare computer system (NCS) and subsequently become a distributed computing environment (DCE) of the Open Software Foundation (OSF).

(RPM) Java generation UUID Universal Unique identifier (universally unique Identifier)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.