CN112559558B - Method and device for generating serial numbers, computing equipment and storage medium - Google Patents

Method and device for generating serial numbers, computing equipment and storage medium Download PDF

Info

Publication number
CN112559558B
CN112559558B CN202011439561.3A CN202011439561A CN112559558B CN 112559558 B CN112559558 B CN 112559558B CN 202011439561 A CN202011439561 A CN 202011439561A CN 112559558 B CN112559558 B CN 112559558B
Authority
CN
China
Prior art keywords
serial number
numbering
application
machine
request
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.)
Active
Application number
CN202011439561.3A
Other languages
Chinese (zh)
Other versions
CN112559558A (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

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 process of starting 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 method, the application numbering server is requested to inquire the machine number in the process of starting the target application, and after the machine number is inquired, the server is not accessed any more, and the serial number is generated by the application numbering server, so that the serial number can be generated rapidly, efficiently and accurately.

Description

Method and device for generating serial numbers, computing equipment and storage medium
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a method and apparatus for generating a serial number, a computing device, and a storage medium.
Background
In software systems, it is often the case that a serial number is set to an application to distinguish between different applications.
In the prior art, in a scheme for generating serial numbers based on a database, multiple applications can access the same database in the generation process, so that the pressure of the database is overlarge, the performance is insufficient, and the service requirement is not met.
Disclosure of Invention
The invention provides a serial number generation method and device, computing equipment 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 process of starting 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 method for generating the serial number provided by the invention, in the process of starting the target application, a serial number request is sent to an application serial number server, and the method comprises the following steps:
generating a numbering request in the process of starting 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 method for generating the serial number provided by the invention, the application numbering server queries the machine number in the numbering database according to the numbering request, and the method comprises the following steps:
the application numbering server queries the current largest 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 according to the sequence from small to large, and updating the n machine numbers into the next adjacent number section after the current machine number section is used;
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 request is greater than or equal to a first threshold value, updating the current machine number section to 1-n, sequentially determining the machine numbers corresponding to the number requests in the current machine number section according to the sequence from small to large, and updating n machine numbers to the next adjacent number section after the current machine number section is used;
if the number is smaller than the first threshold value, the machine numbers corresponding to the number requests are sequentially determined in the current machine number section from small to large, and after the current machine number section is used, the n machine numbers are updated to be the next adjacent number section.
According to the method for generating the serial number provided by the invention, after the application numbering server receives the numbering request, the method further comprises the following steps:
the application numbering server obtains a network address for sending the numbering request;
requesting a distributed lock by taking an application name as a primary key according to the network address;
judging whether a distributed lock is acquired or not;
if yes, executing the step that the application numbering server inquires the machine number in a numbering database according to the numbering request;
if not, retrying to request the distributed lock in the interval time period.
According to the serial number generation method provided by the invention, serial number information of the target application is generated, and the serial number generation method comprises the following steps:
at least one of a sign bit, a version number, a timestamp, a clock callback identification and a serial number of the target application is generated through the distributed serial number component.
According to the method for generating the serial number provided by the invention, the clock callback identifier is generated by the following method: acquiring a time stamp, and judging whether the currently acquired time stamp is larger than the previous time stamp; if yes, acquiring a clock callback identification bit; if not, the clock callback identification bit is automatically increased by 1, and the clock callback identification bit is obtained.
According to the serial number generation method provided by the invention, the serial number is generated by the following method:
judging whether the current time stamp and the previous time stamp are in the same second or not;
if not, setting the serial number to 0, and marking after waiting for the next second to reacquire the time stamp;
if yes, the sequence number is increased by 1, and then whether the sequence number after the automatic increase of 1 is larger than a second threshold value is judged;
if the serial number after the self-increment of 1 is larger than a second threshold value, setting the serial number to 0, and marking after waiting for the next second to reacquire the time stamp;
and if the sequence number after the self-increment of 1 is smaller than or equal to a second threshold value, outputting the sequence number.
The invention also provides a serial number generating device, which comprises:
the system comprises a numbering request module, a numbering database and a numbering server, wherein the numbering request module is used for sending a numbering request to the application numbering server in the process of starting a target application so that the application numbering server queries the 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 generation 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 invention also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and operable on the processor, wherein the processor implements the steps of any of the serial number generation methods described above when executing the program.
The present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the serial number generation method as described in any one of the above.
According to the serial number generation method and device, in the process of starting 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, and the serial number is generated by the server, so that the serial number can be generated rapidly, efficiently and accurately.
In addition, in the method for generating the serial number, the clock callback identification bit is generated through the time stamp, and the clock callback identification bit is automatically increased by 1 under the condition that the currently acquired time stamp is smaller than the previous time stamp, so that the uniqueness of the generated serial number can be ensured even when the clock callback occurs.
Drawings
In order to more clearly illustrate the invention or the technical solutions of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are some embodiments of the invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a serial number generation method provided by the invention;
FIG. 2 is a second flow chart of the serial number generation method according to the present invention;
FIG. 3 is a third flow chart of the serial number generation method according to the present invention;
FIG. 4 is a flow chart of a serial number generation method provided by the invention;
fig. 5 is a schematic structural diagram of a serial number generating device provided by the invention;
fig. 6 is a schematic structural diagram of an electronic device provided by the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The embodiment of the invention discloses a serial number generation method, which comprises the following steps of:
101. and in the process of starting the target application, sending a numbering request to an application numbering server so that the application numbering server queries the machine number in a numbering database according to the numbering request.
Wherein, the number database stores a T_APP_INFO table, and the table stores n machine numbers. And according to the application name, inquiring the corresponding machine number in a number database. If the machine number is not found, the current machine number section in the number database is set to 1-n, and the machine number corresponding to the target application is set to 1.
If the largest machine number segment in the current number database is found to be greater than the set threshold, for example, the threshold is set to 16383, the machine number needs to be numbered again from 1.
In actual use, typically, each application arranges a plurality of nodes, each of which generates a serial number accordingly. For example, an application has 10 nodes, and when the machine number is acquired for the first time, the machine number acquired in the number database is 1-10; in the second acquisition of the machine number, the machine numbers obtained in the number database are 11-20 … …, and so on, until the machine number to be obtained is greater than the set threshold, the cycle is restarted from 1. Since the node of each application is not greater than the set threshold, there is no situation where the machine number is not used enough or is repeated.
Specifically, step 101 includes:
generating a numbering request in the process of starting 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, during the application starting process, the serial number request may be generated by the distributed serial number component in the application.
There are various specific protocol links, such as hypertext transfer http protocol, user datagram UDP protocol, etc.
102. And receiving the machine number returned by the application number server.
In this embodiment, the machine number is acquired during the starting process of the target application, and then interaction with an external server such as an application number server is no longer performed, so that performance is improved, and 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 serial number. The binary 64 bits are used to store the 6 information of sign bit, version number, timestamp, clock callback identification, serial number and machine number.
1) The position of the sign bit in the binary digit is the 64 th bit, 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 to 34 bits, and the value range is 1 to 999;
4) The machine number is located from bit 17 to bit 31 in the binary digit and the value is the value obtained in step 102.
5) The positions of the clock callback identification in the binary digits are the 15 th and 16 th bits. When the current timestamp is found to be smaller than the previously acquired timestamp, this identification bit is incremented by 1.
6) The position of the serial 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 serial number is automatically increased by 1 each time, and if the serial number is equal to 16383, the serial number is delayed until the next second to reacquire the time stamp to generate the serial number.
Referring to Table 1 below, table 1 shows a structural representation of a serial number.
TABLE 1
According to the serial number generation method provided by the embodiment of the invention, in the process of starting the target application, the machine number is queried through the request application number server, and after the machine number is queried, the server is not accessed any more, and the serial number is generated by the request application number server, so that the serial number can be generated rapidly, efficiently and accurately.
The embodiment of the invention discloses a serial number generation method, which is shown in fig. 2 and comprises the following steps 201 to 208:
201. and in the process of starting the target application, sending a numbering request to an application numbering server.
Specifically, step 201 includes: in the process of starting 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. The distributed serial number component sends the numbering request to the application numbering server in the manner of hypertext transfer protocol (http).
202. After receiving the numbering request, the application numbering server obtains 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 primary key according to the network address.
In this embodiment, the application numbering server automatically obtains the IP address of the requester after receiving the numbering request. And the application name is used as a primary key, and the distributed lock is performed by utilizing the setnx command characteristic of Redis so as to ensure that the machine number is distributed and the problem is solved.
In order to prevent interference between processes of multiple applications in a distributed system, a distributed coordination technique is required to schedule the processes of the applications. The core of the distributed coordination technology is realized through distributed locks.
204. The application numbering 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 numbering database for machine numbers 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 numbering server judges whether to query the current largest machine number in a numbering database according to the application name in the numbering request, and if not, the step 302 is executed; if yes, go to step 303.
Wherein the numbering database comprises n machine 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 performed.
303. If the current maximum machine number is obtained, it is determined whether the current maximum machine number is greater than or equal to the first threshold, if yes, step 304 is executed, and if not, step 305 is executed.
304. The current machine number segment is 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 according to the order from small to large, and updating the n machine numbers into the next adjacent number section after the current machine number section is used.
Taking n=10 as an example, the first numbered segment is 1 to 10, the next adjacent numbered segment is 11 to 20, … …, and so on. When the largest number of the n machine numbers exceeds the first threshold, this means that the machine numbers should restart counting.
The first threshold may be set according to actual requirements, for example, 16383.
When the method is specifically set, the number of the nodes in one application is smaller than or equal to n, and the first threshold value should not exceed the number of the nodes in one application, so that the situation that the machine number required for updating after restarting each time exceeds the first threshold value can not occur when the nodes of the application update the serial number.
206. The application numbering server retries requesting the distributed lock for an interval period and performs step 204.
207. And the target application receives the machine number returned by the application number server.
The distributed serial number component is arranged in the target application, and can be used for receiving the machine number and generating the serial number in the subsequent step.
208. And the target application generates a sign bit, a version number, a time stamp, 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 through the distributed serial number component according to the sign bit, the version number, the time stamp, the clock callback identifier, the serial number and the machine number of the target application.
The clock callback identifier is generated by the following steps S281 to S283:
s281, acquiring a time stamp, and judging whether the currently acquired time stamp is larger than the previous time stamp;
s282, if yes, acquiring a clock callback identification bit;
and S283, if not, the clock callback identification bit is automatically increased by 1, and the clock callback identification bit is obtained.
The clock callback identification bit is generated, so that the uniqueness of the serial number can be guaranteed under the severe condition that the machine clock is callback.
Wherein, referring to fig. 4, the serial number is generated by the following steps 401-406:
401. whether the current time stamp is within the same second as the previous time stamp is determined, if not, step 402 is executed, and if yes, step 403 is executed.
402. The serial number is set to 0 and the marking is performed after waiting for the next second to reacquire the timestamp.
It should be explained that for the case that the time stamps are not in the same second, the two serial numbers should belong to different serial numbers. Through the processing of step 402, the serial 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. If the serial number after the self-increment of 1 is larger than the second threshold value, the serial number is set to 0, and the marking is carried out after the next second of re-acquisition of the time stamp is waited.
Wherein the second threshold may be 16383.
406. And if the sequence number after the self-increment of 1 is smaller than or equal to a second threshold value, outputting the sequence number.
According to the serial number generation method, in the process of starting 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, the serial number is generated by the server, so that the serial number can be generated rapidly, efficiently and accurately.
In addition, in the method for generating the serial number, the clock callback identification bit is generated through the time stamp, and the clock callback identification bit is automatically increased by 1 under the condition that the currently acquired time stamp is smaller than the previous time stamp, so that the uniqueness of the generated serial number can be ensured even when the clock callback occurs.
The serial number generating device provided by the invention is described below, and the serial number generating device described below and the serial number generating method described above can be correspondingly referred to each other.
The embodiment discloses a serial number generating device, see fig. 5, including:
a numbering request module 501, configured to send a numbering request to an application numbering server during a process of starting a target application;
the query module 502 is configured to query a machine number in a number database according to the number request by using the number server;
a machine number receiving module 503, configured to receive a machine number returned by the application number server;
and 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 process of starting 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 queries the current largest 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 according to the sequence from small to large, and updating the n machine numbers into the next adjacent number section after the current machine number section is used;
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 request is greater than or equal to a first threshold value, updating the current machine number section to 1-n, sequentially determining the machine numbers corresponding to the number requests in the current machine number section according to the sequence from small to large, and updating n machine numbers to the next adjacent number section after the current machine number section is used;
if the number is smaller than the first threshold value, the machine numbers corresponding to the number requests are sequentially determined in the current machine number section from small to large, and after the current machine number section is used, the n machine numbers are updated to be the next adjacent number section.
Optionally, the apparatus further comprises:
the address acquisition module is used for acquiring a network address for sending the numbering request by the application numbering server;
the distributed lock request module is used for requesting the distributed lock by taking the application name as a primary key according to the network address;
the judging module is configured to judge whether a distributed lock is obtained, if yes, execute the querying module 502, and if no, execute the retry request module;
and the retry request module is used for retrying to request the distributed lock in an interval time period.
Optionally, the serial number generation module 504 is specifically configured to: and generating at least one of sign bit, version number, time stamp, clock callback identifier and serial number of the target application through the distributed serial number component.
Optionally, the device further comprises a clock callback identification module, configured to:
acquiring a time stamp, and judging whether the currently acquired time stamp is larger than the previous time stamp;
if yes, acquiring a clock callback identification bit;
if not, the clock callback identification bit is automatically increased by 1, and the clock callback identification bit is obtained.
Optionally, the apparatus further includes a serial number generation module configured to:
judging whether the current time stamp and the previous time stamp are in the same second or not;
if not, setting the serial number to 0, and marking after waiting for the next second to reacquire the time stamp;
if yes, the sequence number is increased by 1, and then whether the sequence number after the automatic increase of 1 is larger than a second threshold value is judged;
if the serial number after the self-increment of 1 is larger than a second threshold value, setting the serial number to 0, and marking after waiting for the next second to reacquire the time stamp;
and if the sequence number after the self-increment of 1 is smaller than or equal to a second threshold value, outputting the sequence number.
According to the serial number generation device, in the process of starting 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, and the serial number is generated by the server, so that the serial number can be generated rapidly, efficiently and accurately.
Fig. 6 illustrates a physical schematic diagram of an electronic device, as shown in fig. 6, which may include: processor 610, communication interface (Communications Interface), memory 630, and communication bus 640, wherein processor 610, communication interface 620, and memory 830 communicate with each other via communication bus 640. The processor 610 may invoke logic instructions in the memory 630 to perform a method of serial number generation comprising:
in the process of starting 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.
Further, the logic instructions in the memory 630 may be implemented in the form of software functional units and stored in a computer-readable storage medium when sold or used as a stand-alone product. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform 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, random Access Memory), a magnetic disk, or an optical disk, or 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 method of generating a serial number provided by the above methods, comprising:
in the process of starting 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 still another aspect, the present invention further provides a non-transitory computer readable storage medium having stored thereon a computer program, which when executed by a processor is implemented to perform the above-provided serial number generation methods, including:
in the process of starting 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 apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the 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 scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (8)

1. The serial number generation method is characterized by comprising the following steps of:
in the process of starting 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; the numbering request is generated through a distributed serial number component in the target application in the starting process of the target application;
receiving a machine number returned by the application number server through the distributed serial number component;
generating serial number information of a target application through the distributed serial number component, and generating a serial number corresponding to the target application through the distributed serial number component according to the serial number information and the machine number;
generating serial number information of the target application through the distributed serial number component comprises the following steps:
generating at least one of a sign bit, a version number, a time stamp, a clock callback identifier and a serial number of the target application through a distributed serial number component;
generating, by the distributed serial number component, a serial number corresponding to the target application according to the serial number information and the machine number, including:
generating a serial number corresponding to the target application through the distributed serial number component according to the sign bit, version number, time stamp, clock callback identifier, serial number and the machine number of the target application;
the application numbering server receives the numbering request, and the method further comprises:
the application numbering server obtains a network address for sending the numbering request;
requesting a distributed lock by taking an application name as a primary key according to the network address;
judging whether a distributed lock is acquired or not;
if yes, executing the step that the application numbering server inquires the machine number in a numbering database according to the numbering request;
if not, retrying to request the distributed lock in the interval time period.
2. The method for generating a serial number according to claim 1, wherein transmitting a serial number request to the application number server in the process of starting the target application includes:
generating a numbering request in the process of starting 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 running number generation method according to claim 2, wherein the application numbering server querying a machine number in a numbering database according to the numbering request, comprising:
the application numbering server queries the current largest 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 according to the sequence from small to large, and updating the n machine numbers into the next adjacent number section after the current machine number section is used;
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 request is greater than or equal to a first threshold value, updating the current machine number section to 1-n, sequentially determining the machine numbers corresponding to the number requests in the current machine number section according to the sequence from small to large, and updating n machine numbers to the next adjacent number section after the current machine number section is used;
if the number is smaller than the first threshold value, the machine numbers corresponding to the number requests are sequentially determined in the current machine number section from small to large, and after the current machine number section is used, the n machine numbers are updated to be the next adjacent number section.
4. The method for generating a serial number according to claim 1, wherein the clock callback identifier is generated by:
acquiring a time stamp, and judging whether the currently acquired time stamp is larger than the previous time stamp;
if yes, acquiring a clock callback identification bit;
if not, the clock callback identification bit is automatically increased by 1, and the clock callback identification bit is obtained.
5. The serial number generation method according to claim 1, wherein the serial number is generated by:
judging whether the current time stamp and the previous time stamp are in the same second or not;
if not, setting the serial number to 0, and marking after waiting for the next second to reacquire the time stamp;
if yes, the sequence number is increased by 1, and then whether the sequence number after the automatic increase of 1 is larger than a second threshold value is judged;
if the serial number after the self-increment of 1 is larger than a second threshold value, setting the serial number to 0, and marking after waiting for the next second to reacquire the time stamp;
and if the sequence number after the self-increment of 1 is smaller than or equal to a second threshold value, outputting the sequence number.
6. A serial number generation device, characterized by comprising:
the system comprises a numbering request module, a numbering database and a numbering server, wherein the numbering request module is used for sending a numbering request to the application numbering server in the process of starting a target application so that the application numbering server queries the machine number in the numbering database according to the numbering request; the numbering request is generated through a distributed serial number component in the target application in the starting process of the target application;
the machine number receiving module is used for receiving the machine number returned by the application number server through the distributed serial number component;
the serial number generation module is used for generating serial number information of the target application through the distributed serial number component and generating a serial number corresponding to the target application through the distributed serial number component according to the serial number information and the machine number;
the serial number generation module is specifically used for generating at least one of 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;
the serial number generation module is specifically configured to generate, through the distributed serial number component, a serial number corresponding to the target application according to the sign bit, version number, timestamp, clock callback identifier, serial number and machine number of the target application;
the apparatus further comprises:
the address acquisition module is used for acquiring a network address for sending the numbering request by the application numbering server;
the distributed lock request module is used for requesting the distributed lock by taking the application name as a primary key according to the network address;
the judging module is used for judging whether the distributed lock is acquired, if yes, executing the step of inquiring the machine number in the number database by the application number server according to the number request, and if no, executing the retry request module;
and the retry request module is used for retrying to request the distributed lock in an interval time period.
7. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the serial number generation method of any one of claims 1 to 5 when the program is executed by the processor.
8. A non-transitory computer readable storage medium having stored thereon a computer program, which when executed by a processor, implements the steps of the running number generation method of any of claims 1 to 5.
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 CN112559558A (en) 2021-03-26
CN112559558B true 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)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
CN113596193B (en) * 2021-07-27 2024-01-16 京东科技控股股份有限公司 Distributed ID processing method, system, storage medium and electronic equipment
CN114244806B (en) * 2022-02-28 2022-07-29 深圳市城市交通规划设计研究中心股份有限公司 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 (12)

* 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
CN105072160A (en) * 2015-07-17 2015-11-18 联动优势科技有限公司 Serial number generating method and device, and a server
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
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

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10482135B2 (en) * 2012-07-12 2019-11-19 Salesforce.Com, Inc. Facilitating dynamic generation and customization of software applications at client computing devices using server metadata in an on-demand services 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
US11770446B2 (en) * 2014-08-28 2023-09-26 Ebay Inc. Systems and methods for providing complementary content on linked machines
US11157517B2 (en) * 2016-04-18 2021-10-26 Amazon Technologies, Inc. Versioned hierarchical data structures in a distributed data store

Patent Citations (12)

* 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
CN105072160A (en) * 2015-07-17 2015-11-18 联动优势科技有限公司 Serial number generating method and device, and a server
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
管理信息系统中流水号生成方法与实现;杨宝明;;计算机工程与设计(第12期);全文 *

Also Published As

Publication number Publication date
CN112559558A (en) 2021-03-26

Similar Documents

Publication Publication Date Title
CN112559558B (en) Method and device for generating serial numbers, computing equipment and storage medium
CN109828847B (en) Block chain-based lock processing method, device, computer equipment and storage medium
US7774826B1 (en) System and method for determining effective policy profiles in a client-server architecture
CN110543324B (en) Plug-in increment updating method and device for application program
CN110413845B (en) Resource storage method and device based on Internet of things operating system
CN111225082B (en) Identity management method and device of Internet of things intelligent equipment and Internet of things platform
US20040117574A1 (en) Security token sharable data and synchronization cache
US10552411B2 (en) Email service adapter
US8554889B2 (en) Method, system and apparatus for managing computer identity
CN111866203B (en) Domain name resolution method and device, readable storage medium and equipment
CN110955460B (en) Service process starting method and device, electronic equipment and storage medium
CN110727895B (en) Sensitive word sending method and device, electronic equipment and storage medium
JP2006277158A (en) Data update system, server and program
CN115858590A (en) Domain name query request processing method, computer device, apparatus, medium, and product
JP6233846B2 (en) Variable-length nonce generation
CN109688204B (en) File downloading method, node and terminal based on NDN (named data networking)
CN113285933A (en) User access control method and device, electronic equipment and storage medium
CN113296687A (en) Data processing method, device, computing equipment and medium
CN111614750A (en) Data updating method, system, equipment and storage medium
CN109660390B (en) Information updating method and system based on external inquiry DNS server
US8015154B1 (en) Starting database software in response to a broadcast message
CN112039729B (en) Device identification method, server, electronic device, and storage medium
CN110932980B (en) Communication method, terminal, and computer-readable storage medium
CN111460028A (en) Data transmission method, data transmission device, storage medium, and electronic apparatus
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