CN112243040A - Method and system for generating unique identifier - Google Patents

Method and system for generating unique identifier Download PDF

Info

Publication number
CN112243040A
CN112243040A CN202011471815.XA CN202011471815A CN112243040A CN 112243040 A CN112243040 A CN 112243040A CN 202011471815 A CN202011471815 A CN 202011471815A CN 112243040 A CN112243040 A CN 112243040A
Authority
CN
China
Prior art keywords
identification factor
buffer queue
identification
generation unit
taker
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202011471815.XA
Other languages
Chinese (zh)
Other versions
CN112243040B (en
Inventor
李伟豪
史伟
闵宇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Eflycloud Computing Co Ltd
Original Assignee
Guangdong Eflycloud Computing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Eflycloud Computing Co Ltd filed Critical Guangdong Eflycloud Computing Co Ltd
Priority to CN202011471815.XA priority Critical patent/CN112243040B/en
Publication of CN112243040A publication Critical patent/CN112243040A/en
Application granted granted Critical
Publication of CN112243040B publication Critical patent/CN112243040B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/146Markers for unambiguous identification of a particular session, e.g. session cookie or URL-encoding

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention discloses a method and a system for generating a unique identifier, wherein the method comprises the following steps: the method comprises the following steps that a number sender receives a registration identification factor request and parameter information of the number sender sent by the number sender, records the parameter information of the number sender and sends an identification factor to the number sender; the number taker receives the identification factor sent by the number sender, and a buffer unit of the number taker buffers the identification factor; the generating unit of the number taker acquires the identification factor from the buffer unit and generates a unique identifier according to the identification factor. The invention has reliable design principle and clear and definite structure, ensures high availability by adopting the double buffer queues, generates unique identification without time dependence, and has wide application prospect.

Description

Method and system for generating unique identifier
Technical Field
The present invention relates to the field of identifier technologies, and in particular, to a method and a system for generating a unique identifier.
Background
In distributed systems, it is often necessary to use globally unique identifiers to define corresponding different types of data, such as: unique identification of the order, unique identification of the message, unique identification of the data link. The unique identification can facilitate indexing, occupies relatively few positions and is convenient to store.
At present, there are various ways for acquiring a unique identifier in the prior art, and there are mainly the following schemes:
(1) the UUID is relatively simple in implementation mode, a string of unordered unique identifiers is generated on the basis of including the MAC address and the timestamp of the network card, no sequencing is performed, the trend increment cannot be guaranteed, the storage space is large, and the query efficiency is low;
(2) the MySQL database increment is that auto _ increment (digital self-increment attribute) of MySQL is adopted, at least two MySQL databases are needed to be suitable for a distributed system architecture, the identification of an odd number and an even number is generated by distinguishing the initial value and the step length of the auto _ increment, and the digital self-increment sequence mechanism of the databases is utilized to improve the reliability, but the defect is obvious, namely the whole system cannot be used when the databases are abnormal;
(3) the SnowFlake algorithm (SnowFlake) uses a 64-bit long type number as a global unique identifier; the application in the distributed system is very wide, wherein 1 bit of unsuitable bits represents positive and negative, 41 bits of the unsuitable bits are used as the number of milliseconds (the length can be used for 69 years), 10 bits are used as working machine identifiers (1024 nodes are deployed at most in branches), 12 bits are used as serial numbers (the serial numbers are counting sequence numbers, and 4096 identification serial numbers can be generated in every millisecond by supporting each node), and the method has the advantages that the serial numbers are stored in a database according to time order, the indexing efficiency is high, the database is not depended on during generation, the generation is completely carried out in a memory, and the high performance and the high availability are realized; the disadvantage is also evident that depending on the consistency with the system time, id conflicts or duplicates may result if the system time is recalled, or changed.
Disclosure of Invention
The invention aims to solve the technical problem of providing a method and a system for generating a unique identifier, the method and the system are reliable in design principle and clear and definite in structure, the adopted double-cache queue ensures high availability, the generated unique identifier is not dependent on time, and the method and the system have wide application prospect.
In order to solve the technical problems, the invention provides the following technical scheme: a method of generating a unique identifier, comprising the steps of:
step S1, the number sender receives the registration identification factor request and the parameter information of the number sender sent by the number sender, records the parameter information of the number sender and sends the identification factor to the number sender;
step S2, the number taker receives the identification factor sent by the number sender, and the buffer unit of the number taker buffers the identification factor;
step S3, the generating unit of the number taker acquires the identification factor from the buffer unit, and generates a unique identifier from the identification factor.
Further, the step S2 is specifically: the buffer unit detects whether the first buffer queue or the second buffer queue provides an identification factor to the generating unit of the number taker at the moment;
if the first buffer queue provides the identification factor for the generating unit of the number taker, detecting whether the identification factor acquired by the generating unit from the first buffer queue exceeds a certain threshold value; if the identification factor acquired by the generation unit from the first buffer queue exceeds a certain threshold, the buffer unit puts the identification factor in a second buffer queue for buffering, the first buffer queue continues to provide the identification factor for the generation unit of the number taker, and the second buffer queue is switched to provide the identification factor for the generation unit after all the identification factors of the first buffer queue are acquired by the generation unit; if the identification factor acquired by the generation unit from the first buffer queue does not exceed a certain threshold, the number taker stops acquiring the identification factor from the number sender, the generation unit continues to acquire the identification factor from the first buffer queue until the identification factor acquired from the first buffer queue exceeds the certain threshold, the number taker sends a supplementary identification factor request to the number sender, the number sender sends a supplementary identification factor to the number taker after acquiring the supplementary identification factor request, the buffer unit of the number taker puts the supplementary identification factor in the second buffer queue for buffering, the first buffer queue continues to provide the identification factor to the generation unit of the number taker, and the second buffer queue is switched to provide the identification factor to the generation unit until all the identification factors of the first buffer queue are acquired by the generation unit;
if the second buffer queue provides the identification factor for the generating unit of the number taker, detecting whether the identification factor acquired by the generating unit from the second buffer queue exceeds a certain threshold value; if the identification factor acquired by the generation unit from the second buffer queue exceeds a certain threshold, the buffer unit puts the identification factor in the first buffer queue for buffering, the second buffer queue continues to provide the identification factor for the generation unit of the number taker, and the first buffer queue is switched to provide the identification factor for the generation unit until all the identification factors of the second buffer queue are acquired by the generation unit; if the identification factor acquired by the generation unit from the second buffer queue does not exceed a certain threshold, the number taker stops acquiring the identification factor from the number sender, the generation unit continues to acquire the identification factor from the second buffer queue until the identification factor acquired from the second buffer queue exceeds the certain threshold, the number taker sends a supplementary identification factor request to the number sender, the number sender sends a supplementary identification factor to the number taker after acquiring the supplementary identification factor request, the buffer unit of the number taker puts the supplementary identification factor in the first buffer queue for buffering, the second buffer queue continues to provide the identification factor to the generation unit of the number taker, and the first buffer queue is switched to provide the identification factor to the generation unit until all the identification factors of the second buffer queue are acquired by the generation unit.
Further, the identification factor is a 12-bit binary identification factor.
Further, in step S3, a unique identifier is generated according to the identification factor, which specifically includes: the generated unique identifier is a 76-bit unique identifier which comprises 1-bit unavailable bit, a 41-bit time stamp, a 10-bit number of a number taker machine, a 12-bit identification factor and a 12-bit serial number;
wherein, the unavailable bit of 1 bit represents positive or negative, 0 is positive, 1 is negative; a 41-bit timestamp represents the current digital time; the machine number of the number taker with 10 bits represents the machine number of the number taker, the machine numbers of all the number takers are different, and the parameter information of the number taker comprises the machine number of the number taker; the 12-bit serial number represents the sequence number of the unique identifier, and 1 is added to the serial number when one unique identifier is generated.
Further, step S0 is included before step S1, the distributed system sends a request for obtaining the unique identifier to the number taker, and after receiving the request, the number taker sends a request for registering the identification factor to the number sender;
further, step S4 is included after step S3, in which the generating unit converts the 76-bit unique identifier into a decimal long unique identifier, and the number extractor sends the long unique identifier to the distributed system.
The invention also aims to provide a generating system of the unique identifier, which comprises a number sender device and a number taker device, wherein the number taker device comprises a buffer unit and a generating unit;
the number taker device is used for receiving a request for obtaining the unique identifier sent by the distributed system, and after receiving the request for obtaining the unique identifier, the number taker device sends a request for registering the identification factor to the number sender device;
the number sender device is used for receiving the registration identification factor request and the parameter information of the number sender device, recording the parameter information of the number sender device and sending the identification factor to the number sender device;
the number taking device is also used for receiving the identification factors sent by the number sender device;
the buffer unit is used for buffering the identification factors;
the generating unit is used for acquiring the identification factor from the buffer unit and generating a unique identifier according to the identification factor;
the number taker device is also for sending the unique identifier to the distributed system.
Further, the buffer unit comprises a first buffer queue module and a second buffer queue module;
the buffer unit is used for buffering the identification factor, and specifically comprises:
after the number taker device receives the identification factor sent by the number sender device, the buffer unit detects whether the first buffer queue module or the second buffer queue module provides the identification factor for the generation unit of the number taker device;
if the first buffer queue module provides the identification factor for the generation unit of the number taker device, detecting whether the identification factor acquired by the generation unit from the first buffer queue module exceeds a certain threshold value; if the identification factor acquired by the generation unit from the first buffer queue module exceeds a certain threshold value, the buffer unit puts the identification factor in the second buffer queue module for buffering, the first buffer queue module continues to provide the identification factor for the generation unit of the number taker device, and the second buffer queue module is switched to provide the identification factor for the generation unit until all the identification factors of the first buffer queue module are acquired by the generation unit; if the identification factor obtained by the generating unit from the first buffer queue module does not exceed a certain threshold, the number taker device stops obtaining the identification factor from the number sender device, the generating unit continues to obtain the identification factor from the first buffer queue module until the identification factor obtained from the first buffer queue module exceeds the certain threshold, the number taker device sends a supplementary identification factor request to the number sender device, and after the number sender device obtains the supplementary identification factor request, sending the supplemented identification factors to a number taker device, wherein a buffer unit of the number taker device puts the supplemented identification factors in a second buffer queue module for buffering, a first buffer queue module continues to provide the identification factors to a generation unit of the number taker device, and the second buffer queue module is switched to provide the identification factors to the generation unit after all the identification factors of the first buffer queue module are obtained by the generation unit;
if the second buffer queue module provides the identification factor for the generation unit of the number taker device, detecting whether the identification factor acquired by the generation unit from the second buffer queue module exceeds a certain threshold value; if the identification factor acquired by the generation unit from the second buffer queue module exceeds a certain threshold value, the buffer unit puts the identification factor in the first buffer queue module for buffering, the second buffer queue module continues to provide the identification factor for the generation unit of the number taker device, and the first buffer queue module is switched to provide the identification factor for the generation unit until all the identification factors of the second buffer queue module are acquired by the generation unit; if the identification factor obtained by the generating unit from the second buffer queue module does not exceed a certain threshold, the number taker device stops obtaining the identification factor from the number sender device, the generating unit continues to obtain the identification factor from the second buffer queue module until the identification factor obtained from the second buffer queue module exceeds the certain threshold, the number taker device sends a supplementary identification factor request to the number sender device, and after the number sender device obtains the supplementary identification factor request, and sending the supplemented identification factors to the number taker device, wherein a buffer unit of the number taker device puts the supplemented identification factors in a first buffer queue module for buffering, a second buffer queue module continues to provide the identification factors to a generation unit of the number taker device, and the first buffer queue module is switched to provide the identification factors to the generation unit until all the identification factors of the second buffer queue module are obtained by the generation unit.
After the technical scheme is adopted, the invention at least has the following beneficial effects:
1. the combined scheme of the number sender and the number taker improves the structural coupling degree and ensures the reliability of the whole process of generating the unique identifier.
2. The invention adopts double buffer queues, and can ensure that the distributed unique identifier has the characteristic of high availability.
3. The unique identifier of the 76bit generated by the invention does not depend on time, and even if the time is backtracked, the identifier is not repeated; and the number of the distribution machines is large, and the number of the generated marks per second is large.
Drawings
Fig. 1 is a flowchart of steps of a method for generating a unique identifier according to embodiment 1 of the present invention.
Fig. 2 is an example of the unique identifier in embodiment 1 of the present invention.
Fig. 3 is a system framework diagram of generating a unique identifier according to embodiment 2 of the present invention.
Detailed Description
It should be noted that, in the present application, the embodiments and features of the embodiments may be combined with each other without conflict, and the present application is further described in detail with reference to the drawings and specific embodiments.
The invention provides a method for generating a 76-bit long type number and an ordered unique identifier finally through a combination mode of a number sender and a number taker, so as to solve the technical problem.
In the first aspect, the number sender is a module service, and after the number sender receives the registration request of the number taker, the number sender pre-calculates the preset number of identification factors, sends the specified number of identification factors to the number taker, and then provides a request for supplementing the identification factors for the number taker.
In the second aspect, the number taker uses a double-circulation buffer queue to allocate buffer space to store a specified number of identification factors; monitoring the current locking queue state, and when the number of the identification factors distributed to the queue exceeds a preset threshold value, requesting the number sender to acquire the specified number of the identification factors by the prepared queue and supplementing the identification factors to the prepared queue; when all the identification factors of the locking queue are distributed, the buffer queue is immediately switched, the prepared queue is converted into the locking queue, the identification factors are continuously distributed, and the like; and then acquiring a corresponding identification factor from the locking queue, and generating a 76-bit long type number ordered unique identification through a generation rule.
Example 1
As shown in fig. 1, the present embodiment discloses a method for generating a unique identifier, which includes the following steps:
step S0, the distributed system sends a request for obtaining the unique identifier to the number taker, and the number taker sends a request for registering the identification factor to the number sender after receiving the request;
the embodiment preferably provides the unique identifier to the distributed system, but is not limited to providing the unique identifier only to the distributed system, and other unique identifiers required by the distributed system can be provided by the embodiment;
step S1, the number sender receives the registration identification factor request and the parameter information of the number sender sent by the number sender, records the parameter information of the number sender and sends the identification factor to the number sender; the parameter information includes a machine number, which is used for managing and participating in generating a unique identifier (specifically disclosed in the following content), and the machine number of each number taker is different;
the identification factor is a 12-bit binary identification factor; the identification factor is composed of N numbers, each number of the identification factor is a random number and all the numbers can not be reused, and the identification factor composed of N numbers is converted into an identification factor composed of 12-bit binary; preferably, the identification factor composed of N numbers is one of the values selected from 1-10000, and the value is the identification factor, but each digit of each value is not repeatable, such as the value 1234 is the available identification factor and the value 1224 is the unavailable identification factor;
step S2, the number taker receives the identification factor sent by the number sender, and the buffer unit of the number taker buffers the identification factor, specifically:
if the first buffer queue provides the identification factor for the generating unit of the number taker, detecting whether the identification factor acquired by the generating unit from the first buffer queue exceeds a certain threshold value; if the identification factor acquired by the generation unit from the first buffer queue exceeds a certain threshold, the buffer unit puts the identification factor in a second buffer queue for buffering, the first buffer queue continues to provide the identification factor for the generation unit of the number taker, and the second buffer queue is switched to provide the identification factor for the generation unit after all the identification factors of the first buffer queue are acquired by the generation unit; if the identification factor acquired by the generation unit from the first buffer queue does not exceed a certain threshold, the number taker stops acquiring the identification factor from the number sender, the generation unit continues to acquire the identification factor from the first buffer queue until the identification factor acquired from the first buffer queue exceeds the certain threshold, the number taker sends a supplementary identification factor request to the number sender, the number sender sends a supplementary identification factor to the number taker after acquiring the supplementary identification factor request, the buffer unit of the number taker puts the supplementary identification factor in the second buffer queue for buffering, the first buffer queue continues to provide the identification factor to the generation unit of the number taker, and the second buffer queue is switched to provide the identification factor to the generation unit until all the identification factors of the first buffer queue are acquired by the generation unit;
if the second buffer queue provides the identification factor for the generating unit of the number taker, detecting whether the identification factor acquired by the generating unit from the second buffer queue exceeds a certain threshold value; if the identification factor acquired by the generation unit from the second buffer queue exceeds a certain threshold, the buffer unit puts the identification factor in the first buffer queue for buffering, the second buffer queue continues to provide the identification factor for the generation unit of the number taker, and the first buffer queue is switched to provide the identification factor for the generation unit until all the identification factors of the second buffer queue are acquired by the generation unit; if the identification factor acquired by the generation unit from the second buffer queue does not exceed a certain threshold, the number taker stops acquiring the identification factor from the number sender, the generation unit continues to acquire the identification factor from the second buffer queue until the identification factor acquired from the second buffer queue exceeds the certain threshold, the number taker sends a supplementary identification factor request to the number sender, the number sender sends a supplementary identification factor to the number taker after acquiring the supplementary identification factor request, the buffer unit of the number taker buffers the supplementary identification factor in the first buffer queue, the second buffer queue continues to provide the identification factor to the generation unit of the number taker, and the first buffer queue is switched to provide the identification factor to the generation unit until all the identification factors of the second buffer queue are acquired by the generation unit;
therefore, the first buffer queue and the second buffer queue are double-circulation buffer queues, and the characteristic that the allocated unique identifier has high availability can be ensured;
step S3, the generating unit of the number taker acquires the identification factor from the buffer unit, and generates a unique identifier according to the identification factor, which specifically includes: the generated unique identifier is a 76-bit unique identifier which comprises 1-bit unavailable bit, a 41-bit time stamp, a 10-bit number of a number taker machine, a 12-bit identification factor and a 12-bit serial number;
wherein, the unavailable bit of 1 bit represents positive and negative, 0 is positive, 1 is negative, and we use 0 to meet the requirement; a 41-bit timestamp represents the current digital time, which can be up to 69 years; the machine number of the number taker with 10 bits represents the machine number of the number taker, the machine numbers of each number taker are different, the parameter information of the number taker comprises the machine number of the number taker, when the number taker is deployed, the number of the number taker needs to be named, and the number taker with 1024 number takers is supported at most; a 12-bit identification factor, wherein a sender randomly generates a unique factor and supports 4096 identification factors at most; the 12-bit serial number represents the sequence number of the unique identifier, and the serial number is correspondingly added with 1 every time a unique identifier is generated, so that 4096 sequence numbers are supported at most simultaneously;
as shown in fig. 2, for the example of the unique identifier, let us assume that the timestamp is 1592987792, the number of the sender is 10, the identification factor is 846, and the current serial number is 2, then the last unique identifier is:
0 (unavailable position)
00000000001011110111100110001000010010000 (time stamp)
0000001010 (number taker machine)
001101001110 (identification factor)
000000000010 (Serial number)
The last binary identification is converted to a decimal identification of 27367321878440239106;
and step S4, the generating unit converts the unique identifier with 76 bits into a decimal long type unique identifier, and the number taker sends the long type unique identifier to the distributed system.
The implementation has the advantages that through the combination scheme of the number sender and the number taker, the structural coupling degree is improved, and the reliability is guaranteed; through the double buffer queues, the distributed unique identifier can be ensured to have the characteristic of high availability; through the generated unique identifier of 76 bits, the identifier is not repeated even if time backtracks are carried out, and time is not depended on; and the number of the distribution machines is large, and the number of the generated marks per second is large.
Example 2
The implementation discloses a generating system of a unique identifier on the basis of an embodiment generating method, and the generating system comprises a number sender device and a number taker device, wherein the number taker device comprises a buffer unit and a generating unit;
the number taker device is used for receiving a request for obtaining the unique identifier sent by the distributed system, and after receiving the request for obtaining the unique identifier, the number taker device sends a request for registering the identification factor to the number sender device;
the number sender device is used for receiving the registration identification factor request and the parameter information of the number sender device, recording the parameter information of the number sender device and sending the identification factor to the number sender device;
the number taking device is also used for receiving the identification factors sent by the number sender device;
the buffer unit is used for buffering the identification factors;
the generating unit is used for acquiring the identification factor from the buffer unit and generating a unique identifier according to the identification factor;
the number taker device is also for sending the unique identifier to the distributed system.
Further, the buffer unit comprises a first buffer queue module and a second buffer queue module;
the buffer unit is used for buffering the identification factor, and specifically comprises:
after the number taker device receives the identification factor sent by the number sender device, the buffer unit detects whether the first buffer queue module or the second buffer queue module provides the identification factor for the generation unit of the number taker device;
if the first buffer queue module provides the identification factor for the generation unit of the number taker device, detecting whether the identification factor acquired by the generation unit from the first buffer queue module exceeds a certain threshold value; if the identification factor acquired by the generation unit from the first buffer queue module exceeds a certain threshold value, the buffer unit puts the identification factor in the second buffer queue module for buffering, the first buffer queue module continues to provide the identification factor for the generation unit of the number taker device, and the second buffer queue module is switched to provide the identification factor for the generation unit until all the identification factors of the first buffer queue module are acquired by the generation unit; if the identification factor obtained by the generating unit from the first buffer queue module does not exceed a certain threshold, the number taker device stops obtaining the identification factor from the number sender device, the generating unit continues to obtain the identification factor from the first buffer queue module until the identification factor obtained from the first buffer queue module exceeds the certain threshold, the number taker device sends a supplementary identification factor request to the number sender device, and after the number sender device obtains the supplementary identification factor request, sending the supplemented identification factors to a number taker device, wherein a buffer unit of the number taker device puts the supplemented identification factors in a second buffer queue module for buffering, a first buffer queue module continues to provide the identification factors to a generation unit of the number taker device, and the second buffer queue module is switched to provide the identification factors to the generation unit after all the identification factors of the first buffer queue module are obtained by the generation unit;
if the second buffer queue module provides the identification factor for the generation unit of the number taker device, detecting whether the identification factor acquired by the generation unit from the second buffer queue module exceeds a certain threshold value; if the identification factor acquired by the generation unit from the second buffer queue module exceeds a certain threshold value, the buffer unit puts the identification factor in the first buffer queue module for buffering, the second buffer queue module continues to provide the identification factor for the generation unit of the number taker device, and the first buffer queue module is switched to provide the identification factor for the generation unit until all the identification factors of the second buffer queue module are acquired by the generation unit; if the identification factor obtained by the generating unit from the second buffer queue module does not exceed a certain threshold, the number taker device stops obtaining the identification factor from the number sender device, the generating unit continues to obtain the identification factor from the second buffer queue module until the identification factor obtained from the second buffer queue module exceeds the certain threshold, the number taker device sends a supplementary identification factor request to the number sender device, and after the number sender device obtains the supplementary identification factor request, and sending the supplemented identification factors to the number taker device, wherein a buffer unit of the number taker device puts the supplemented identification factors in a first buffer queue module for buffering, a second buffer queue module continues to provide the identification factors to a generation unit of the number taker device, and the first buffer queue module is switched to provide the identification factors to the generation unit until all the identification factors of the second buffer queue module are obtained by the generation unit.
Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various equivalent changes, modifications, substitutions and alterations can be made herein without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims (8)

1. A method for generating a unique identifier, comprising the steps of:
step S1, the number sender receives the registration identification factor request and the parameter information of the number sender sent by the number sender, records the parameter information of the number sender and sends the identification factor to the number sender;
step S2, the number taker receives the identification factor sent by the number sender, and the buffer unit of the number taker buffers the identification factor;
step S3, the generating unit of the number taker acquires the identification factor from the buffer unit, and generates a unique identifier from the identification factor.
2. The method for generating a unique identifier according to claim 1, wherein the step S2 specifically includes: the buffer unit detects whether the first buffer queue or the second buffer queue provides an identification factor to the generating unit of the number taker at the moment; the buffer unit comprises a first buffer queue and a second buffer queue;
if the first buffer queue provides the identification factor for the generating unit of the number taker, detecting whether the identification factor acquired by the generating unit from the first buffer queue exceeds a certain threshold value; if the identification factor acquired by the generation unit from the first buffer queue exceeds a certain threshold, the buffer unit puts the identification factor in a second buffer queue for buffering, the first buffer queue continues to provide the identification factor for the generation unit of the number taker, and the second buffer queue is switched to provide the identification factor for the generation unit after all the identification factors of the first buffer queue are acquired by the generation unit; if the identification factor acquired by the generation unit from the first buffer queue does not exceed a certain threshold, the number taker stops acquiring the identification factor from the number sender, the generation unit continues to acquire the identification factor from the first buffer queue until the identification factor acquired from the first buffer queue exceeds the certain threshold, the number taker sends a supplementary identification factor request to the number sender, the number sender sends a supplementary identification factor to the number taker after acquiring the supplementary identification factor request, the buffer unit of the number taker puts the supplementary identification factor in the second buffer queue for buffering, the first buffer queue continues to provide the identification factor to the generation unit of the number taker, and the second buffer queue is switched to provide the identification factor to the generation unit until all the identification factors of the first buffer queue are acquired by the generation unit;
if the second buffer queue provides the identification factor for the generating unit of the number taker, detecting whether the identification factor acquired by the generating unit from the second buffer queue exceeds a certain threshold value; if the identification factor acquired by the generation unit from the second buffer queue exceeds a certain threshold, the buffer unit puts the identification factor in the first buffer queue for buffering, the second buffer queue continues to provide the identification factor for the generation unit of the number taker, and the first buffer queue is switched to provide the identification factor for the generation unit until all the identification factors of the second buffer queue are acquired by the generation unit; if the identification factor acquired by the generation unit from the second buffer queue does not exceed a certain threshold, the number taker stops acquiring the identification factor from the number sender, the generation unit continues to acquire the identification factor from the second buffer queue until the identification factor acquired from the second buffer queue exceeds the certain threshold, the number taker sends a supplementary identification factor request to the number sender, the number sender sends a supplementary identification factor to the number taker after acquiring the supplementary identification factor request, the buffer unit of the number taker puts the supplementary identification factor in the first buffer queue for buffering, the second buffer queue continues to provide the identification factor to the generation unit of the number taker, and the first buffer queue is switched to provide the identification factor to the generation unit until all the identification factors of the second buffer queue are acquired by the generation unit.
3. The method of claim 2, wherein the identification factor is a 12-bit binary identification factor.
4. The method for generating a unique identifier according to claim 3, wherein the step S3 generates the unique identifier according to the identification factor, which specifically includes: the generated unique identifier is a 76-bit unique identifier which comprises 1-bit unavailable bit, a 41-bit time stamp, a 10-bit number of a number taker machine, a 12-bit identification factor and a 12-bit serial number;
wherein, the unavailable bit of 1 bit represents positive or negative, 0 is positive, 1 is negative; a 41-bit timestamp represents the current digital time; the machine number of the number taker with 10 bits represents the machine number of the number taker, the machine numbers of all the number takers are different, and the parameter information of the number taker comprises the machine number of the number taker; the 12-bit serial number represents the sequence number of the unique identifier, and 1 is added to the serial number when one unique identifier is generated.
5. The method of claim 4, wherein the step S1 is preceded by the step S0 of sending a request for obtaining the unique identifier to the number taker, and the number taker sends a request for registration of the identification factor to the number sender after receiving the request.
6. The method as claimed in claim 5, wherein the step S3 is followed by a step S4 in which the generating unit converts the 76-bit unique identifier into a decimal long unique identifier, and the number extractor sends the long unique identifier to the distribution system.
7. A generation system of a unique identifier is characterized by comprising a number sender device and a number taker device, wherein the number taker device comprises a buffer unit and a generation unit;
the number taker device is used for receiving a request for obtaining the unique identifier sent by the distributed system, and after receiving the request for obtaining the unique identifier, the number taker device sends a request for registering the identification factor to the number sender device;
the number sender device is used for receiving the registration identification factor request and the parameter information of the number sender device, recording the parameter information of the number sender device and sending the identification factor to the number sender device;
the number taking device is also used for receiving the identification factors sent by the number sender device;
the buffer unit is used for buffering the identification factors;
the generating unit is used for acquiring the identification factor from the buffer unit and generating a unique identifier according to the identification factor;
the number taker device is also for sending the unique identifier to the distributed system.
8. The system for generating a unique identifier according to claim 7, wherein said buffer unit comprises a first buffer queue module and a second buffer queue module;
the buffer unit is used for buffering the identification factor, and specifically comprises:
after the number taker device receives the identification factor sent by the number sender device, the buffer unit detects whether the first buffer queue module or the second buffer queue module provides the identification factor for the generation unit of the number taker device;
if the first buffer queue module provides the identification factor for the generation unit of the number taker device, detecting whether the identification factor acquired by the generation unit from the first buffer queue module exceeds a certain threshold value; if the identification factor acquired by the generation unit from the first buffer queue module exceeds a certain threshold value, the buffer unit puts the identification factor in the second buffer queue module for buffering, the first buffer queue module continues to provide the identification factor for the generation unit of the number taker device, and the second buffer queue module is switched to provide the identification factor for the generation unit until all the identification factors of the first buffer queue module are acquired by the generation unit; if the identification factor obtained by the generating unit from the first buffer queue module does not exceed a certain threshold, the number taker device stops obtaining the identification factor from the number sender device, the generating unit continues to obtain the identification factor from the first buffer queue module until the identification factor obtained from the first buffer queue module exceeds the certain threshold, the number taker device sends a supplementary identification factor request to the number sender device, and after the number sender device obtains the supplementary identification factor request, sending the supplemented identification factors to a number taker device, wherein a buffer unit of the number taker device puts the supplemented identification factors in a second buffer queue module for buffering, a first buffer queue module continues to provide the identification factors to a generation unit of the number taker device, and the second buffer queue module is switched to provide the identification factors to the generation unit after all the identification factors of the first buffer queue module are obtained by the generation unit;
if the second buffer queue module provides the identification factor for the generation unit of the number taker device, detecting whether the identification factor acquired by the generation unit from the second buffer queue module exceeds a certain threshold value; if the identification factor acquired by the generation unit from the second buffer queue module exceeds a certain threshold value, the buffer unit puts the identification factor in the first buffer queue module for buffering, the second buffer queue module continues to provide the identification factor for the generation unit of the number taker device, and the first buffer queue module is switched to provide the identification factor for the generation unit until all the identification factors of the second buffer queue module are acquired by the generation unit; if the identification factor obtained by the generating unit from the second buffer queue module does not exceed a certain threshold, the number taker device stops obtaining the identification factor from the number sender device, the generating unit continues to obtain the identification factor from the second buffer queue module until the identification factor obtained from the second buffer queue module exceeds the certain threshold, the number taker device sends a supplementary identification factor request to the number sender device, and after the number sender device obtains the supplementary identification factor request, and sending the supplemented identification factors to the number taker device, wherein a buffer unit of the number taker device puts the supplemented identification factors in a first buffer queue module for buffering, a second buffer queue module continues to provide the identification factors to a generation unit of the number taker device, and the first buffer queue module is switched to provide the identification factors to the generation unit until all the identification factors of the second buffer queue module are obtained by the generation unit.
CN202011471815.XA 2020-12-15 2020-12-15 Method and system for generating unique identifier Active CN112243040B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011471815.XA CN112243040B (en) 2020-12-15 2020-12-15 Method and system for generating unique identifier

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011471815.XA CN112243040B (en) 2020-12-15 2020-12-15 Method and system for generating unique identifier

Publications (2)

Publication Number Publication Date
CN112243040A true CN112243040A (en) 2021-01-19
CN112243040B CN112243040B (en) 2021-03-30

Family

ID=74175217

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011471815.XA Active CN112243040B (en) 2020-12-15 2020-12-15 Method and system for generating unique identifier

Country Status (1)

Country Link
CN (1) CN112243040B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115145955A (en) * 2022-09-05 2022-10-04 泰豪软件股份有限公司 Serial number generation method and system

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101334908A (en) * 2007-06-29 2008-12-31 刘少龙 Bank queuing management method and system with multimedia playing function
CN101478483A (en) * 2009-01-08 2009-07-08 中国人民解放军信息工程大学 Method for implementing packet scheduling in switch equipment and switch equipment
US20120150996A1 (en) * 2010-12-09 2012-06-14 Dubois Charles L System and method for providing caching and pre-fetch of assets/media
CN102521269A (en) * 2011-11-22 2012-06-27 清华大学 Index-based computer continuous data protection method
CN105704207A (en) * 2015-12-18 2016-06-22 百势软件(北京)有限公司 Method for generating unique identifier, terminal and network side
CN108647193A (en) * 2018-04-20 2018-10-12 河南中烟工业有限责任公司 A kind of unique identifier generation method can be applied to distributed system and device
CN109740120A (en) * 2018-12-14 2019-05-10 深圳壹账通智能科技有限公司 The generation method of unique identification, device, computer equipment under distributed environment
CN112073554A (en) * 2020-09-08 2020-12-11 腾讯科技(深圳)有限公司 Global unique identifier generation method, device and computer readable storage medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101334908A (en) * 2007-06-29 2008-12-31 刘少龙 Bank queuing management method and system with multimedia playing function
CN101478483A (en) * 2009-01-08 2009-07-08 中国人民解放军信息工程大学 Method for implementing packet scheduling in switch equipment and switch equipment
US20120150996A1 (en) * 2010-12-09 2012-06-14 Dubois Charles L System and method for providing caching and pre-fetch of assets/media
CN102521269A (en) * 2011-11-22 2012-06-27 清华大学 Index-based computer continuous data protection method
CN105704207A (en) * 2015-12-18 2016-06-22 百势软件(北京)有限公司 Method for generating unique identifier, terminal and network side
CN108647193A (en) * 2018-04-20 2018-10-12 河南中烟工业有限责任公司 A kind of unique identifier generation method can be applied to distributed system and device
CN109740120A (en) * 2018-12-14 2019-05-10 深圳壹账通智能科技有限公司 The generation method of unique identification, device, computer equipment under distributed environment
CN112073554A (en) * 2020-09-08 2020-12-11 腾讯科技(深圳)有限公司 Global unique identifier generation method, device and computer readable storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115145955A (en) * 2022-09-05 2022-10-04 泰豪软件股份有限公司 Serial number generation method and system

Also Published As

Publication number Publication date
CN112243040B (en) 2021-03-30

Similar Documents

Publication Publication Date Title
CN110619114B (en) Serial number generation method and system
CN108259328B (en) Message forwarding method and device
CN111026767B (en) Block chain data storage method and device and hardware equipment
CN112559558B (en) Method and device for generating serial numbers, computing equipment and storage medium
CN112243040B (en) Method and system for generating unique identifier
CN112272243B (en) Address allocation method
US11640261B2 (en) Log processing method to avoid log collision, and related device and system
CN112115133A (en) Distributed global unique ID generation method and system, storage medium and device
CN113076303A (en) Method and device for generating service identifier in distributed system
US8244670B2 (en) System and method for reliable symmetric data synchronization
CN114172792B (en) Method and device for realizing sequence number generation method for ensuring high availability of service
CN113179327A (en) High-concurrency protocol stack unloading method, equipment and medium based on high-capacity memory
CN113934547B (en) Method, device, equipment and product for recording alarm log in cluster environment
CN108509296B (en) Method and system for processing equipment fault
CN103905512A (en) Data processing method and equipment
US11309974B2 (en) Quantum channel routing utilizing a quantum channel measurement service
CN112463790A (en) Method and system for rapidly generating ID (identity) under micro-service architecture
CN110855627B (en) Application deployment method, device, equipment and medium
CN111092956A (en) Resource synchronization method, device, storage medium and equipment
CN111741038A (en) Data transmission method and data transmission device
CN113949658B (en) Table entry processing method, system, device, electronic equipment and storage medium
CN109768976B (en) Method and device for transmitting and receiving OAM information for flexible Ethernet
CN112615944B (en) Method and system for master-slave synchronization of distributed DNS (Domain name System)
CN110750534A (en) Method and apparatus for deploying Redis clusters
US20230315759A1 (en) A method of operating a storage device of an access point, a method of locating a device context of an end node device stored in a storage device of an access point, and an access point

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant