Serial number generation method and device, electronic equipment and storage medium

By generating node identifiers and timestamps in distributed nodes, combined with logical clocks and network time protocols, a globally unique serial number is independently generated, which solves the problem in the existing technology that serial number generation relies on external storage or coordination services, and achieves Efficient, reliable and secure generation of serial numbers.

CN118779378APending Publication Date: 2024-10-15BEIYIN FINANCIAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410813412.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2024-10-15

AI Technical Summary

Technical Problem

In the existing technology, the generation of serial numbers relies on centralized external storage or distributed coordination services, resulting in single point failure risks and management complexity, making it difficult to independently generate globally unique serial numbers among distributed nodes.

Method used

When a distributed node starts, the node identifier is generated based on the hardware information, and a globally unique serial number is generated based on the timestamp and sequence number to avoid relying on external storage or distributed coordination services. The system clock is synchronized through the logical clock and network time protocol. Ensure the uniqueness and reliability of the serial number.

Benefits of technology

It eliminates the risk of single point of failure, reduces management complexity and operation and maintenance costs, adapts to the needs of high concurrency and large-scale distributed systems, and ensures the uniqueness and reliability of serial numbers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118779378A_ABST
    Figure CN118779378A_ABST
Patent Text Reader

Abstract

The invention provides a serial number generation method and device, electronic equipment and a storage medium, and relates to the technical field of computers, and when a distributed node is started, a node identifier is generated according to hardware information of the distributed node. The distributed nodes independently generate unique node identifiers, and the node identifiers, the first timestamps when the serial number generation requests are received and the target serial numbers are combined, so that globally unique serial numbers can be independently generated. Therefore, node identifiers do not need to be distributed and managed by means of centralized external storage or distributed coordination service, and the risk of single-point failure is fundamentally eliminated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, device, electronic device and storage medium for generating a serial number. Background Art

[0002] Serial numbers play an important role in data management and system design. They can provide data uniqueness, order, traceability and controllability, and help improve system reliability, scalability and maintainability. Therefore, serial numbers are widely used in various industries and fields. For example, in bank transaction data management, serial numbers are the basis for achieving safe and smooth bank transactions.

[0003] In related technologies, the generation of serial numbers usually relies on centralized external storage, such as a database or cache system, which introduces the risk of a single point of failure. Summary of the invention

[0004] In order to solve the above-mentioned problems in the prior art, the embodiments of the present application provide a serial number generation method, device, electronic device and storage medium for generating non-repetitive serial numbers without relying on external storage.

[0005] In a first aspect, an embodiment of the present application provides a method for generating a serial number, the method comprising:

[0006] When the distributed node is started, generating a node identifier according to the hardware information of the distributed node;

[0007] In response to the serial number generation request, obtain a first timestamp and a target serial number, wherein the first timestamp represents the time when the distributed node receives the serial number generation request, and the number of digits of the target serial number is determined according to the maximum number of serial numbers required to be generated by the distributed node per unit time;

[0008] A serial number is generated according to the node identifier, the first timestamp and the target sequence number.

[0009] In a possible implementation manner, when the distributed node is started, generating a node identifier according to the hardware information of the distributed node includes:

[0010] Obtaining a startup timestamp when the distributed node is started;

[0011] The node identifier is generated according to the startup timestamp and the hardware information of the distributed node.

[0012] In a possible implementation manner, the hardware information of the distributed node is at least one of a MAC address, a device model, and a device serial number of the distributed node.

[0013] In a possible implementation manner, the serial number is the i+1th serial number, and the target sequence number is generated by the following method:

[0014] Obtain a second timestamp, where the second timestamp is the timestamp used to generate the i-th serial number;

[0015] Determine whether the first timestamp and the second timestamp are the same; if so, perform an increment operation on the target sequence number; if not, perform a reset operation on the target sequence number.

[0016] In a possible implementation manner, obtaining the first timestamp includes:

[0017] If it is determined that the system clock is dialed back, a logical clock is used to generate a timestamp; the logical clock is a software clock in the distributed node, and the system clock is a physical clock in the distributed node;

[0018] The timestamp generated by the logical clock is used as the first timestamp.

[0019] In a possible implementation manner, the serial number is the (i+1)th serial number, and whether the system clock is dialed back is determined by the following method:

[0020] Obtain a second timestamp, where the second timestamp is the timestamp used to generate the i-th serial number;

[0021] If the first timestamp is earlier than the second timestamp, it is determined that the system clock is dialed back; otherwise, it is determined that the system clock is not dialed back.

[0022] In a possible implementation manner, after generating the node identifier, the method further includes:

[0023] Synchronizes system clocks based on the Network Time Protocol based on pre-set time periods.

[0024] In a second aspect, an embodiment of the present application provides a serial number generating device, the device comprising:

[0025] A node identifier generating unit, configured to generate a node identifier according to hardware information of the distributed node when the distributed node is started;

[0026] an information acquisition unit, configured to acquire a first timestamp and a target serial number in response to a serial number generation request, wherein the first timestamp indicates a time when the distributed node receives the serial number generation request, and the number of digits of the target serial number is determined according to a maximum number of serial numbers required to be generated by the distributed node per unit time;

[0027] A serial number generating unit is used to generate a serial number according to the node identifier, the first timestamp and the target sequence number.

[0028] In a possible implementation manner, the node identifier generation unit is specifically configured to:

[0029] Obtaining a startup timestamp when the distributed node is started;

[0030] The node identifier is generated according to the startup timestamp and the hardware information of the distributed node.

[0031] In a possible implementation manner, the hardware information of the distributed node is at least one of a MAC address, a device model, and a device serial number of the distributed node.

[0032] In a possible implementation manner, the information acquisition unit is specifically configured to:

[0033] Obtain a second timestamp, where the second timestamp is the timestamp used to generate the i-th serial number;

[0034] Determine whether the first timestamp and the second timestamp are the same; if so, perform an increment operation on the target sequence number; if not, perform a reset operation on the target sequence number.

[0035] In a possible implementation manner, the information acquisition unit is specifically configured to:

[0036] If it is determined that the system clock is dialed back, a logical clock is used to generate a timestamp; the logical clock is a software clock in the distributed node, and the system clock is a physical clock in the distributed node;

[0037] The timestamp generated by the logical clock is used as the first timestamp.

[0038] In a possible implementation manner, the information acquisition unit is specifically configured to:

[0039] Obtain a second timestamp, where the second timestamp is the timestamp used to generate the i-th serial number;

[0040] If the first timestamp is earlier than the second timestamp, it is determined that the system clock is dialed back; otherwise, it is determined that the system clock is not dialed back.

[0041] In a possible implementation manner, the serial number generating unit is further configured to:

[0042] Synchronizes system clocks based on the Network Time Protocol based on pre-set time periods.

[0043] In a third aspect, an embodiment of the present application provides an electronic device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, and when the computer program is executed by the processor, any one of the methods for generating serial numbers in the first aspect is implemented.

[0044] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in any one of the serial number generation methods in the first aspect is implemented.

[0045] The technical solution provided by the embodiments of the present application brings at least the following beneficial effects:

[0046] The embodiments of the present application provide a method, device, electronic device and storage medium for generating a serial number. When a distributed node is started, a node identifier is generated according to the hardware information of the distributed node. The distributed node independently generates a unique node identifier, and combines the node identifier, the first timestamp when the serial number generation request is received, and the target sequence number to independently generate a globally unique serial number. As a result, there is no need to rely on centralized external storage or distributed coordination services to allocate and manage node identifiers, which fundamentally eliminates the risk of single point failures.

[0047] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0049] Figure 1 A flowchart of a method for generating a serial number provided in an embodiment of the present application;

[0050] Figure 2 A schematic diagram of the structure of a serial number generating device provided in an embodiment of the present application;

[0051] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0052] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0053] It should be noted that the terms "including" and "having" and their variations involved in the documents of this application are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0054] Serial numbers play an important role in data management and system design. They can provide data uniqueness, order, traceability and controllability, and help improve system reliability, scalability and maintainability. Therefore, serial numbers are widely used in various industries and fields. For example, in bank transaction data management, serial numbers are the basis for achieving safe and smooth bank transactions.

[0055] In related technologies, the generation of serial numbers usually relies on centralized external storage, such as a database or cache system, or uses distributed coordination services such as Zookeeper to allocate and manage node identifiers. This approach not only introduces the risk of single point failures, but also increases the complexity of management.

[0056] Based on this, the embodiments of the present application provide a method, device, electronic device and storage medium for generating a serial number. When a distributed node is started, a node identifier is generated according to the hardware information of the distributed node. The distributed node independently generates a unique node identifier, and combines the node identifier, the first timestamp when the serial number generation request is received, and the target sequence number to independently generate a globally unique serial number. As a result, there is no need to rely on centralized external storage or distributed coordination services to allocate and manage node identifiers, which fundamentally eliminates the risk of single point failures and reduces the complexity of management.

[0057] Figure 1 A flowchart of a serial number generation method provided by an embodiment of the present application is shown, and the method can be completed by any distributed node in a distributed system. Figure 1 As shown, the serial number generation method may include the following steps:

[0058] Step S101: when a distributed node is started, a node identifier is generated according to hardware information of the distributed node.

[0059] When a distributed node is started, it can determine its own hardware information and generate a node identifier of the distributed node based on its own hardware information, thereby ensuring that the node identifier is unique in the entire distributed system.

[0060] In an optional implementation, the MAC address of the distributed node may be used as the node identifier of the distributed node. Since the MAC address of each distributed node is unique in the entire distributed system, using the MAC address as the node identifier of the distributed node can effectively provide uniqueness assurance.

[0061] In another optional implementation, other hardware information besides the MAC address may also be used as the node identifier of the distributed node. For example, the device model of the distributed node may be used as the node identifier of the distributed node, or the device serial number of the distributed node may be used as the node identifier of the distributed node.

[0062] In order to further ensure the uniqueness of the node identifier, in an optional implementation, the MAC address, device model and device serial number of the distributed node may be combined, and the result of the combination may be used as the node identifier of the distributed node.

[0063] In some embodiments, the MAC address and the device model may be combined, and the combined result of the MAC address and the device model may be used as the node identifier of the distributed node.

[0064] In other embodiments, the MAC address and the device serial number may also be combined, and the combined result of the MAC address and the device serial number may be used as the node identifier of the distributed node.

[0065] In some other embodiments, the device model and the device serial number may also be combined, and the combined result of the device model and the device serial number may be used as the node identifier of the distributed node.

[0066] In other embodiments, the MAC address, the device model, and the device serial number may be combined, and the combined result of the MAC address, the device model, and the device serial number may be used as the node identifier of the distributed node.

[0067] In another optional implementation, in order to further ensure the uniqueness of the node identifier, based on generating the node identifier according to the hardware information of the distributed node, a unique node identifier can also be generated in combination with the startup timestamp when the distributed node is started.

[0068] In a specific implementation, when a distributed node is started, the system clock can be used to obtain the current timestamp, that is, the startup timestamp of the distributed node. Then, the startup timestamp of the distributed node and the hardware information of the distributed node are combined, and then the combination result of the startup timestamp of the distributed node and the hardware information of the distributed node is used as the node identifier of the distributed node.

[0069] In some embodiments, when a distributed node is started, the MAC address of the distributed node and the startup timestamp of the distributed node may be combined, and the combined result of the MAC address of the distributed node and the startup timestamp of the distributed node may be used as the node identifier of the distributed node.

[0070] In other embodiments, when a distributed node is started, the device serial number of the distributed node and the startup timestamp of the distributed node may be combined, and the combined result of the device serial number of the distributed node and the startup timestamp of the distributed node may be used as the node identifier of the distributed node.

[0071] In other embodiments, when a distributed node is started, the device model of the distributed node and the startup timestamp of the distributed node may be combined, and the combined result of the device model of the distributed node and the startup timestamp of the distributed node may be used as the node identifier of the distributed node.

[0072] In other embodiments, the MAC address, the device serial number and the startup timestamp of the distributed node may be combined, and the combined result of the MAC address, the device serial number and the startup timestamp of the distributed node may be used as the node identifier of the distributed node.

[0073] In other embodiments, the MAC address, device model and the startup timestamp of the distributed node may also be combined, and the combined result of the MAC address, device model and the startup timestamp of the distributed node may be used as the node identifier of the distributed node.

[0074] In other embodiments, the device model, the device serial number and the startup timestamp of the distributed node may be combined, and the combined result of the device model, the device serial number and the startup timestamp of the distributed node may be used as the node identifier of the distributed node.

[0075] In other embodiments, the MAC address, device model, device serial number and the startup timestamp of the distributed node may be combined, and the combined result of the MAC address, device model, device serial number and the startup timestamp of the distributed node may be used as the node identifier of the distributed node.

[0076] At this point, the distributed node has completed the operation of generating a unique node identifier in the distributed system. After the distributed node generates the node identifier, the node identifier can be stored in the memory for use in subsequent serial number generation.

[0077] Step S102, in response to a serial number generation request, obtaining a first timestamp and a target serial number.

[0078] In each distributed node, a high-precision timestamp generator can be independently maintained. The timestamp accuracy can be milliseconds. If higher accuracy is required, microsecond or nanosecond accuracy can be used to ensure the distinction between different time points.

[0079] In the present application, the distributed nodes independently maintain the timestamp generator, which can avoid the problem of generating duplicate serial numbers due to clock synchronization.

[0080] In a specific implementation, when a distributed node receives a request to generate a serial number, it can use the system clock to obtain a current timestamp, that is, a first timestamp.

[0081] Since the system clock may be dialed back in the distributed system, duplicate serial numbers may be generated. Therefore, the distributed nodes need to determine whether the system clock has dialed back to avoid generating duplicate serial numbers. Assuming that the first timestamp generates the i+1th serial number, before generating the target sequence number for generating the i+1th serial number, it can be determined whether the first timestamp used to generate the i+1th serial number is earlier than the second timestamp used to generate the i-th serial number. If the first timestamp is earlier than the second timestamp, it can be determined that the system clock has dialed back. Otherwise, it is determined that the system clock has not dialed back.

[0082] In an optional implementation, if it is determined that the system clock is dialed back, a logical clock may be used to generate a timestamp, wherein the logical clock is a software clock maintained in a distributed node and the system clock is a physical clock in a distributed node. After the timestamp is generated using the logical clock, the timestamp generated by the logical clock may be used as the first timestamp.

[0083] The logical clock can ensure the orderliness of timestamps, thereby effectively preventing the problem of generating duplicate serial numbers caused by system clock dialback, and ensuring the uniqueness and reliability of serial numbers in distributed systems.

[0084] In another optional implementation, in order to prevent the generation of duplicate serial numbers due to clock rollback, after the distributed node is started and the node identifier is generated, the system clock can be synchronized according to the network time protocol based on a pre-set time period, thereby avoiding the problem of generating duplicate serial numbers due to system clock rollback and ensuring the uniqueness and reliability of the serial number in the distributed system.

[0085] After obtaining the first timestamp, the distributed node may use a local counter to generate a target sequence number, wherein the target sequence number is used to generate a final serial number.

[0086] In a specific implementation, when the distributed node is started, it can initialize the locally maintained counter and start counting from 0. Assuming that the first timestamp generates the i+1th serial number, before generating the target sequence number for generating the i+1th serial number, it can be determined whether the second timestamp used to generate the i-th serial number is the same as the first timestamp.

[0087] In some embodiments, if the second timestamp is different from the first timestamp, it means that the time when the i+1th serial number is generated is different from the time when the ith serial number is generated, and the target serial number can be reset, that is, counted from zero again. For example, if the serial number that generates the ith serial number is 70, the target serial number that generates the i+1th serial number is 0.

[0088] In other embodiments, if the second timestamp is the same as the first timestamp, it means that the time of generating the i+1th serial number is the same as the time of generating the ith serial number, and the target serial number can be incremented. For example, if the serial number of generating the ith serial number is 70, the target serial number of generating the i+1th serial number can be 71.

[0089] In this application, distributed nodes maintain a local sequence number counter at the same timestamp without coordination with other nodes, thereby reducing the complexity of the distributed system.

[0090] It should be noted that the embodiment of the present application does not impose any limitation on the increase range of the target sequence number, and the increase range may also be 2, or other ranges.

[0091] In an optional implementation, the number of digits of the target sequence number is determined based on the maximum number of serial numbers required to be generated by the distributed nodes per unit time.

[0092] For example, assuming that the maximum number of serial numbers generated by the system within a unit of time (such as 1 millisecond) is 80, then in decimal, the target serial number only needs 2 digits to fully distinguish the 80 generated serial numbers.

[0093] At this point, the distributed node obtains the first timestamp representing the time when the distributed node receives the serial number generation request, and the target sequence number for generating the serial number.

[0094] Step S103, generating a serial number according to the node identifier, the first timestamp and the target sequence number.

[0095] After obtaining the node identifier, the first timestamp and the target sequence number, a final serial number can be generated based on a preset serial number format, thereby ensuring the uniqueness of the serial number in the entire distributed system.

[0096] For example, the format of the serial number can be set as first timestamp-node identifier-target sequence number. For another example, the format of the serial number can also be set as first timestamp-target sequence number-node identifier. The specific format of the serial number definition is not limited in this application.

[0097] In related technologies, the generation of serial numbers usually relies on centralized external storage, such as a database or cache system. This approach requires a centralized coordination service to allocate and manage data center identifiers and machine identifiers, such as Zookeeper. This approach not only introduces the risk of single point failures, but also requires the configuration and maintenance of data center identifiers and machine identifiers, increasing the complexity of the system and the cost of operation and maintenance.

[0098] Based on this, a serial number generation method provided in an embodiment of the present application generates a node identifier according to the hardware information of the distributed node when the distributed node is started. The distributed node independently generates a unique node identifier, and combines the node identifier, the first timestamp when the serial number generation request is received, and the target sequence number to independently generate a globally unique serial number. As a result, there is no need to rely on centralized external storage or distributed coordination services to allocate and manage node identifiers, which fundamentally eliminates the risk of single point failures and reduces the complexity and operation and maintenance costs of the system. Therefore, it can meet the needs of high concurrency and large-scale distributed systems.

[0099] Based on the same inventive concept, an embodiment of the present invention also provides a structural schematic diagram of a serial number generating device, such as Figure 2 As shown, the serial number generating device includes:

[0100] The node identifier generating unit 201 is used to generate a node identifier according to the hardware information of the distributed node when the distributed node is started.

[0101] The information acquisition unit 202 is used to obtain a first timestamp and a target serial number in response to a serial number generation request, wherein the first timestamp represents the time when the distributed node receives the serial number generation request, and the number of digits of the target serial number is determined based on the maximum number of serial numbers required to be generated by the distributed node per unit time.

[0102] The serial number generating unit 203 is used to generate a serial number according to the node identifier, the first timestamp and the target sequence number.

[0103] In a possible implementation manner, the node identifier generation unit 201 is specifically configured to:

[0104] Get the startup timestamp when the distributed node is started;

[0105] Generate a node identifier based on the startup timestamp and the hardware information of the distributed node.

[0106] In a possible implementation manner, the hardware information of the distributed node is at least one of a MAC address, a device model, and a device serial number of the distributed node.

[0107] In a possible implementation manner, the information acquisition unit 202 is specifically configured to:

[0108] Get a second timestamp, which is the timestamp used to generate the i-th serial number;

[0109] Determine whether the first timestamp and the second timestamp are the same; if so, perform an increment operation on the target sequence number; if not, perform a reset operation on the target sequence number.

[0110] In a possible implementation manner, the information acquisition unit 202 is specifically configured to:

[0111] If the system clock is set back, the logical clock is used to generate the timestamp; the logical clock is the software clock in the distributed node, and the system clock is the physical clock in the distributed node;

[0112] The timestamp generated by the logical clock is used as the first timestamp.

[0113] In a possible implementation manner, the information acquisition unit 202 is specifically configured to:

[0114] Get a second timestamp, which is the timestamp used to generate the i-th serial number;

[0115] If the first timestamp is earlier than the second timestamp, it is determined that the system clock is dialed back; otherwise, it is determined that the system clock is not dialed back.

[0116] In a possible implementation manner, the serial number generating unit 203 is further configured to:

[0117] Synchronizes system clocks based on the Network Time Protocol based on pre-set time periods.

[0118] Based on the same inventive concept, an embodiment of the present application further provides an electronic device, which may be the distributed node mentioned above. The electronic device includes at least a memory and a processor for storing data, wherein, for the processor for data processing, when executing the processing, a microprocessor, a CPU, a GPU (Graphics Processing Unit), a DSP or an FPGA may be used. For the memory, an operation instruction is stored in the memory, and the operation instruction may be a computer executable code, and each step in the process of the serial number generation method of the embodiment of the present application is implemented by the operation instruction.

[0119] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 3 As shown, the electronic device 300 includes a memory 301, a processor 302, a data acquisition module 303 and a bus 304. The memory 301, the processor 302 and the data acquisition module 303 are all connected via the bus 304, and the bus 304 is used to transmit data between the memory 301, the processor 302 and the data acquisition module 303.

[0120] Among them, the memory 301 can be used to store software programs and modules, and the processor 302 executes various functional applications and data processing of the electronic device 300 by running the software programs and modules stored in the memory 301, such as the serial number generation method provided in the embodiment of the present application. The memory 301 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application application, etc.; the data storage area can store data created according to the use of the electronic device 300, etc. In addition, the memory 301 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0121] The processor 302 is the control center of the electronic device 300, and uses the bus 304 and various interfaces and lines to connect various parts of the entire electronic device 300, and executes various functions and processes data of the electronic device 300 by running or executing software programs and / or modules stored in the memory 301, and calling data stored in the memory 301. Optionally, the processor 302 may include one or more processing units, such as a CPU, a GPU (Graphics Processing Unit), a digital processing unit, etc.

[0122] An embodiment of the present application also provides a computer-readable storage medium, which stores computer-executable instructions. When the computer program is executed by a processor, it can be used to implement the serial number generation method recorded in any embodiment of the present application.

[0123] In some possible implementations, various aspects of the serial number generation method provided in the present application may also be implemented in the form of a program product, which includes program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of the serial number generation method according to various exemplary embodiments of the present application described above in this specification. For example, the computer device may execute the following steps: Figure 1 The process of the serial number generation method shown in FIG.

[0124] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0125] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0126] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0127] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0128] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A method for generating a serial number, characterized in that: Applied to a distributed node, the method comprises: When the distributed node is started, generating a node identifier according to the hardware information of the distributed node; In response to the serial number generation request, obtain a first timestamp and a target serial number, wherein the first timestamp represents the time when the distributed node receives the serial number generation request, and the number of digits of the target serial number is determined according to the maximum number of serial numbers required to be generated by the distributed node per unit time; A serial number is generated according to the node identifier, the first timestamp and the target sequence number.

2. The method according to claim 1, characterized in that When the distributed node is started, generating a node identifier according to the hardware information of the distributed node includes: Obtaining a startup timestamp when the distributed node is started; The node identifier is generated according to the startup timestamp and the hardware information of the distributed node.

3. The method according to claim 1 or 2, characterized in that: The hardware information of the distributed node is at least one of a MAC address, a device model, and a device serial number of the distributed node.

4. The method according to claim 1, characterized in that: The serial number is the i+1th serial number, and the target serial number is generated by the following method: Obtain a second timestamp, where the second timestamp is the timestamp used to generate the i-th serial number; Determine whether the first timestamp and the second timestamp are the same; if so, perform an increment operation on the target sequence number; if not, perform a reset operation on the target sequence number.

5. The method according to claim 1, characterized in that The obtaining of the first timestamp comprises: If it is determined that the system clock is dialed back, a logical clock is used to generate a timestamp; the logical clock is a software clock in the distributed node, and the system clock is a physical clock in the distributed node; The timestamp generated by the logical clock is used as the first timestamp.

6. The method according to claim 5, characterized in that The serial number is the i+1th serial number, and whether the system clock is dialed back is determined by the following method: Obtain a second timestamp, where the second timestamp is the timestamp used to generate the i-th serial number; If the first timestamp is earlier than the second timestamp, determining that the system clock is dialed back; Otherwise, it is determined that the system clock has not been dialed back.

7. The method according to claim 1, characterized in that After generating the node identifier, the method further includes: Synchronizes system clocks based on the Network Time Protocol based on pre-set time periods.

8. A serial number generating device, characterized in that: The device comprises: A node identifier generating unit, configured to generate a node identifier according to hardware information of the distributed node when the distributed node is started; an information acquisition unit, configured to acquire a first timestamp and a target serial number in response to a serial number generation request, wherein the first timestamp indicates a time when the distributed node receives the serial number generation request, and the number of digits of the target serial number is determined according to a maximum number of serial numbers required to be generated by the distributed node per unit time; A serial number generating unit is used to generate a serial number according to the node identifier, the first timestamp and the target sequence number.

9. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program executable on the processor, and when the computer program is executed by the processor, the method according to any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.