A distributed number issuing method, device and electronic device based on atomic operation
Through the distributed number issuance method based on atomic operations, user-defined sequence rules and sharding principles are used to generate globally unique IDs, which solves the need for globally unique IDs in databases and tables when the amount of data is large, and achieves efficient ID management and reduced storage. Space effect.
Patent Information
- Application Number
- CN202110439886.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-23
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2041-04-23
AI Technical Summary
Existing globally unique serial number generation technology cannot meet the global unique ID requirements for database and table sharding when the amount of data is large.
Adopting a distributed numbering method based on atomic operations, it generates a starting globally unique ID sequence by obtaining user-defined sequence rules, and stores and auto-increments the ID sequence in the buffer queue. It supports custom formats and fragmentation principles to generate IDs to meet the needs of Unique ID requirements for distributed systems.
Effectively generates and manages globally unique IDs in distributed systems, reduces ID storage space, supports custom formats and sharding principles, and meets unique ID requirements for large amounts of data.
Smart Images

Figure CN113312349B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer network technology, and in particular to a distributed numbering method, device, electronic device and computer-readable medium based on atomic operations. Background Art
[0002] When using a database, the primary key of a table is often generated using the database's auto_increment function. For example, the auto-increment primary key in MySQL and the ObjectId in MongoDB are all ways for the database to generate a globally unique serial number ID to represent a unique record. However, when the amount of data grows, it is necessary to shard the data into different databases and tables. Since the globally unique serial number IDs between different databases may be the same, the auto-increment IDs that come with the database after sharding cannot meet the ID uniqueness requirement. This requires a generator that can generate globally unique serial number IDs in a distributed environment. Summary of the invention
[0003] The present invention aims to solve the technical problem that the existing globally unique serial number generation technology cannot meet the global uniqueness requirement of database and table division when the data volume is large.
[0004] In order to solve the above technical problems, the first aspect of the present invention proposes a distributed number distribution method based on atomic operations, the method comprising:
[0005] Get the user-defined sequence rules used in this number issuance;
[0006] When receiving a starting numbering request from a node, generating a starting globally unique ID sequence using the custom serial number rule, and storing the starting globally unique ID sequence in a buffer queue;
[0007] According to the order of the node number request, the current globally unique ID sequence value is incremented by 1 by atomic operation to generate a new globally unique ID sequence, and the new globally unique ID sequence is stored in the buffer queue;
[0008] When a number issuance and consumption request from a node is received, the globally unique ID sequence is read sequentially from the cache queue.
[0009] According to a preferred embodiment of the present invention, when the buffer queue reaches the storage threshold, the buffer queue is cleared, and the current globally unique ID sequence value is incremented by 1 through atomic operations according to the order of node number issuance requests to generate a new globally unique ID sequence, and the new globally unique ID sequence is stored in the buffer queue.
[0010] According to a preferred embodiment of the present invention, the method of obtaining the user-defined sequence rule used in the current number issuance includes:
[0011] Receive keywords input by users;
[0012] Matching a user-defined sequence library according to the keyword, and displaying at least one matched user-defined sequence rule;
[0013] The user-defined sequence rule used for the current number issuance is determined according to the user's selection operation of the at least one user-defined sequence rule.
[0014] According to a preferred embodiment of the present invention, the value range of the globally unique ID sequence is generated using a fragmentation principle.
[0015] According to a preferred embodiment of the present invention, the method further comprises:
[0016] Store the globally unique ID sequence read from the cache queue into the database.
[0017] According to a preferred embodiment of the present invention, the structure of the custom serial number rule includes a serial number name, a start index, a sequence minimum value, a sequence maximum value, an incrementing step, a previous index, a current index and a serial number format.
[0018] In order to solve the above technical problems, the second aspect of the present invention provides a distributed number issuing device based on atomic operations, the device comprising:
[0019] The acquisition module is used to obtain the user-defined sequence rules used in this number issuance;
[0020] A first generating module is used for, when receiving a starting number issuing request from a node, generating a starting globally unique ID sequence using the custom serial number rule, and storing the starting globally unique ID sequence in a buffer queue;
[0021] A second generation module is used to generate a new globally unique ID sequence by increasing the current globally unique ID sequence value by 1 through an atomic operation according to the order of the node number issuance request, and store the new globally unique ID sequence in a buffer queue;
[0022] The reading module is used to read the globally unique ID sequence from the cache queue in sequence when receiving a number issuance and consumption request from a node.
[0023] According to a preferred embodiment of the present invention, the second generation module is also used to clear the buffer queue when the buffer queue reaches the storage threshold, and to increase the current globally unique ID sequence value by 1 through atomic operations according to the order of node number issuance requests to generate a new globally unique ID sequence, and to store the new globally unique ID sequence in the buffer queue.
[0024] According to a preferred embodiment of the present invention, the acquisition module includes:
[0025] A receiving module, used for receiving keywords input by a user;
[0026] A matching module, used for matching the user-defined sequence library according to the keyword, and displaying at least one matched user-defined sequence rule;
[0027] The determination module is used to determine the user-defined sequence rule used for the current number issuance according to the user's selection operation of the at least one user-defined sequence rule.
[0028] According to a preferred embodiment of the present invention, the value range of the globally unique ID sequence is generated using a fragmentation principle.
[0029] According to a preferred embodiment of the present invention, the device further comprises:
[0030] The storage module is used to store the globally unique ID sequence read from the cache queue into the database.
[0031] According to a preferred embodiment of the present invention, the structure of the custom serial number rule includes a serial number name, a start index, a sequence minimum value, a sequence maximum value, an incrementing step, a previous index, a current index and a serial number format.
[0032] In order to solve the above technical problems, the third aspect of the present invention provides an electronic device, including:
[0033] Processor; and
[0034] A memory storing computer executable instructions, which when executed cause the processor to perform the above method.
[0035] To solve the above technical problem, the fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores one or more programs, and when the one or more programs are executed by a processor, the above method is implemented.
[0036] The present invention generates a globally unique ID component in a distributed system through an embedded mode. Each ID component can use a user-defined sequence rule to generate a starting globally unique ID sequence, and the current globally unique ID sequence value is incremented by 1 through atomic operations to achieve the purpose of the self-incrementing sequence. In addition, the present invention uses a production / consumption mode to store the globally unique ID sequence pre-generated by each ID component in a buffer queue, and directly obtains the ID sequence from the memory when calling, which can effectively reduce the storage space of the serial number. The present invention completes the issuance of a globally unique serial number in a distributed system through an embedded ID component. At the same time, the present invention supports business serial number scenarios in custom formats and can effectively reduce the storage space of the serial number. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to make the technical problems solved by the present invention, the technical means adopted and the technical effects achieved more clearly, the specific embodiments of the present invention will be described in detail with reference to the accompanying drawings. However, it should be noted that the drawings described below are only drawings of exemplary embodiments of the present invention, and those skilled in the art can obtain drawings of other embodiments based on these drawings without creative work.
[0038] Figure 1 It is a flow chart of a distributed number issuing method based on atomic operation of the present invention;
[0039] Figure 2 It is a schematic diagram of the distributed number distribution based on atomic operation implemented by the present invention;
[0040] Figure 3 It is a schematic diagram of the structural framework of a distributed number issuing device of the present invention;
[0041] Figure 4 is a structural block diagram of an exemplary embodiment of an electronic device according to the present invention;
[0042] Figure 5 is a schematic diagram of an embodiment of a computer readable medium of the present invention. DETAILED DESCRIPTION
[0043] The exemplary embodiments of the present invention will now be described more fully with reference to the accompanying drawings. Although each exemplary embodiment can be implemented in a variety of specific ways, it should not be understood that the present invention is limited to the embodiments set forth herein. On the contrary, these exemplary embodiments are provided to make the content of the present invention more complete and to facilitate the comprehensive communication of the inventive concept to those skilled in the art.
[0044] Under the premise of conforming to the technical concept of the present invention, the structure, performance, effect or other characteristics described in a specific embodiment may be combined with one or more other embodiments in any appropriate manner.
[0045] In the process of introducing specific embodiments, the detailed description of the structure, performance, effect or other characteristics is to enable those skilled in the art to fully understand the embodiments. However, it does not exclude that those skilled in the art can implement the present invention with a technical solution that does not contain the above-mentioned structure, performance, effect or other characteristics under certain circumstances.
[0046] The flowchart in the accompanying drawings is only an exemplary process demonstration, and does not mean that the solution of the present invention must include all the contents, operations and steps in the flowchart, nor does it mean that it must be executed in the order shown in the figure. For example, some operations / steps in the flowchart can be decomposed, some operations / steps can be combined or partially combined, etc. The execution order shown in the flowchart can be changed according to the actual situation without departing from the main purpose of the present invention.
[0047] Frames in the attached figure Figure 1 Generally, it refers to functional entities, which do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0048] The same reference numerals in the drawings represent the same or similar elements, components or parts, and thus the repeated description of the same or similar elements, components or parts may be omitted below. It should also be understood that although the first, second, third and other attributives representing the numbers may be used herein to describe various devices, elements, components or parts, these devices, elements, components or parts should not be limited by these attributives. In other words, these attributives are only used to distinguish one from another. For example, the first device may also be called the second device, but it does not deviate from the essential technical solution of the present invention. In addition, the terms "and / or" and "and / or" refer to all combinations including any one or more of the listed items.
[0049] See also Figure 1 , Figure 1 This is a flow chart of a distributed number issuance method based on atomic operations provided by the present invention. The method generates ID components in an embedded mode, and completes the serial number issuance of different services through the ID components. The ID components can be integrated into each node of the distributed system in the form of plug-ins, which has the advantages of plug-and-play and zero-cost access. Figure 1 As shown, the method includes:
[0050] S1. Obtain the user-defined sequence rule used for this number issuance;
[0051] The present invention supports scenarios of business serial numbers in user-defined formats. Users can set different business serial number formats for different businesses. In this way, the business serial number formats can be used to distinguish different business types. In one example, user-defined sequence rules can be managed through a front-end web page, such as a web project using spring boot + thymeleaf, and the user-defined sequence rules for this issuance can be obtained according to the user's choice. Therefore, the method of obtaining the user-defined sequence rules used for this issuance includes:
[0052] S11, receiving keywords input by a user;
[0053] The keyword may be any one of a serial number name, a start index, and a current index.
[0054] S12, matching the user-defined sequence library according to the keyword, and displaying at least one matched user-defined sequence rule;
[0055] In the present invention, fuzzy matching or exact matching can be adopted.
[0056] S13: Determine the user-defined sequence rule used for the current number issuance according to the user's selection operation of the at least one user-defined sequence rule.
[0057] The selection operation may be a click operation by the user on the user-defined sequence rule used for the current number issuance.
[0058] In addition, before this step, a regular expression input by a user can be received through a front-end web page, and a user-defined sequence rule is generated according to the structure of the regular expression and the user-defined sequence rule, and each user-defined sequence rule set generates a user-defined sequence library. Wherein, a regular expression is a logical formula for operating a string (including common characters (for example, letters between a and z) and special characters (called "meta characters"), that is, some preset specific characters and the combination of these specific characters are composed into a "rule string", and this "rule string" is used to express a filtering logic for the string. In the present invention, one or more rules to be matched when generating a global unique ID sequence are described by a regular expression. Exemplarily, a regular expression %s can be used to describe a user-defined sequence rule, wherein % represents processing in the used rows of the global unique ID sequence, s represents a search function, and the regular expression %s represents that the specified character can be found in all rows. For example, ABC%s represents that the specified character ABC can be found in all rows. The structure of the user-defined sequence rule includes a sequence number name, a start index, a sequence minimum value, a sequence maximum value, an incremental step, a previous index, a current index, and a sequence number format, wherein the sequence number format is used to specify the numbers, character positions, and numbers contained in the sequence number. When specifically generating a user-defined sequence rule, a corresponding identifier can be set for each structure of the user-defined sequence rule, and the customization of each structure is completed by receiving the regular expression %s corresponding to the identifier input by the user, and the customized structures are spliced to obtain a complete user-defined sequence rule.
[0059] S2. When receiving the starting numbering request of the node, the starting globally unique ID sequence is generated by using the custom serial number rule, and the starting globally unique ID sequence is stored in the buffer queue;
[0060] In a distributed system, data and programs can be dispersed to different nodes, and all nodes work together to implement a series of business functions. In an embodiment of the present invention, when a distributed system includes multiple business modules, each business node generates a globally unique ID sequence by sending a number issuance request to notify the ID component, and reads the corresponding globally unique ID sequence from the buffer queue by sending a number issuance consumption request. Among them, the ID component is developed in the form of spring boot starter in an embedded manner, and the ID component can provide an interface API, so that it can be integrated into the distributed system in the form of a plug-in.
[0061] like Figure 2As shown, the distributed system includes nodes 1, 2...N, and the ID component of the present invention can be inserted into each node in an embedded manner, and each node can correspond to an ID component to generate a globally unique ID sequence requested by the node. For a new business at the application layer (such as order number business, log number business, etc.), at the beginning of the business, the user-defined sequence rule adopted by this issuance is received through the front-end page, and the starting node of the business, such as node 2, will send a start issuance request to its corresponding ID component 2. When the start issuance request of node 2 is received, the ID component 2 uses the user-defined sequence rule of this issuance to generate a starting globally unique ID sequence. In addition, in order to save the problem that the globally unique ID sequence occupies a large storage space and affects the database insertion and query performance, the present invention adopts a production / consumption mode to store the globally unique ID sequence pre-generated by each ID component in a buffer queue, and directly obtains the ID sequence from the memory when calling, effectively reducing the storage space of the serial number. Therefore, after generating the starting globally unique ID sequence, the ID component 2 stores the starting globally unique ID sequence in the buffer queue, completing the production and storage of the starting globally unique ID sequence in the new business.
[0062] like Figure 2 As shown, the buffer queue can be multiple, preferably a blocking queue, through which an intermediary for consumers (multiple) and producers (multiple) to exchange products is implemented. The producer thread (i.e., the ID component) is blocked when the queue is full, and the consumer thread (each node) is blocked when the queue is empty.
[0063] S3, according to the order of the node number request, the current globally unique ID sequence value is incremented by 1 by atomic operation to generate a new globally unique ID sequence, and the new globally unique ID sequence is stored in the buffer queue;
[0064] In order to ensure the uniqueness of the global unique ID sequence subsequently generated by each ID component in the distributed system, each ID component of the present invention uses an atomic operation to increment the current global unique ID sequence value by 1 according to the order of the node's number issuance request to generate a new global unique ID sequence, thereby achieving the purpose of the self-incrementing sequence. Among them, an atomic operation refers to one or a series of operations that cannot be interrupted. It can be implemented in a processor or in Java. The present invention uses the Java atomic operation class AtomicLong to atomically increment the current global unique ID sequence value by 1, and returns the incremented value to obtain a new global unique ID sequence, and then stores the new global unique ID sequence in a buffer queue in a production / consumption manner.
[0065] Among them, each buffer queue is set with a storage threshold. When the buffer queue reaches the storage threshold, that is, when the buffer queue is blocked, the buffer queue is cleared and a new globally unique ID sequence is regenerated. That is, according to the order of node number issuance requests, the current globally unique ID sequence value is incremented by 1 through atomic operations to generate a new globally unique ID sequence, and the new globally unique ID sequence is stored in the buffer queue.
[0066] S4. When receiving a number consumption request from a node, read the globally unique ID sequence from the cache queue in sequence.
[0067] When a specific service is completed in a node, the node will send a number consumption request to its corresponding ID component to obtain the global unique ID sequence of the service as the service serial number. The present invention uses a first-in-first-out method to read the global unique ID sequence from the cache queue in sequence.
[0068] Further, such as Figure 2 The present invention can also store the globally unique ID sequence read from the cache queue into a database to facilitate subsequent queries. The database can be MySQL or redis. In the present invention, the value range of the globally unique ID sequence is generated using the sharding principle. The database storing the globally unique ID sequence is split and distributed on different machines.
[0069] Figure 3 FIG. 1 is a schematic diagram of the architecture of a distributed number issuing device according to the present invention. Figure 3 As shown, the device comprises:
[0070] The acquisition module 31 is used to obtain the user-defined sequence rule used for this number issuance; wherein the structure of the user-defined sequence number rule includes the sequence number name, start index, sequence minimum value, sequence maximum value, increment step, previous index, current index and sequence number format.
[0071] A first generating module 32 is used for, when receiving a starting numbering request from a node, generating a starting globally unique ID sequence using the custom serial number rule, and storing the starting globally unique ID sequence in a buffer queue;
[0072] The second generating module 33 is used to generate a new globally unique ID sequence by increasing the current globally unique ID sequence value by 1 through an atomic operation according to the order of the node number issuance request, and store the new globally unique ID sequence in a buffer queue;
[0073] The reading module 34 is used to read the global unique ID sequence from the cache queue in sequence when receiving a number issuance and consumption request from a node.
[0074] In a specific embodiment, the second generation module 33 is also used to clear the buffer queue when the buffer queue reaches the storage threshold, and to increase the current globally unique ID sequence value by 1 through atomic operations according to the order of node number issuance requests to generate a new globally unique ID sequence, and to store the new globally unique ID sequence in the buffer queue.
[0075] The acquisition module 31 includes:
[0076] A receiving module, used for receiving keywords input by a user;
[0077] A matching module, used for matching the user-defined sequence library according to the keyword, and displaying at least one matched user-defined sequence rule;
[0078] The determination module is used to determine the user-defined sequence rule used for the current number issuance according to the user's selection operation of the at least one user-defined sequence rule.
[0079] In the present invention, the value range of the globally unique ID sequence is generated using the fragmentation principle.
[0080] Furthermore, the device also includes:
[0081] The storage module 35 is used to store the globally unique ID sequence read from the cache queue into the database.
[0082] Those skilled in the art will appreciate that the modules in the above device embodiments may be distributed in the device as described, or may be changed accordingly and distributed in one or more devices different from the above embodiments. The modules in the above embodiments may be combined into one module, or may be further split into multiple submodules.
[0083] The electronic device embodiment of the present invention is described below, and the electronic device can be regarded as a physical implementation of the method and device embodiments of the present invention described above. The details described in the electronic device embodiment of the present invention should be regarded as a supplement to the above method or device embodiments; details not disclosed in the electronic device embodiment of the present invention can be implemented with reference to the above method or device embodiments.
[0084] Figure 4 is a structural block diagram of an exemplary embodiment of an electronic device according to the present invention. Figure 4 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0085] like Figure 4As shown, the electronic device 400 of this exemplary embodiment is in the form of a general data processing device. The components of the electronic device 400 may include, but are not limited to: at least one processing unit 410, at least one storage unit 420, a bus 430 connecting different electronic device components (including the storage unit 420 and the processing unit 410), a display unit 440, etc.
[0086] The storage unit 420 stores a computer-readable program, which may be a source program or a code of a read-only program. The program may be executed by the processing unit 410, so that the processing unit 410 performs the steps of various embodiments of the present invention. For example, the processing unit 410 may perform the following steps: Figure 1 Steps shown.
[0087] The storage unit 420 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 4201 and / or a cache storage unit 4202, and may further include a read-only storage unit (ROM) 4203. The storage unit 420 may also include a program / utility 4204 having a set (at least one) of program modules 4205, such program modules 4205 include but are not limited to: operating electronic devices, one or more application programs, other program modules and program data, each of which or some combination may include the implementation of a network environment.
[0088] Bus 430 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0089] The electronic device 400 may also communicate with one or more external devices 300 (e.g., keyboard, display, network device, Bluetooth device, etc.) so that a user can interact with the electronic device 400 via these external devices 300, and / or enable the electronic device 400 to communicate with one or more other data processing devices (e.g., routers, modems, etc.). Such communication may be performed through an input / output (I / O) interface 450, and may also be performed through a network adapter 460 with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet). The network adapter 460 may communicate with other modules of the electronic device 400 through the bus 430. It should be understood that although Figure 4 Not shown, other hardware and / or software modules may be used in the electronic device 400, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID electronic devices, tape drives, and data backup storage electronic devices, etc.
[0090] Figure 5 Schematic diagram of a computer readable medium embodiment of the present invention. Figure 5 As shown, the computer program can be stored on one or more computer-readable media. The computer-readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, an electronic device, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. When the computer program is executed by one or more data processing devices, the computer-readable medium can implement the above method of the present invention, namely: obtaining the user-defined sequence rule used for this number issuance; when receiving the starting number issuance request of the node, using the custom sequence number rule to generate a starting globally unique ID sequence, and storing the starting globally unique ID sequence in a buffer queue; according to the order of the node number issuance request, the current globally unique ID sequence value is incremented by 1 through atomic operations to generate a new globally unique ID sequence, and the new globally unique ID sequence is stored in the buffer queue; when receiving the number issuance consumption request of the node, the globally unique ID sequence is read from the cache queue in sequence.
[0091] Through the description of the above implementation modes, it is easy for those skilled in the art to understand that the exemplary embodiments described in the present invention can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation mode of the present invention can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a data processing device (which can be a personal computer, a server, or a network device, etc.) to execute the above method according to the present invention.
[0092] The computer readable storage medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in combination with an instruction-executing electronic device, device, or device. The program code contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.
[0093] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., as well as conventional procedural programming languages such as "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0094] In summary, the present invention can be implemented by a method, apparatus, electronic device or computer-readable medium that executes a computer program. In practice, a general-purpose data processing device such as a microprocessor or a digital signal processor (DSP) can be used to implement some or all of the functions of the present invention.
[0095] The specific embodiments described above further describe the purpose, technical solutions and beneficial effects of the present invention in detail. It should be understood that the present invention is not inherently related to any specific computer, virtual device or electronic device, and various general devices can also implement the present invention. The above description is only a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A distributed number distribution method based on atomic operations, characterized in that: The method comprises: Generate a globally unique ID component in each node of the distributed system in an embedded manner, and each node corresponds to an ID component to generate a globally unique ID sequence requested by the node; The ID component obtains the user-defined sequence rule used for issuing the business serial number this time; When receiving the node's initial numbering request, the ID component generates an initial globally unique ID sequence using the custom serial number rule, and stores the initial globally unique ID sequence in a buffer queue; The ID component increments the current globally unique ID sequence value by 1 to generate a new globally unique ID sequence through atomic operations according to the order of the node number issuance request, and stores the new globally unique ID sequence in the buffer queue; When the ID component receives a number issuance and consumption request from a node, it reads the globally unique ID sequence from the buffer queue in sequence.
2. The method according to claim 1, characterized in that When the buffer queue reaches the storage threshold, the buffer queue is cleared, and the current globally unique ID sequence value is incremented by 1 to generate a new globally unique ID sequence through atomic operations according to the order of node number issuance requests, and the new globally unique ID sequence is stored in the buffer queue.
3. The method according to claim 2, characterized in that The user-defined sequence rules used to obtain the number issuance include: Receive keywords input by users; Matching a user-defined sequence library according to the keyword, and displaying at least one matched user-defined sequence rule; The user-defined sequence rule used for the current number issuance is determined according to the user's selection operation of the at least one user-defined sequence rule.
4. The method according to claim 3, characterized in that The value range of the globally unique ID sequence is generated using the fragmentation principle.
5. The method according to claim 1, characterized in that The method further comprises: Store the globally unique ID sequence read from the cache queue into the database.
6. The method according to claim 1, characterized in that The structure of the custom serial number rule includes a serial number name, a start index, a sequence minimum value, a sequence maximum value, an increment step, a previous index, a current index and a serial number format.
7. A distributed number issuing device based on atomic operation, characterized in that: The device comprises: A generation module, used to generate a globally unique ID component in each node of the distributed system in an embedded manner, each node corresponding to an ID component to generate a globally unique ID sequence requested by the node; The ID component module is used to obtain the user-defined sequence rules used for this number issuance; when receiving the node's initial business serial number issuance request, the user-defined sequence number rules are used to generate a starting globally unique ID sequence, and the starting globally unique ID sequence is stored in a buffer queue; according to the order of the node's number issuance request, the current globally unique ID sequence value is incremented by 1 through atomic operations to generate a new globally unique ID sequence, and the new globally unique ID sequence is stored in the buffer queue; when the node's number issuance consumption request is received, the globally unique ID sequence is read from the buffer queue in sequence.
8. The device according to claim 7, characterized in that The ID component module is also used to clear the buffer queue when the buffer queue reaches a storage threshold, and to increase the current globally unique ID sequence value by 1 through atomic operations according to the order of node number issuance requests to generate a new globally unique ID sequence, and to store the new globally unique ID sequence in the buffer queue.
9. The device according to claim 8, characterized in that The ID component module includes: A receiving module, used for receiving keywords input by a user; A matching module, used for matching the user-defined sequence library according to the keyword, and displaying at least one matched user-defined sequence rule; The determination module is used to determine the user-defined sequence rule used for the current number issuance according to the user's selection operation of the at least one user-defined sequence rule.
10. The device according to claim 9, characterized in that The value range of the globally unique ID sequence is generated using the fragmentation principle.
11. The device according to claim 7, characterized in that The device also includes: The storage module is used to store the globally unique ID sequence read from the cache queue into the database.
12. The device according to claim 7, characterized in that The structure of the custom serial number rule includes a serial number name, a start index, a sequence minimum value, a sequence maximum value, an increment step, a previous index, a current index and a serial number format.
13. An electronic device comprising: processor; as well as A memory storing computer executable instructions which, when executed, cause the processor to perform the method according to any one of claims 1-6.
14. A computer-readable storage medium, wherein: The computer-readable storage medium stores one or more programs, and when the one or more programs are executed by a processor, the method according to any one of claims 1 to 6 is implemented.
