CN112559558A - Serial number generation method and device, computing device and storage medium - Google Patents

Serial number generation method and device, computing device and storage medium Download PDF

Info

Publication number
CN112559558A
CN112559558A CN202011439561.3A CN202011439561A CN112559558A CN 112559558 A CN112559558 A CN 112559558A CN 202011439561 A CN202011439561 A CN 202011439561A CN 112559558 A CN112559558 A CN 112559558A
Authority
CN
China
Prior art keywords
numbering
serial number
application
machine
server
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
CN202011439561.3A
Other languages
Chinese (zh)
Other versions
CN112559558B (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.)
Beijing Lifangtong Payment Technology Co ltd
Original Assignee
Beijing Lifangtong Payment Technology 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 Beijing Lifangtong Payment Technology Co ltd filed Critical Beijing Lifangtong Payment Technology Co ltd
Priority to CN202011439561.3A priority Critical patent/CN112559558B/en
Publication of CN112559558A publication Critical patent/CN112559558A/en
Application granted granted Critical
Publication of CN112559558B publication Critical patent/CN112559558B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/126Character encoding

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer And Data Communications (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a serial number generation method and device, a computing device and a storage medium, wherein the serial number generation method comprises the following steps: in the starting process of a target application, a numbering request is sent to an application numbering server, so that the application numbering server queries a machine number in a numbering database according to the numbering request; receiving a machine number returned by the application number server; and generating serial number information of the target application, and generating a serial number corresponding to the target application according to the serial number information and the machine number. In the starting process of the target application, the method requests the application number server to inquire the machine number, and generates the serial number by the server after the machine number is inquired, without accessing the server, so that the serial number can be generated quickly, efficiently and accurately.

Description

Serial number generation method and device, computing device and storage medium
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a serial number generation method and apparatus, a computing device, and a storage medium.
Background
In software systems, it is often encountered to sequence applications to distinguish between different applications.
In the prior art, in a scheme for generating serial numbers based on a database, in a generation process, multiple applications access the same database, so that the pressure of the database is too high, the performance is insufficient, and the service requirement is not met.
Disclosure of Invention
The invention provides a serial number generation method and device, a computing device and a storage medium, which are used for solving the technical defects in the prior art.
The invention provides a serial number generation method, which comprises the following steps:
in the starting process of a target application, a numbering request is sent to an application numbering server, so that the application numbering server queries a machine number in a numbering database according to the numbering request;
receiving a machine number returned by the application number server;
and generating serial number information of the target application, and generating a serial number corresponding to the target application according to the serial number information and the machine number.
According to the serial number generation method provided by the invention, in the process of starting the target application, a numbering request is sent to an application numbering server, and the method comprises the following steps:
generating a numbering request in the starting process of a target application, wherein the numbering request comprises an application name, a host name and a local area network address;
and sending the numbering request to the application numbering server through a protocol link.
According to the serial number generation method provided by the invention, the application numbering server inquires a machine number in a numbering database according to the numbering request, and the method comprises the following steps:
the application numbering server inquires the current maximum machine number in a numbering database according to the application name in the numbering request, wherein the numbering database comprises n machine numbers;
if the current maximum machine number is not inquired, determining that the current machine number section is 1 to n, sequentially determining the machine numbers corresponding to the number requests in the current machine number section from small to large, and updating the n machine numbers into the next adjacent number section after the current machine number section is used up;
if the current maximum machine number is obtained through inquiry, judging whether the current maximum machine number is larger than or equal to a first threshold value or not;
if the number is larger than or equal to the first threshold value, updating the current machine number segment to be 1 to n, sequentially determining the machine numbers corresponding to the number requests in the current machine number segment from small to large, and updating the n machine numbers to be the next adjacent number segment after the current machine number segment is used;
and if the number is smaller than the first threshold value, sequentially determining the machine numbers corresponding to the number requests in the current machine number section from small to large, and updating the n machine numbers to the next adjacent number section after the current machine number section is used.
According to the serial number generation method provided by the invention, after the application numbering server receives the numbering request, the method further comprises the following steps:
the application numbering server acquires a network address for sending the numbering request;
according to the network address, an application name is used as a main key to request a distributed lock;
judging whether a distributed lock is acquired;
if yes, executing the step that the application numbering server inquires a machine number in a numbering database according to the numbering request;
if not, the request for the distributed lock is retried within the interval time period.
According to the serial number generation method provided by the invention, the generation of the serial number information of the target application comprises the following steps:
generating at least one of a sign bit, a version number, a timestamp, a clock callback identification, and a sequence number of the target application by the distributed serial number component.
According to the serial number generation method provided by the invention, the clock callback identifier is generated by the following method: acquiring a timestamp, and judging whether the currently acquired timestamp is larger than a previous timestamp; if yes, acquiring a clock callback identification bit; if not, the clock callback identification bit is increased by 1 to obtain the clock callback identification bit.
According to the serial number generation method provided by the invention, the serial number is generated by the following method:
judging whether the current timestamp and the previous timestamp are in the same second or not;
if not, setting the serial number to be 0, and marking after waiting for the next second to obtain the timestamp again;
if so, increasing the sequence number by 1, and then judging whether the sequence number after the increase by 1 is larger than a second threshold value;
if the sequence number after the self increment of 1 is larger than a second threshold value, setting the sequence number to be 0, and marking after the timestamp is acquired again in the next second;
and if the sequence number after the self increment of 1 is less than or equal to a second threshold value, outputting the sequence number.
The present invention also provides a serial number generating apparatus, comprising:
the system comprises a numbering request module, a numbering database and a numbering database, wherein the numbering request module is used for sending a numbering request to an application numbering server in the process of starting a target application so as to enable the application numbering server to inquire a machine number in the numbering database according to the numbering request;
the machine number receiving module is used for receiving the machine number returned by the application number server;
and the serial number generating module is used for generating serial number information of the target application and generating a serial number corresponding to the target application according to the serial number information and the machine number.
The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any of the serial number generation methods described above when executing the program.
The invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the serial number generation method as any one of the above.
According to the serial number generation method and device provided by the invention, in the starting process of the target application, the application number server is requested to inquire the machine number, and after the machine number is inquired, the server is not accessed any more, but the serial number is generated by the server, so that the serial number can be generated quickly, efficiently and accurately.
In addition, in the severe condition of clock dial-back, the serial number generation method generates the clock dial-back identification bit through the timestamp, and increases the clock dial-back identification bit by 1 when the current acquired timestamp is smaller than the previous timestamp, so that the uniqueness of the generated serial number can be ensured even when the clock dial-back occurs.
Drawings
In order to more clearly illustrate the technical solutions of the present invention or the prior art, the drawings needed for the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
FIG. 1 is a flow chart of a serial number generation method provided by the present invention;
FIG. 2 is a second schematic flow chart of the serial number generation method provided by the present invention;
FIG. 3 is a third schematic flow chart of a serial number generation method provided by the present invention;
FIG. 4 is a fourth schematic flowchart of the serial number generation method provided by the present invention;
FIG. 5 is a schematic structural diagram of a serial number generating apparatus provided in the present invention;
fig. 6 is a schematic structural diagram of an electronic device provided in the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the invention discloses a serial number generation method, which is shown in figure 1 and comprises the following steps:
101. in the starting process of the target application, a numbering request is sent to an application numbering server, so that the application numbering server queries a machine number in a numbering database according to the numbering request.
Wherein, the serial number database stores a T _ APP _ INFO table, and the table stores n machine numbers. And inquiring the corresponding machine number in the number database according to the application name. If the machine number cannot be inquired, setting the current machine number segment in the number database to be 1-n, and setting the machine number corresponding to the target application to be 1.
If the largest machine number segment in the current number database is found to be larger than the set threshold, for example, the threshold is set to 16383, it means that the machine number needs to be numbered from 1 again.
In actual use, generally, a plurality of nodes are arranged for each application, and each node generates a serial number correspondingly. For example, one application has 10 nodes, and when a machine number is acquired for the first time, the machine number acquired in the number database is 1-10; and when the machine number is acquired for the second time, the machine numbers 11-20 … … acquired in the number database are analogized until the machine number to be acquired is greater than the set threshold value, and the loop is started from 1 again. Since the node of each application is not larger than the set threshold, the case where the machine number is not sufficient or duplicated does not occur.
Specifically, step 101 includes:
generating a numbering request in the starting process of a target application, wherein the numbering request comprises an application name, a host name and a local area network address; and sending the numbering request to the application numbering server in a protocol link mode.
In this embodiment, in the application starting process, the numbering request may be generated by a distributed serial number component in the application.
There are many specific protocol links, such as hypertext transfer http protocol, user datagram UDP protocol, and so on.
102. And receiving the machine number returned by the application number server.
In the embodiment, the machine number is acquired in the starting process of the target application, and then the machine number is not interacted with an application number server and other external servers, so that the performance is improved, and the dependence is reduced.
103. And generating serial number information of the target application, and generating a serial number corresponding to the target application according to the serial number information and the machine number.
Wherein, the serial number information includes: at least one of a sign bit, a version number, a timestamp, a clock callback identification, and a sequence number. The sign bit, version number, time stamp, clock callback identification, serial number and machine number 6 information are stored with binary 64 bits.
1) The position of the sign bit in the binary digit is bit 64, and the default value is 0;
2) the position of the second-level timestamp in the binary digits is 35 bits to 63 bits, and the value is the acquired current system timestamp;
3) the position of the version number in the binary digits is 32-34 bits, and the value range is 1-999;
4) the machine number is located 17 th to 31 th bits in the binary digit, and the value is the value obtained in step 102.
5) The positions of the clock callback identifications in the binary digits are 15 th and 16 th bits. This identification bit is incremented by 1 when the current timestamp is found to be less than the previously acquired timestamp.
6) The position of the sequence number in the binary digit is 1 to 14 bits. The value range is 0 to 16383, the initial value is 0 in the current second, the sequence number is generated by increasing by 1 each time, and if the sequence number is 16383, the sequence number is delayed until the timestamp is acquired again to generate the sequence number in the next second.
Referring to table 1 below, table 1 shows a structural representation of a serial number.
TABLE 1
Figure BDA0002821825320000071
According to the serial number generation method provided by the embodiment of the invention, in the starting process of the target application, the server inquires the machine number by requesting the application number, and after the machine number is inquired, the server is not accessed any more, but the serial number is generated by the server, so that the serial number can be generated quickly, efficiently and accurately.
The embodiment of the invention discloses a serial number generation method, which is shown in figure 2 and comprises the following steps 201-208:
201. and in the starting process of the target application, sending a numbering request to an application numbering server.
Specifically, step 201 includes: in the starting process of the target application, a numbering request is generated through a distributed serial number component, wherein the numbering request comprises an application name, a host name and a local area network address. And the distributed serial number component sends the numbering request to an application numbering server in a hypertext transfer protocol http mode.
202. And after receiving the numbering request, the application numbering server acquires the network address for sending the numbering request.
203. And the application numbering server requests the distributed lock by taking the application name as a main key according to the network address.
In this embodiment, after receiving the numbering request, the application numbering server automatically obtains the IP address of the requester. And the application name is used as a main key, and distributed locking is performed by utilizing the setnx command characteristic of Redis to ensure the concurrence problem of machine number distribution.
To prevent the processes of multiple applications in a distributed system from interfering with each other, a distributed coordination technique is needed to schedule the processes of the applications. The core of the distributed coordination technology is realized by distributed locks.
204. The application number server determines whether a distributed lock is acquired, if so, step 205 is executed, and if not, step 206 is executed.
205. The application numbering server queries the machine number in the numbering database according to the numbering request and then performs step 207.
Specifically, referring to FIG. 3, step 205 includes the following steps 301-305:
301. the application number server judges whether to inquire the current maximum machine number in a number database according to the application name in the number request, if not, the step 302 is executed; if yes, go to step 303.
Wherein, the serial number database comprises n machine serial numbers.
302. If the current maximum machine number is not found, the current machine number segment is determined to be 1 to n, and then step 305 is executed.
303. If the current maximum machine number is obtained through inquiry, whether the current maximum machine number is larger than or equal to a first threshold value is judged, if yes, step 304 is executed, and if not, step 305 is executed.
304. The current machine number segments are updated to 1 to n and then step 305 is performed.
305. And sequentially determining the machine numbers corresponding to the number requests in the current machine number section from small to large, and updating the n machine numbers to the next adjacent number section after the current machine number section is used.
Taking n as 10 as an example, the first number segment is 1-10, the next adjacent number segment is 11-20, … … and so on. When the maximum number of the n machine numbers exceeds the first threshold, it means that the machine number should restart counting.
The first threshold value may be set according to actual requirements, for example, 16383.
During specific setting, the number of nodes in one application is less than or equal to n, and the first threshold value should not exceed the number of nodes in one application, so that when the serial number of the applied node is updated, the situation that the machine number required for updating after each restart exceeds the first threshold value does not occur.
206. The application number server retries requesting the distributed lock for the interval period and performs step 204.
207. And the target application receives the machine number returned by the application number server.
The target application is provided with a distributed serial number component, and the function of receiving the machine serial number and generating the serial number in the subsequent steps can be realized through the component.
208. The target application generates a sign bit, a version number, a timestamp, a clock callback identifier and a serial number of the target application through the distributed serial number component, and generates a serial number corresponding to the target application according to the sign bit, the version number, the timestamp, the clock callback identifier, the serial number and a machine number of the target application through the distributed serial number component.
Wherein, the clock callback identifier is generated through the following steps S281 to S283:
s281, acquiring a timestamp, and judging whether the currently acquired timestamp is larger than a previous timestamp;
s282, if yes, acquiring a clock callback identification bit;
and S283, if not, increasing the clock callback identification bit by 1 to obtain the clock callback identification bit.
Through the generation of the clock callback identification bit, the uniqueness of the serial number can be guaranteed under the severe condition that the machine clock generates callback.
Referring to fig. 4, the serial number is generated through the following steps 401 to 406:
401. and judging whether the current time stamp and the previous time stamp are in the same second, if not, executing the step 402, and if so, executing the step 403.
402. And setting the sequence number to be 0, and marking after the timestamp is acquired again in the next second.
It should be explained that for the case that the time stamps are not in the same second, the two sequence numbers should belong to different serial number sequences. Through the processing of step 402, sequence numbers which do not belong to the same serial number sequence are prevented from being generated in the same serial number sequence, and the accuracy of serial number generation is ensured.
403. The sequence number is incremented by 1.
404. And judging whether the sequence number after the self increment of 1 is larger than a second threshold value.
405. And if the sequence number after the self increment of 1 is larger than a second threshold value, setting the sequence number to be 0, and marking after waiting for reacquiring the timestamp in the next second.
Wherein the second threshold may be 16383.
406. And if the sequence number after the self increment of 1 is less than or equal to a second threshold value, outputting the sequence number.
In the serial number generation method provided by this embodiment, in the process of starting the target application, the application number server is requested to query the machine number, and after the machine number is queried, the server is not accessed any more, but the serial number is generated by the server, so that the serial number can be generated quickly, efficiently and accurately.
In addition, in the severe condition of clock dial-back, the serial number generation method generates the clock dial-back identification bit through the timestamp, and increases the clock dial-back identification bit by 1 when the current acquired timestamp is smaller than the previous timestamp, so that the uniqueness of the generated serial number can be ensured even when the clock dial-back occurs.
The serial number generating device provided by the present invention is described below, and the serial number generating device described below and the serial number generating method described above may be referred to in correspondence with each other.
The present embodiment discloses a serial number generation apparatus, see fig. 5, including:
a numbering request module 501, configured to send a numbering request to an application numbering server in a process of starting a target application;
a query module 502, configured to query, by the application numbering server, a machine number in a number database according to the numbering request;
a machine number receiving module 503, configured to receive a machine number returned by the application number server;
the serial number generation module 504 is configured to generate serial number information of a target application, and generate a serial number corresponding to the target application according to the serial number information and the machine number.
Optionally, the numbering request module 501 is specifically configured to: generating a numbering request in the starting process of a target application, wherein the numbering request comprises an application name, a host name and a local area network address;
and sending the numbering request to the application numbering server through a protocol link.
Optionally, the query module 502 is specifically configured to:
the application numbering server inquires the current maximum machine number in a numbering database according to the application name in the numbering request, wherein the numbering database comprises n machine numbers;
if the current maximum machine number is not inquired, determining that the current machine number section is 1 to n, sequentially determining the machine numbers corresponding to the number requests in the current machine number section from small to large, and updating the n machine numbers into the next adjacent number section after the current machine number section is used up;
if the current maximum machine number is obtained through inquiry, judging whether the current maximum machine number is larger than or equal to a first threshold value or not;
if the number is larger than or equal to the first threshold value, updating the current machine number segment to be 1 to n, sequentially determining the machine numbers corresponding to the number requests in the current machine number segment from small to large, and updating the n machine numbers to be the next adjacent number segment after the current machine number segment is used;
and if the number is smaller than the first threshold value, sequentially determining the machine numbers corresponding to the number requests in the current machine number section from small to large, and updating the n machine numbers to the next adjacent number section after the current machine number section is used.
Optionally, the apparatus further comprises:
an address acquisition module, configured to acquire, by the application numbering server, a network address from which the numbering request is sent;
the distributed lock request module is used for requesting a distributed lock by taking the application name as a main key according to the network address;
the judging module is used for judging whether the distributed lock is acquired, if so, executing the inquiring module 502, and if not, executing a retry request module;
a retry request module to retry requesting the distributed lock within an interval period.
Optionally, the serial number generating module 504 is specifically configured to: and generating at least one of a sign bit, a version number, a timestamp, a clock callback identifier and a sequence number of the target application by the distributed serial number component.
Optionally, the apparatus further includes a clock callback identification module, configured to:
acquiring a timestamp, and judging whether the currently acquired timestamp is larger than a previous timestamp;
if yes, acquiring a clock callback identification bit;
if not, the clock callback identification bit is increased by 1 to obtain the clock callback identification bit.
Optionally, the apparatus further includes a serial number generation module, configured to:
judging whether the current timestamp and the previous timestamp are in the same second or not;
if not, setting the serial number to be 0, and marking after waiting for the next second to obtain the timestamp again;
if so, increasing the sequence number by 1, and then judging whether the sequence number after the increase by 1 is larger than a second threshold value;
if the sequence number after the self increment of 1 is larger than a second threshold value, setting the sequence number to be 0, and marking after the timestamp is acquired again in the next second;
and if the sequence number after the self increment of 1 is less than or equal to a second threshold value, outputting the sequence number.
The serial number generation device provided by the invention requests the application number server to inquire the machine number in the starting process of the target application, and generates the serial number by the serial number generation device without accessing the server after the machine number is inquired, so that the serial number can be generated quickly, efficiently and accurately.
Fig. 6 illustrates a physical structure diagram of an electronic device, which may include, as shown in fig. 6: a processor (processor)610, a communication Interface (Communications Interface)620, a memory (memory)630 and a communication bus 640, wherein the processor 610, the communication Interface 620 and the memory 830 communicate with each other via the communication bus 640. The processor 610 may invoke logic instructions in the memory 630 to perform a serial number generation method comprising:
in the starting process of a target application, a numbering request is sent to an application numbering server, so that the application numbering server queries a machine number in a numbering database according to the numbering request;
receiving a machine number returned by the application number server;
and generating serial number information of the target application, and generating a serial number corresponding to the target application according to the serial number information and the machine number.
In addition, the logic instructions in the memory 630 may be implemented in software functional units and stored in a computer readable storage medium when the logic instructions are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, which when executed by a computer, enable the computer to perform the serial number generation method provided by the above methods, including:
in the starting process of a target application, a numbering request is sent to an application numbering server, so that the application numbering server queries a machine number in a numbering database according to the numbering request;
receiving a machine number returned by the application number server;
and generating serial number information of the target application, and generating a serial number corresponding to the target application according to the serial number information and the machine number.
In yet another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored, the computer program being implemented by a processor to perform the serial number generation methods provided above, including:
in the starting process of a target application, a numbering request is sent to an application numbering server, so that the application numbering server queries a machine number in a numbering database according to the numbering request;
receiving a machine number returned by the application number server;
and generating serial number information of the target application, and generating a serial number corresponding to the target application according to the serial number information and the machine number.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A serial number generation method, comprising:
in the starting process of a target application, a numbering request is sent to an application numbering server, so that the application numbering server queries a machine number in a numbering database according to the numbering request;
receiving a machine number returned by the application number server;
and generating serial number information of the target application, and generating a serial number corresponding to the target application according to the serial number information and the machine number.
2. The serial number generation method of claim 1, wherein sending a numbering request to an application numbering server during the start of a target application comprises:
generating a numbering request in the starting process of a target application, wherein the numbering request comprises an application name, a host name and a local area network address;
and sending the numbering request to the application numbering server through a protocol link.
3. The serial number generation method of claim 2, wherein the application numbering server queries a machine number in a numbering database according to the numbering request, and comprises:
the application numbering server inquires the current maximum machine number in a numbering database according to the application name in the numbering request, wherein the numbering database comprises n machine numbers;
if the current maximum machine number is not inquired, determining that the current machine number section is 1 to n, sequentially determining the machine numbers corresponding to the number requests in the current machine number section from small to large, and updating the n machine numbers into the next adjacent number section after the current machine number section is used up;
if the current maximum machine number is obtained through inquiry, judging whether the current maximum machine number is larger than or equal to a first threshold value or not;
if the number is larger than or equal to the first threshold value, updating the current machine number segment to be 1 to n, sequentially determining the machine numbers corresponding to the number requests in the current machine number segment from small to large, and updating the n machine numbers to be the next adjacent number segment after the current machine number segment is used;
and if the number is smaller than the first threshold value, sequentially determining the machine numbers corresponding to the number requests in the current machine number section from small to large, and updating the n machine numbers to the next adjacent number section after the current machine number section is used.
4. The serial number generation method of claim 2, wherein after the application numbering server receives the numbering request, the method further comprises:
the application numbering server acquires a network address for sending the numbering request;
according to the network address, an application name is used as a main key to request a distributed lock;
judging whether a distributed lock is acquired;
if yes, executing the step that the application numbering server inquires a machine number in a numbering database according to the numbering request;
if not, the request for the distributed lock is retried within the interval time period.
5. The serial number generation method according to claim 1, wherein generating serial number information of the target application comprises:
generating at least one of a sign bit, a version number, a timestamp, a clock callback identification, and a sequence number of the target application by the distributed serial number component.
6. The serial number generation method according to claim 5, wherein the clock callback identifier is generated by:
acquiring a timestamp, and judging whether the currently acquired timestamp is larger than a previous timestamp;
if yes, acquiring a clock callback identification bit;
if not, the clock callback identification bit is increased by 1 to obtain the clock callback identification bit.
7. The serial number generation method according to claim 5, wherein the serial number is generated by:
judging whether the current timestamp and the previous timestamp are in the same second or not;
if not, setting the serial number to be 0, and marking after waiting for the next second to obtain the timestamp again;
if so, increasing the sequence number by 1, and then judging whether the sequence number after the increase by 1 is larger than a second threshold value;
if the sequence number after the self increment of 1 is larger than a second threshold value, setting the sequence number to be 0, and marking after the timestamp is acquired again in the next second;
and if the sequence number after the self increment of 1 is less than or equal to a second threshold value, outputting the sequence number.
8. A serial number generation apparatus, comprising:
the system comprises a numbering request module, a numbering database and a numbering database, wherein the numbering request module is used for sending a numbering request to an application numbering server in the process of starting a target application so as to enable the application numbering server to inquire a machine number in the numbering database according to the numbering request;
the machine number receiving module is used for receiving the machine number returned by the application number server;
and the serial number generating module is used for generating serial number information of the target application and generating a serial number corresponding to the target application according to the serial number information and the machine number.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the steps of the serial number generation method according to any one of claims 1 to 7 are implemented when the program is executed by the processor.
10. A non-transitory computer readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the serial number generation method according to any one of claims 1 to 7.
CN202011439561.3A 2020-12-07 2020-12-07 Method and device for generating serial numbers, computing equipment and storage medium Active CN112559558B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011439561.3A CN112559558B (en) 2020-12-07 2020-12-07 Method and device for generating serial numbers, computing equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011439561.3A CN112559558B (en) 2020-12-07 2020-12-07 Method and device for generating serial numbers, computing equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112559558A true CN112559558A (en) 2021-03-26
CN112559558B CN112559558B (en) 2024-04-09

Family

ID=75060588

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011439561.3A Active CN112559558B (en) 2020-12-07 2020-12-07 Method and device for generating serial numbers, computing equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112559558B (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113065034A (en) * 2021-03-29 2021-07-02 上海安畅网络科技股份有限公司 Distributed system number generation method and system
CN113254447A (en) * 2021-05-27 2021-08-13 平安普惠企业管理有限公司 ID generation method, device, electronic equipment and storage medium
CN113360316A (en) * 2021-06-01 2021-09-07 苏州震坤科技有限公司 Product serial number coding device, coding method and method for updating product serial number code
CN113596193A (en) * 2021-07-27 2021-11-02 京东科技控股股份有限公司 Distributed ID processing method, system, storage medium and electronic equipment
CN114244806A (en) * 2022-02-28 2022-03-25 深圳市城市交通规划设计研究中心股份有限公司 Distributed micro-service system number sending method, computer and storage medium
CN115729978A (en) * 2022-11-24 2023-03-03 湖南长银五八消费金融股份有限公司 Serial number generation method and device, computer equipment and storage medium

Citations (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102609477A (en) * 2012-01-19 2012-07-25 北京神州数码思特奇信息技术股份有限公司 Method for implementing serial number generator
US20140019480A1 (en) * 2012-07-12 2014-01-16 Salesforce.Com, Inc. Facilitating dynamic generation and customziation of software applications at cleint computing devices using server metadata in an on-demand services environment
CN105072160A (en) * 2015-07-17 2015-11-18 联动优势科技有限公司 Serial number generating method and device, and a server
US20160063015A1 (en) * 2014-08-28 2016-03-03 Kent Andrew Edmonds Systems and methods for providing complimentary content on linked machines
US20170300552A1 (en) * 2016-04-18 2017-10-19 Amazon Technologies, Inc. Versioned hierarchical data structures in a distributed data store
CN108897628A (en) * 2018-05-25 2018-11-27 北京奇艺世纪科技有限公司 A kind of implementation method of distributed lock, device and electronic equipment
CN109740120A (en) * 2018-12-14 2019-05-10 深圳壹账通智能科技有限公司 The generation method of unique identification, device, computer equipment under distributed environment
US20190171650A1 (en) * 2017-12-01 2019-06-06 Chavdar Botev System and method to improve data synchronization and integration of heterogeneous databases distributed across enterprise and cloud using bi-directional transactional bus of asynchronous change data system
WO2019218479A1 (en) * 2018-05-14 2019-11-21 平安科技(深圳)有限公司 Method and device for sending information
CN110619114A (en) * 2019-09-26 2019-12-27 北京明略软件***有限公司 Serial number generation method and system
CN111083228A (en) * 2019-12-24 2020-04-28 腾讯云计算(北京)有限责任公司 Identification number generation method and device and electronic equipment
CN111125569A (en) * 2019-12-25 2020-05-08 北京同邦卓益科技有限公司 Data identifier generation method and device, electronic equipment and medium
CN111414379A (en) * 2020-03-20 2020-07-14 深圳前海微众银行股份有限公司 Serial number generation method, device, equipment and computer readable storage medium
CN111680052A (en) * 2020-06-02 2020-09-18 深圳前海微众银行股份有限公司 Method and device for generating identity identification number
CN111831757A (en) * 2020-06-09 2020-10-27 时时同云科技(成都)有限责任公司 Method and device for generating and managing distributed global unique identification information
CN111831453A (en) * 2020-07-24 2020-10-27 中国工商银行股份有限公司 Information processing method, information processing apparatus, electronic device, and medium

Patent Citations (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102609477A (en) * 2012-01-19 2012-07-25 北京神州数码思特奇信息技术股份有限公司 Method for implementing serial number generator
US20140019480A1 (en) * 2012-07-12 2014-01-16 Salesforce.Com, Inc. Facilitating dynamic generation and customziation of software applications at cleint computing devices using server metadata in an on-demand services environment
US20160063015A1 (en) * 2014-08-28 2016-03-03 Kent Andrew Edmonds Systems and methods for providing complimentary content on linked machines
CN105072160A (en) * 2015-07-17 2015-11-18 联动优势科技有限公司 Serial number generating method and device, and a server
US20170300552A1 (en) * 2016-04-18 2017-10-19 Amazon Technologies, Inc. Versioned hierarchical data structures in a distributed data store
US20190171650A1 (en) * 2017-12-01 2019-06-06 Chavdar Botev System and method to improve data synchronization and integration of heterogeneous databases distributed across enterprise and cloud using bi-directional transactional bus of asynchronous change data system
WO2019218479A1 (en) * 2018-05-14 2019-11-21 平安科技(深圳)有限公司 Method and device for sending information
CN108897628A (en) * 2018-05-25 2018-11-27 北京奇艺世纪科技有限公司 A kind of implementation method of distributed lock, device and electronic equipment
CN109740120A (en) * 2018-12-14 2019-05-10 深圳壹账通智能科技有限公司 The generation method of unique identification, device, computer equipment under distributed environment
CN110619114A (en) * 2019-09-26 2019-12-27 北京明略软件***有限公司 Serial number generation method and system
CN111083228A (en) * 2019-12-24 2020-04-28 腾讯云计算(北京)有限责任公司 Identification number generation method and device and electronic equipment
CN111125569A (en) * 2019-12-25 2020-05-08 北京同邦卓益科技有限公司 Data identifier generation method and device, electronic equipment and medium
CN111414379A (en) * 2020-03-20 2020-07-14 深圳前海微众银行股份有限公司 Serial number generation method, device, equipment and computer readable storage medium
CN111680052A (en) * 2020-06-02 2020-09-18 深圳前海微众银行股份有限公司 Method and device for generating identity identification number
CN111831757A (en) * 2020-06-09 2020-10-27 时时同云科技(成都)有限责任公司 Method and device for generating and managing distributed global unique identification information
CN111831453A (en) * 2020-07-24 2020-10-27 中国工商银行股份有限公司 Information processing method, information processing apparatus, electronic device, and medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
杨宝明;: "管理信息***中流水号生成方法与实现", 计算机工程与设计, no. 12 *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113065034A (en) * 2021-03-29 2021-07-02 上海安畅网络科技股份有限公司 Distributed system number generation method and system
CN113065034B (en) * 2021-03-29 2022-11-18 上海安畅网络科技股份有限公司 Distributed system number generation method and system
CN113254447A (en) * 2021-05-27 2021-08-13 平安普惠企业管理有限公司 ID generation method, device, electronic equipment and storage medium
CN113360316A (en) * 2021-06-01 2021-09-07 苏州震坤科技有限公司 Product serial number coding device, coding method and method for updating product serial number code
CN113596193A (en) * 2021-07-27 2021-11-02 京东科技控股股份有限公司 Distributed ID processing method, system, storage medium and electronic equipment
CN113596193B (en) * 2021-07-27 2024-01-16 京东科技控股股份有限公司 Distributed ID processing method, system, storage medium and electronic equipment
CN114244806A (en) * 2022-02-28 2022-03-25 深圳市城市交通规划设计研究中心股份有限公司 Distributed micro-service system number sending method, computer and storage medium
CN115729978A (en) * 2022-11-24 2023-03-03 湖南长银五八消费金融股份有限公司 Serial number generation method and device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN112559558B (en) 2024-04-09

Similar Documents

Publication Publication Date Title
CN112559558A (en) Serial number generation method and device, computing device and storage medium
US7774826B1 (en) System and method for determining effective policy profiles in a client-server architecture
CN108491252B (en) Distributed transaction processing method and distributed system
US20080259922A1 (en) Intersection-based configuration management
CN110543324B (en) Plug-in increment updating method and device for application program
US8554889B2 (en) Method, system and apparatus for managing computer identity
CN108076081A (en) Method, device and system for synchronizing service data
CN103905512A (en) Data processing method and equipment
CN111866197B (en) Domain name resolution method and system
CN112328325A (en) Execution method and device of model file, terminal equipment and storage medium
CN110955460A (en) Service process starting method and device, electronic equipment and storage medium
US20150100545A1 (en) Distributed database system and a non-transitory computer readable medium
CN110543465A (en) directory operation method and device, computer equipment and storage medium
CN115858590A (en) Domain name query request processing method, computer device, apparatus, medium, and product
CN113285933A (en) User access control method and device, electronic equipment and storage medium
US8719822B2 (en) Method and system for storing and referencing partial complex resources using object identifiers in a printing system
JP2014524210A (en) Generate variable length nonce
CN113821495A (en) Database cluster implementation system and method
CN111614750A (en) Data updating method, system, equipment and storage medium
US20140280347A1 (en) Managing Digital Files with Shared Locks
CN110839085A (en) Instruction management method, instruction management device, electronic equipment and storage medium
CN117539649B (en) Identification management method, equipment and readable storage medium of distributed cluster
CN117076492A (en) Service data query method, device, equipment and storage medium
CN109660390B (en) Information updating method and system based on external inquiry DNS server
CN112732757B (en) Method, system, device, equipment and storage medium for processing degraded data

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