CN117827868A - Method and device for determining serial number, storage medium and electronic equipment - Google Patents

Method and device for determining serial number, storage medium and electronic equipment Download PDF

Info

Publication number
CN117827868A
CN117827868A CN202311562534.9A CN202311562534A CN117827868A CN 117827868 A CN117827868 A CN 117827868A CN 202311562534 A CN202311562534 A CN 202311562534A CN 117827868 A CN117827868 A CN 117827868A
Authority
CN
China
Prior art keywords
serial number
sequence number
serial
target
node
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.)
Pending
Application number
CN202311562534.9A
Other languages
Chinese (zh)
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.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202311562534.9A priority Critical patent/CN117827868A/en
Publication of CN117827868A publication Critical patent/CN117827868A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a serial number determining method, a serial number determining device, a storage medium and electronic equipment, and relates to the field of financial science and technology and other related technical fields. Wherein the method comprises the following steps: generating serial numbers through N serial number nodes, wherein each serial number node corresponds to a serial number database; screening N sequence number nodes according to the interface request to obtain a target sequence number node, wherein the running state of the target sequence number node is normal; inquiring a sequence number database corresponding to a target sequence number node to obtain a first sequence number, wherein the first sequence number is a sequence number generated by the target sequence number node according to a historical interface request, and the historical interface request is a last historical interface request corresponding to the interface request; and determining the target serial number according to the first serial number. The method and the device solve the technical problem of low acquisition efficiency of the serial number caused by generating the serial number by means of a single database.

Description

Method and device for determining serial number, storage medium and electronic equipment
Technical Field
The present invention relates to the field of financial science and technology and other related technical fields, and in particular, to a method and apparatus for determining a serial number, a storage medium and an electronic device.
Background
With the technical development of the financial science and technology field, the range of financial services supported by online application of a financial institution is becoming wider, and when the financial institution processes a service request triggered by online application of a user, a series of serial numbers need to be generated to identify resources related to the service request of the user. In the prior art, a single database is generally adopted to generate a serial number required by a user, however, the generation efficiency of the serial number is lower due to the performance limitation of the single database node, the generation speed of the serial number is also limited by the server performance of the database node, the transverse expansion cannot be performed, and under the condition that the database is down, the serial number cannot be provided for the user to use, so that the problem of low acquisition efficiency of the serial number caused by generating the serial number by means of the single database is caused.
In view of the above problems, no effective solution has been proposed at present.
Disclosure of Invention
The application provides a method and a device for determining a serial number, a storage medium and electronic equipment, and aims to at least solve the technical problem of low acquisition efficiency of the serial number caused by generating the serial number by means of a single database.
According to one aspect of the present application, there is provided a method for determining a sequence number, including: generating serial numbers through N serial number nodes, wherein N is a positive integer, each serial number node corresponds to a serial number database, the serial number database corresponding to each serial number node is used for storing the serial numbers generated by the serial number node, and the serial numbers are used for responding to the interface requests; screening N sequence number nodes according to the interface request to obtain a target sequence number node, wherein the running state of the target sequence number node is normal; inquiring a sequence number database corresponding to a target sequence number node to obtain a first sequence number, wherein the first sequence number is a sequence number generated by the target sequence number node according to a historical interface request, and the historical interface request is a last historical interface request corresponding to the interface request; and determining the target serial number according to the first serial number.
Optionally, the method for determining the serial number further includes: when the interface request is a first request, a first serial number node in N serial number nodes is determined to be a target serial number node, wherein the serial number generated by the first serial number node is the unique identifier of the page resource acquired by the first request, and the communication protocol corresponding to the first request is a hypertext transfer protocol; and when the interface request is a second request, determining a second serial number node in the N serial number nodes as a target serial number node, wherein the serial number generated by the second serial number node is the unique identification of the remote call result obtained by the second request, and the communication protocol corresponding to the second request is a protocol used for remote call among different devices in the distributed system.
Optionally, the method for determining the serial number further includes: the control target sequence number node generates M sequence numbers according to a preset step length, wherein M is a positive integer, each sequence number in the M sequence numbers corresponds to a sequence number ID, the sequence number ID is a unique identifier of the sequence number, and the preset step length is used for representing a difference value between two adjacent sequence numbers of the sequence number ID; determining the margin of each sequence number in the M sequence numbers, wherein the margin of each sequence number is used for representing the remainder obtained by dividing the sequence number by a preset increment; acquiring a first database table and a second database table corresponding to the target sequence number node, wherein the first database table and the second database table are tables in a sequence number database corresponding to the target sequence number node, the first database table corresponds to a first preset threshold value, the second database table corresponds to a second preset threshold value, and the first preset threshold value is different from the second preset threshold value; and storing the M serial numbers into a first database table and a second database table, wherein the allowance of the serial numbers stored in the first database table is equal to a first preset threshold value, and the allowance of the serial numbers stored in the second database table is equal to a second preset threshold value.
Optionally, the method for determining the serial number further includes: determining a first loading threshold corresponding to the first database table, wherein the first loading threshold is used for representing the product of the total number of all serial numbers stored in the first database table and a preset percentage; loading the second database table under the condition that the serial number corresponding to the first loading threshold value is used; determining a second loading threshold corresponding to the second database table, wherein the second loading threshold is used for representing the product of the total number of all serial numbers stored in the second database table and a preset percentage; and loading the first database table under the condition that the serial number corresponding to the second loading threshold value is used.
Optionally, the method for determining the serial number further includes: determining the allowance corresponding to the first serial number as a target allowance; detecting whether the target allowance is equal to a preset threshold, wherein the preset threshold is a first preset threshold or a second preset threshold; under the condition that the target allowance is equal to a preset threshold value, determining a second serial number corresponding to the first serial number as a target serial number, wherein the second serial number is the sum of the first serial number and a preset increment; and under the condition that the target allowance is not equal to the preset threshold, determining a third serial number corresponding to the first serial number as the target serial number, wherein the third serial number is smaller than the sum of the first serial number and the preset increment, and the third serial number is a multiple of the preset threshold.
Optionally, the method for determining the serial number further includes: judging whether the target serial number is larger than the maximum serial number, wherein the maximum serial number is used for representing the maximum value of the serial numbers which can be stored in the serial number database; generating first prompt information under the condition that the target sequence number is larger than the maximum sequence number, wherein the first prompt information is used for representing that the target sequence number does not accord with the use rule of the sequence number corresponding to the interface request; judging whether the target sequence number is larger than a loading threshold value or not under the condition that the target sequence number is smaller than or equal to the maximum sequence number, wherein the loading threshold value is a first loading threshold value or a second loading threshold value; generating second prompt information under the condition that the target sequence number is smaller than the loading threshold value, wherein the second prompt information is used for representing that the target sequence number accords with the use rule of the sequence number corresponding to the interface request; and generating third prompt information under the condition that the target serial number is greater than or equal to the loading threshold value, wherein the third prompt information is used for prompting a user to load the first database table or the second database table into the memory.
Optionally, the method for determining the serial number further includes: acquiring a first pointer corresponding to a target sequence number node, wherein the first pointer is used for positioning a database table of a last acquired sequence number, and the database table is a first database table or a second database table; and under the condition that all the stored serial numbers in the database tables corresponding to the first pointer are used, acquiring a second pointer corresponding to the target serial number node, wherein the second pointer is used for positioning the database tables with the serial numbers which are not used completely.
According to an aspect of the present application, there is provided a sequence number determining apparatus, including: the first generation unit is used for generating serial numbers through N serial number nodes, wherein N is a positive integer, each serial number node corresponds to a serial number database, the serial number database corresponding to each serial number node is used for storing the serial numbers generated by the serial number node, and the serial numbers are used for responding to the interface request; the screening unit is used for screening the target sequence number node from the N sequence number nodes according to the interface request, wherein the running state of the target sequence number node is normal; the query unit is used for querying a sequence number database corresponding to the target sequence number node to obtain a first sequence number, wherein the first sequence number is a sequence number generated by the target sequence number node according to a historical interface request, and the historical interface request is a last historical interface request corresponding to the interface request; and the first determining unit is used for determining the target serial number according to the first serial number.
According to another aspect of the present application, there is also provided a computer readable storage medium having a computer program stored therein, wherein the computer readable storage medium is controlled to execute the method for determining the serial number of any one of the above items by a device in which the computer readable storage medium is located when the computer program is run.
According to another aspect of the present application, there is also provided an electronic device, wherein the electronic device includes one or more processors and a memory for storing one or more programs, and wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method for determining a serial number of any of the above.
In the method, firstly, a serial number is generated through N serial number nodes, wherein N is a positive integer, each serial number node corresponds to a serial number database, the serial number database corresponding to each serial number node is used for storing serial numbers generated by the serial number node, the serial numbers are used for responding to interface requests, secondly, a target serial number node is screened from the N serial number nodes according to the interface requests, wherein the running state of the target serial number node is normal, afterwards, a first serial number is inquired from the serial number database corresponding to the target serial number node, the first serial number is the serial number generated by the target serial number node according to historical interface requests, the historical interface requests are last historical interface requests corresponding to the interface requests, and finally, the target serial number is determined according to the first serial number.
As can be seen from the foregoing, in the technical solution of the present application, the number of N serial number nodes for generating serial numbers is included, compared with a method of generating serial numbers by using a single node in the prior art, the serial number generating efficiency is improved by using a parallel operation mode of the N serial number nodes, and then, by checking the running state of each serial number generating node in the N serial number generating nodes, the serial number node with a normal running state is selected as the target serial number node, so that the problem of low acquisition efficiency of serial numbers caused by downtime of a single database is avoided.
Therefore, the method and the device achieve the purpose of improving the generation speed of the serial numbers by screening the target serial number nodes from N serial number nodes working in parallel, avoid the problem of interruption of serial number generation caused by downtime of a single database, achieve the technical effect of improving the acquisition efficiency of the serial numbers, and further solve the technical problem of low acquisition efficiency of the serial numbers caused by generating the serial numbers by means of the single database.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application and do not constitute an undue limitation to the application. In the drawings:
FIG. 1 is a flow chart of an alternative method of determining a sequence number according to an embodiment of the present application;
FIG. 2 is a schematic diagram of an alternative serial number determination system according to an embodiment of the present application;
FIG. 3 is a flow chart of an alternative method of storing M serial numbers according to an embodiment of the present application;
FIG. 4 is a flow chart of an alternative method of determining the acquisition result of a target sequence number according to an embodiment of the present application;
FIG. 5 is a flow chart of an alternative hint information generating method according to embodiments of the present application;
FIG. 6 is a flow chart of an alternative method of retrieving a sequence number from a dual database table according to an embodiment of the present application;
FIG. 7 is a flow chart of an alternative sequence number determination apparatus according to an embodiment of the present application;
fig. 8 is a schematic diagram of an alternative electronic device according to an embodiment of the present application.
Detailed Description
In order to make the present application solution better understood by those skilled in the art, the following description will be made in detail and with reference to the accompanying drawings in the embodiments of the present application, it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, shall fall within the scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of the present application and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that embodiments of the present application described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be further noted that, the relevant information (including the interface request information and the operation status information of the serial number generating node) and the data (including, but not limited to, the data for presentation and the data for analysis) related to the present application are both information and data authorized by the user or sufficiently authorized by each party. For example, an interface is provided between the system and the relevant user or institution, before acquiring the relevant information, the system needs to send an acquisition request to the user or institution through the interface, and acquire the relevant information after receiving the consent information fed back by the user or institution.
The present application is further illustrated below in conjunction with various embodiments.
Example 1
In accordance with the embodiments of the present application, a method embodiment for determining a serial number is provided, it being noted that the steps illustrated in the flowchart of the figures may be performed in a computer system, such as a set of computer executable instructions, and, although a logical order is illustrated in the flowchart, in some cases, the steps illustrated or described may be performed in an order other than that illustrated herein.
The present application provides a serial number determining system (abbreviated as determining system) for executing a serial number determining method in the present application, and fig. 1 is a flowchart of an alternative serial number determining method according to an embodiment of the present application, as shown in fig. 1, and the method includes the following steps:
step S101, generating serial numbers through N serial number nodes.
In step S101, N is a positive integer, each sequence number node corresponds to a sequence number database, and the sequence number database corresponding to each sequence number node is used for storing the sequence number generated by the sequence number node, and the sequence number is used for responding to the interface request.
Optionally, each serial number database includes at least two database tables, each database table is used for storing a partial serial number generated by a serial number node corresponding to the serial number database, in addition, each database table corresponds to a serial number slicer, and the serial number slicer is used for storing the partial serial number meeting the storage requirement of the database table into the database.
Step S102, screening out target serial number nodes from N serial number nodes according to the interface request.
In step S102, the operation state of the target sequence number node is normal.
Optionally, the determining system obtains a performance index of each serial number node in the N serial number nodes, where the performance index at least includes a CPU occupancy rate and a memory occupancy rate, determines that an operation state of the serial number node is a normal state when the performance index meets a preset index condition, determines that the operation state of the serial number node is an abnormal state when the performance index does not meet the preset index condition, and then determines that a serial number node whose operation state is a normal state is a target serial number node.
Step S103, inquiring a sequence number database corresponding to the target sequence number node to obtain a first sequence number.
In step S103, the first sequence number is a sequence number generated by the target sequence number node according to the history interface request, where the history interface request is a last history interface request corresponding to the interface request.
Alternatively, the first sequence number may be stored in a first database table of the sequence number database, or may be stored in a second database table of the sequence number database.
Step S104, determining the target serial number according to the first serial number.
Optionally, the determining system performs a remainder operation on the first sequence number, where the remainder operation is used to calculate a remainder of the first sequence number, and then determines the target sequence number according to the remainder of the first sequence number.
Optionally, fig. 2 is a schematic diagram of an optional serial number determining system according to an embodiment of the present application, as shown in fig. 2, where the serial number determining system is composed of a serial number generating node cluster and a database cluster, where the serial number generating node cluster includes a serial number node 1, a serial number node 2, a serial number node 3, and a load balancing subsystem, and the database cluster includes a serial number database 1, a serial number database 2, and a serial number database 3, and the load balancing subsystem is configured to distribute an HTTP request or an RPC request to one serial number node in the serial number generating node cluster in a load balancing manner.
As can be seen from the foregoing, in the technical solution of the present application, the number of N serial number nodes for generating serial numbers is included, compared with a method of generating serial numbers by using a single node in the prior art, the serial number generating efficiency is improved by using a parallel operation mode of the N serial number nodes, and then, by checking the running state of each serial number generating node in the N serial number generating nodes, the serial number node with a normal running state is selected as the target serial number node, so that the problem of low acquisition efficiency of serial numbers caused by downtime of a single database is avoided.
Therefore, the method and the device achieve the purpose of improving the generation speed of the serial numbers by screening the target serial number nodes from N serial number nodes working in parallel, avoid the problem of interruption of serial number generation caused by downtime of a single database, achieve the technical effect of improving the acquisition efficiency of the serial numbers, and further solve the technical problem of low acquisition efficiency of the serial numbers caused by generating the serial numbers by means of the single database.
In an alternative embodiment, when the interface request is a first request, a first serial number node of the N serial number nodes is determined to be a target serial number node, wherein a serial number generated by the first serial number node is a unique identifier of a page resource acquired by the first request, a communication protocol corresponding to the first request is a hypertext transfer protocol, and when the interface request is a second request, a second serial number node of the N serial number nodes is determined to be a target serial number node, wherein a serial number generated by the second serial number node is a unique identifier of a remote call result acquired by the second request, and a communication protocol corresponding to the second request is a protocol used for performing remote call between different devices in the distributed system.
Optionally, the first request is an HTTP (Hypertext Transfer Protocol ) request, the second request is an RPC (Remote Procedure Call ) request, the application encapsulates the generation logic of the serial number into a back-end node (serial number generation node), interacts with other programs, applications or systems in an HTTP interface request mode or an RPC interface request mode, and encapsulates the serial number node in cooperation with a k8s (Kubernetes) platform, so that the interface service of the serial number node can be expanded laterally, and the traffic of the interface request is uniformly spread to each serial number generation node in a load balancing mode, thereby improving the generation efficiency of the serial number determining system.
In an alternative embodiment, fig. 3 is a flowchart of an alternative method of storing M serial numbers according to an embodiment of the present application, as shown in fig. 3, the method including the steps of:
step S301, the control target sequence number node generates M sequence numbers according to a preset step length.
In step S301, M is a positive integer, each of the M serial numbers corresponds to a serial number ID, the serial number ID is a unique identifier of the serial number, and the preset step size is used for representing a difference between two adjacent serial numbers of the serial number IDs.
Step S302, determining a margin of each of the M sequence numbers.
In step S302, the margin of each serial number is used to characterize the remainder of dividing the serial number by a preset increment.
Step S303, a first database table and a second database table corresponding to the target serial number node are obtained.
In step S303, the first database table and the second database table are tables in the sequence number database corresponding to the target sequence number node, the first database table corresponds to a first preset threshold, the second database table corresponds to a second preset threshold, and the first preset threshold is different from the second preset threshold.
Step S304, M serial numbers are stored in a first database table and a second database table.
In step S304, the margin of the serial number stored in the first database table is equal to the first preset threshold, and the margin of the serial number stored in the second database table is equal to the second preset threshold.
For example, assuming that the target sequence number node includes a database table a and a database table B, where the database table a corresponds to a sequence number slicer C, the database table B corresponds to a sequence number slicer D, the sequence number slicer C is configured to store a sequence number with a margin of 0 in the database table a, the sequence number slicer D is configured to store a sequence number with a margin of 0 in the database table B, a preset increment corresponding to the target sequence number is 2, a preset step size is 1, a first preset threshold is 0, a second preset threshold is 1, 10 sequence numbers generated by the target sequence number are 1, 2, 3, … …, 9, and 10, then 1, 3, 5, 7, and 9 are stored in the database table a through the sequence number slicer C, and 2, 4, 6, 8, and 10 are stored in the database table B through the sequence number slicer D.
In an alternative embodiment, after the determining system stores M serial numbers in the first database table and the second database table, determining a first loading threshold corresponding to the first database table, where the first loading threshold is used to characterize a product of a total number of all serial numbers stored in the first database table and a preset percentage, and then loading the second database table if the serial number corresponding to the first loading threshold is used; in addition, a second loading threshold corresponding to the second database table is determined, wherein the second loading threshold is used for representing the product of the total number of all serial numbers stored in the second database table and a preset percentage, and then the first database table is loaded under the condition that the serial number corresponding to the second loading threshold is used.
Optionally, the purpose of dividing the serial number to be used into two number segments for caching is achieved by setting the double database table in the target serial number, and after the serial number stored in the database currently being used is consumed by a preset percentage, the determining system loads the serial number stored in the other database table in advance, so that the problem that the serial number stored in the first database is consumed rapidly due to burst traffic, but the serial number stored in the second database table cannot be loaded timely is avoided, and the determining system can control the time for loading the serial number in advance by changing the sizes of the first loading threshold and the second loading threshold, so that the reliability of the determining system is improved.
In an alternative embodiment, the determining system first determines the margin corresponding to the first sequence number as a target margin, then detects whether the target margin is equal to a preset threshold, where the preset threshold is a first preset threshold or a second preset threshold, then determines the second sequence number corresponding to the first sequence number as a target sequence number if the target margin is equal to the preset threshold, where the second sequence number is a sum of the first sequence number and a preset increment, and further determines the third sequence number corresponding to the first sequence number as a target sequence number if the target margin is not equal to the preset threshold, where the third sequence number is less than the sum of the first sequence number and the preset increment, and where the third sequence number is a multiple of the preset threshold.
Optionally, in the case that the target margin is not equal to the preset threshold, performing a self-increasing operation on the first sequence number, where the self-increasing operation is used to gradually increase the first sequence number by 1 until the margin corresponding to the result after each increase is equal to the preset threshold.
Optionally, fig. 4 is a flowchart of an alternative method for determining the acquisition result of the target serial number according to an embodiment of the present application, as shown in fig. 4, including the following steps:
The method comprises the steps that a determining system firstly obtains a database table in an interface calling mode, wherein the database table is a first database table or a second database table, then, whether the database table is initialized is judged, namely whether a serial number generated by a serial number node is stored in the database table is judged, under the condition that the database table is not initialized, an initial value of the first serial number is determined to be 0, a target serial number is equal to the sum of the first serial number and a preset increment, under the condition that the database table is initialized, whether target allowance is equal to a preset threshold value is judged, and the target allowance is the allowance of the first serial number in the database table.
Under the condition that the target allowance is equal to a preset threshold value, determining that the target serial number is equal to the sum of the first serial number and a preset increment; and setting the initial value of the variable in the determination system to 0 when the target allowance is not equal to the preset threshold, judging whether the variable is smaller than or equal to the preset increment, performing self-increment operation on the variable i and also performing self-increment operation on the first serial number when the variable is smaller than or equal to the preset increment, and then judging whether the target allowance is equal to the preset threshold.
And if the target allowance is not equal to the preset threshold, circularly judging whether the current variable is smaller than or equal to the preset increment.
In addition, the sum of the current first serial number and the preset increment is used as a target serial number, whether the target serial number is larger than the maximum serial number is judged, and when the target serial number is larger than the maximum serial number, the acquisition result of the serial number is determined to be a first result (corresponding to the generation of first prompt information); and judging whether the target sequence number is greater than or equal to a loading threshold value under the condition that the target sequence number is less than or equal to the maximum sequence number. Under the condition that the target serial number is greater than or equal to the loading threshold value, determining that the acquired result is a second result (correspondingly generating second prompt information); and under the condition that the target sequence number is smaller than the loading threshold value, determining the acquired result as a third result (correspondingly generating third prompt information).
In an alternative embodiment, fig. 5 is a flowchart of an alternative method for generating a hint information according to an embodiment of the present application, as shown in fig. 5, the method includes the steps of:
in step S501, it is determined whether the target sequence number is greater than the maximum sequence number.
In step S501, the maximum sequence number is used to characterize the maximum value of the sequence numbers that can be stored in the sequence number database.
Step S502, generating a first prompt message when the target sequence number is greater than the maximum sequence number.
In step S502, the first hint information is used to characterize that the target sequence number does not conform to the usage rule of the sequence number corresponding to the interface request.
In step S503, if the target sequence number is less than or equal to the maximum sequence number, it is determined whether the target sequence number is greater than the loading threshold.
In step S503, the loading threshold is the first loading threshold or the second loading threshold.
Step S504, generating a second prompt message under the condition that the target sequence number is smaller than the loading threshold value.
In step S504, the second hint information is used to characterize that the target sequence number meets the usage rule of the sequence number corresponding to the interface request.
In step S505, a third hint information is generated if the target sequence number is greater than or equal to the load threshold.
In step S505, the third prompting information is used to prompt the user to load the first database table or the second database table into the memory.
In an alternative embodiment, the determining system first obtains a first pointer corresponding to the target sequence number node, where the first pointer is used to locate a database table of the last obtained sequence number, and the database table is the first database table or the second database table, and then obtains a second pointer corresponding to the target sequence number node when all the stored sequence numbers in the database table corresponding to the first pointer are used, where the second pointer is used to locate a database table of which the sequence numbers are not used all.
Optionally, in the case that the first pointer points to the first database table and the sequence numbers in the first database table are all used, the second pointer points to the second database table; in the case where the first pointer points to the second database table and a new sequence number that is partially unused is newly stored in the first database table, the second pointer is pointed to the first database table.
Optionally, fig. 6 is a flowchart of an alternative method for obtaining a serial number from a dual database table according to an embodiment of the present application, as shown in fig. 6, including the steps of:
determining that the system acquires a first database table in an interface calling mode, then judging whether a first pointer is empty (namely judging whether a serial number stored in the first database table corresponding to the first pointer is empty), and judging whether the serial number in the first database table is larger than a maximum serial number (namely judging whether the first database is full) under the condition that the first pointer is empty; and under the condition that the first pointer is not empty, acquiring an acquisition result of the serial number corresponding to the first pointer, wherein the acquisition result is a first result, a second result or a third result.
Generating a new sequence number and storing the new sequence number into the first database table under the condition that the sequence number in the first database table is smaller than or equal to the maximum sequence number (namely, the first database table is not full); when the sequence number in the first database table is greater than the maximum sequence number, it is determined whether the second pointer is empty (i.e., whether the sequence number stored in the second database table corresponding to the second pointer is empty).
Loading a second database table corresponding to the second pointer under the condition that the second pointer is empty, and assigning the database table corresponding to the second pointer to the first pointer; and under the condition that the second pointer is not empty, directly assigning the database table corresponding to the second pointer to the first pointer, and then assigning the second pointer to be empty.
In the method, firstly, a serial number is generated through N serial number nodes, wherein N is a positive integer, each serial number node corresponds to a serial number database, the serial number database corresponding to each serial number node is used for storing serial numbers generated by the serial number node, the serial numbers are used for responding to interface requests, secondly, a target serial number node is screened from the N serial number nodes according to the interface requests, wherein the running state of the target serial number node is normal, afterwards, a first serial number is inquired from the serial number database corresponding to the target serial number node, the first serial number is the serial number generated by the target serial number node according to historical interface requests, the historical interface requests are last historical interface requests corresponding to the interface requests, and finally, the target serial number is determined according to the first serial number.
As can be seen from the foregoing, in the technical solution of the present application, the number of N serial number nodes for generating serial numbers is included, compared with a method of generating serial numbers by using a single node in the prior art, the serial number generating efficiency is improved by using a parallel operation mode of the N serial number nodes, and then, by checking the running state of each serial number generating node in the N serial number generating nodes, the serial number node with a normal running state is selected as the target serial number node, so that the problem of low acquisition efficiency of serial numbers caused by downtime of a single database is avoided.
Therefore, the method and the device achieve the purpose of improving the generation speed of the serial numbers by screening the target serial number nodes from N serial number nodes working in parallel, avoid the problem of interruption of serial number generation caused by downtime of a single database, achieve the technical effect of improving the acquisition efficiency of the serial numbers, and further solve the technical problem of low acquisition efficiency of the serial numbers caused by generating the serial numbers by means of the single database.
Example 2
According to an embodiment of the present application, an embodiment of a determining device for a serial number is provided. Fig. 7 is a schematic diagram of an alternative apparatus for determining a serial number according to an embodiment of the present application, where, as shown in fig. 7, the apparatus for determining a serial number includes: a first generation unit 701, a screening unit 702, a query unit 703, and a first determination unit 704.
Optionally, the first generating unit is configured to generate a sequence number through N sequence number nodes, where N is a positive integer, each sequence number node corresponds to a sequence number database, and the sequence number database corresponding to each sequence number node is configured to store the sequence number generated by the sequence number node, and the sequence number is configured to respond to the interface request; the screening unit is used for screening the target sequence number node from the N sequence number nodes according to the interface request, wherein the running state of the target sequence number node is normal; the query unit is used for querying a sequence number database corresponding to the target sequence number node to obtain a first sequence number, wherein the first sequence number is a sequence number generated by the target sequence number node according to a historical interface request, and the historical interface request is a last historical interface request corresponding to the interface request; and the first determining unit is used for determining the target serial number according to the first serial number.
In an alternative embodiment, the screening unit comprises: a first determination subunit and a second determination subunit.
Optionally, when the interface request is a first request, the first determining subunit is configured to determine a first sequence number node of the N sequence number nodes as a target sequence number node, where a sequence number generated by the first sequence number node is a unique identifier of a page resource acquired by the first request, and a communication protocol corresponding to the first request is a hypertext transfer protocol; and the first determining subunit is used for determining a second serial number node in the N serial number nodes as a target serial number node when the interface request is a second request, wherein the serial number generated by the second serial number node is the unique identifier of the remote call result obtained by the second request, and the communication protocol corresponding to the second request is a protocol used for remote call among different devices in the distributed system.
In an alternative embodiment, the determining means of the serial number further comprises: the device comprises a control unit, a second determining unit, a first acquisition unit and a storage unit.
Optionally, the control unit is configured to control the target sequence number node to generate M sequence numbers according to a preset step length, where M is a positive integer, each sequence number in the M sequence numbers corresponds to a sequence number ID, the sequence number ID is a unique identifier of the sequence number, and the preset step length is used to characterize a difference value between two adjacent sequence numbers of the sequence number ID; a second determining unit, configured to determine a margin of each of the M sequence numbers, where the margin of each sequence number is used to characterize a remainder obtained by dividing the sequence number by a preset increment; the first acquisition unit is used for acquiring a first database table and a second database table corresponding to the target serial number node, wherein the first database table and the second database table are tables in a serial number database corresponding to the target serial number node, the first database table corresponds to a first preset threshold value, the second database table corresponds to a second preset threshold value, and the first preset threshold value is different from the second preset threshold value; and the storage unit is used for storing the M serial numbers into a first database table and a second database table, wherein the allowance of the serial numbers stored in the first database table is equal to a first preset threshold value, and the allowance of the serial numbers stored in the second database table is equal to a second preset threshold value.
In an alternative embodiment, the determining means of the serial number further comprises: the device comprises a third determining unit, a first loading unit, a fourth determining unit and a second loading unit.
Optionally, a third determining unit is configured to determine a first loading threshold corresponding to the first database table, where the first loading threshold is used to characterize a product of a total number of all serial numbers stored in the first database table and a preset percentage; the first loading unit is used for loading the second database table under the condition that the serial number corresponding to the first loading threshold value is used; a fourth determining unit, configured to determine a second loading threshold corresponding to the second database table, where the second loading threshold is used to characterize a product of a total number of all serial numbers stored in the second database table and a preset percentage; and the second loading unit is used for loading the first database table under the condition that the serial number corresponding to the second loading threshold value is used.
In an alternative embodiment, the first determining unit further comprises: a third determination subunit, a detection subunit, a fourth determination subunit, and a fifth determination subunit.
Optionally, a third determining subunit, configured to determine a residual amount corresponding to the first sequence number as a target residual amount; the detecting subunit is used for detecting whether the target allowance is equal to a preset threshold value, wherein the preset threshold value is a first preset threshold value or a second preset threshold value; a fourth determining subunit, configured to determine, when the target margin is equal to a preset threshold, a second sequence number corresponding to the first sequence number as a target sequence number, where the second sequence number is a sum of the first sequence number and a preset increment; and a fifth determining subunit, configured to determine, when the target remaining amount is not equal to the preset threshold, a third sequence number corresponding to the first sequence number as the target sequence number, where the third sequence number is smaller than a sum of the first sequence number and the preset increment, and the third sequence number is a multiple of the preset threshold.
In an alternative embodiment, the determining means of the serial number further comprises: the device comprises a first judging unit, a second generating unit, a second judging unit, a third generating unit and a fourth generating unit.
Optionally, the first judging unit is configured to judge whether the target sequence number is greater than a maximum sequence number, where the maximum sequence number is used to characterize a maximum value of the sequence numbers that can be stored in the sequence number database; the second generation unit is used for generating first prompt information under the condition that the target sequence number is larger than the maximum sequence number, wherein the first prompt information is used for representing that the target sequence number does not accord with the use rule of the sequence number corresponding to the interface request; the second judging unit is used for judging whether the target sequence number is larger than a loading threshold value or not under the condition that the target sequence number is smaller than or equal to the maximum sequence number, wherein the loading threshold value is a first loading threshold value or a second loading threshold value; the third generation unit is used for generating second prompt information under the condition that the target sequence number is smaller than the loading threshold value, wherein the second prompt information is used for representing that the target sequence number accords with the use rule of the sequence number corresponding to the interface request; and the fourth generation unit is used for generating third prompt information when the target serial number is greater than or equal to the loading threshold value, wherein the third prompt information is used for prompting a user to load the first database table or the second database table into the memory.
In an alternative embodiment, the determining means of the serial number further comprises: a second acquisition unit and a third acquisition unit.
Optionally, the second obtaining unit is configured to obtain a first pointer corresponding to the target sequence number node, where the first pointer is used to locate a database table that obtains the sequence number last time, and the database table is a first database table or a second database table; and a third obtaining unit, configured to obtain, when all the stored sequence numbers in the database tables corresponding to the first pointers are used, a second pointer corresponding to the target sequence number node, where the second pointer is used to locate the database tables whose sequence numbers are not used entirely.
In the method, firstly, a serial number is generated through N serial number nodes, wherein N is a positive integer, each serial number node corresponds to a serial number database, the serial number database corresponding to each serial number node is used for storing serial numbers generated by the serial number node, the serial numbers are used for responding to interface requests, secondly, a target serial number node is screened from the N serial number nodes according to the interface requests, wherein the running state of the target serial number node is normal, afterwards, a first serial number is inquired from the serial number database corresponding to the target serial number node, the first serial number is the serial number generated by the target serial number node according to historical interface requests, the historical interface requests are last historical interface requests corresponding to the interface requests, and finally, the target serial number is determined according to the first serial number.
As can be seen from the foregoing, in the technical solution of the present application, the number of N serial number nodes for generating serial numbers is included, compared with a method of generating serial numbers by using a single node in the prior art, the serial number generating efficiency is improved by using a parallel operation mode of the N serial number nodes, and then, by checking the running state of each serial number generating node in the N serial number generating nodes, the serial number node with a normal running state is selected as the target serial number node, so that the problem of low acquisition efficiency of serial numbers caused by downtime of a single database is avoided.
Therefore, the method and the device achieve the purpose of improving the generation speed of the serial numbers by screening the target serial number nodes from N serial number nodes working in parallel, avoid the problem of interruption of serial number generation caused by downtime of a single database, achieve the technical effect of improving the acquisition efficiency of the serial numbers, and further solve the technical problem of low acquisition efficiency of the serial numbers caused by generating the serial numbers by means of the single database.
Example 3
According to another aspect of the embodiments of the present application, there is also provided a computer readable storage medium, where the computer readable storage medium includes a stored computer program, where the computer program when executed controls a device in which the computer readable storage medium is located to perform the method for determining a serial number according to any one of the above embodiments 1.
Example 4
According to another aspect of the embodiments of the present application, there is also provided an electronic device, including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the method of determining the sequence number of any of the above embodiments 1 via execution of executable instructions.
Fig. 8 is a schematic diagram of an alternative electronic device according to an embodiment of the present application, and as shown in fig. 8, the embodiment of the present application provides an electronic device, where the electronic device includes a processor, a memory, and a program stored on the memory and capable of running on the processor, and the processor implements the method for determining a serial number in any one of the foregoing embodiments 1 when executing the program.
The foregoing embodiment numbers of the present application are merely for describing, and do not represent advantages or disadvantages of the embodiments.
In the foregoing embodiments of the present application, the descriptions of the embodiments are emphasized, and for a portion of this disclosure that is not described in detail in this embodiment, reference is made to the related descriptions of other embodiments.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory. The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, etc., such as Read Only Memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises an element.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and changes may be made to the present application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. which are within the spirit and principles of the present application are intended to be included within the scope of the claims of the present application.

Claims (10)

1. A method for determining a serial number, comprising:
generating serial numbers through N serial number nodes, wherein N is a positive integer, each serial number node corresponds to a serial number database, the serial number database corresponding to each serial number node is used for storing the serial numbers generated by the serial number node, and the serial numbers are used for responding to interface requests;
Screening the N sequence number nodes according to the interface request to obtain a target sequence number node, wherein the running state of the target sequence number node is normal;
inquiring a first serial number from a serial number database corresponding to the target serial number node, wherein the first serial number is a serial number generated by the target serial number node according to a historical interface request, and the historical interface request is a last historical interface request corresponding to the interface request;
and determining a target serial number according to the first serial number.
2. The method for determining a sequence number according to claim 1, wherein screening the target sequence number node from the N sequence number nodes according to the interface request includes:
when the interface request is a first request, determining a first serial number node in the N serial number nodes as the target serial number node, wherein the serial number generated by the first serial number node is the unique identifier of the page resource acquired by the first request, and the communication protocol corresponding to the first request is a hypertext transfer protocol;
and when the interface request is a second request, determining a second serial number node in the N serial number nodes as the target serial number node, wherein the serial number generated by the second serial number node is the unique identifier of the remote call result obtained by the second request, and the communication protocol corresponding to the second request is a protocol used for remote call among different devices in the distributed system.
3. The method for determining a sequence number according to claim 1, wherein before the first sequence number is queried from the sequence number database corresponding to the target sequence number node, the method for determining a sequence number further comprises:
controlling the target sequence number node to generate M sequence numbers according to a preset step length, wherein M is a positive integer, each sequence number in the M sequence numbers corresponds to a sequence number ID, the sequence number ID is a unique identifier of the sequence number, and the preset step length is used for representing the difference value between two adjacent sequence numbers of the sequence number ID;
determining the margin of each sequence number in the M sequence numbers, wherein the margin of each sequence number is used for representing the remainder obtained by dividing the sequence number by a preset increment;
acquiring a first database table and a second database table corresponding to the target sequence number node, wherein the first database table and the second database table are tables in a sequence number database corresponding to the target sequence number node, the first database table corresponds to a first preset threshold value, the second database table corresponds to a second preset threshold value, and the first preset threshold value is different from the second preset threshold value;
And storing the M serial numbers into the first database table and the second database table, wherein the allowance of the serial numbers stored in the first database table is equal to the first preset threshold value, and the allowance of the serial numbers stored in the second database table is equal to the second preset threshold value.
4. The method of determining a sequence number according to claim 3, wherein after storing the M sequence numbers to the first database table and the second database table, the method of determining a sequence number further comprises:
determining a first loading threshold corresponding to the first database table, wherein the first loading threshold is used for representing the product of the total number of all serial numbers stored in the first database table and a preset percentage;
loading the second database table under the condition that the serial number corresponding to the first loading threshold value is used;
determining a second loading threshold corresponding to the second database table, wherein the second loading threshold is used for representing the product of the total number of all serial numbers stored in the second database table and the preset percentage;
and loading the first database table under the condition that the serial number corresponding to the second loading threshold value is used.
5. The method of determining a sequence number according to claim 4, wherein determining a target sequence number from the first sequence number comprises:
determining the allowance corresponding to the first serial number as a target allowance;
detecting whether the target allowance is equal to a preset threshold, wherein the preset threshold is the first preset threshold or a second preset threshold;
determining a second sequence number corresponding to the first sequence number as the target sequence number under the condition that the target allowance is equal to the preset threshold value, wherein the second sequence number is the sum of the first sequence number and the preset increment;
and under the condition that the target allowance is not equal to the preset threshold, determining a third serial number corresponding to the first serial number as the target serial number, wherein the third serial number is smaller than the sum of the first serial number and the preset increment, and the third serial number is a multiple of the preset threshold.
6. The method for determining a sequence number according to claim 5, wherein after determining a third sequence number corresponding to the first sequence number as the target sequence number, the method for determining a sequence number further comprises:
Judging whether the target serial number is larger than a maximum serial number, wherein the maximum serial number is used for representing the maximum value of the serial numbers which can be stored in the serial number database;
generating first prompt information under the condition that the target sequence number is larger than the maximum sequence number, wherein the first prompt information is used for representing that the target sequence number does not accord with the use rule of the sequence number corresponding to the interface request;
judging whether the target sequence number is larger than a loading threshold value or not under the condition that the target sequence number is smaller than or equal to the maximum sequence number, wherein the loading threshold value is a first loading threshold value or a second loading threshold value;
generating second prompt information under the condition that the target sequence number is smaller than the loading threshold value, wherein the second prompt information is used for representing that the target sequence number accords with a use rule of a sequence number corresponding to the interface request;
and generating third prompt information when the target serial number is greater than or equal to the loading threshold, wherein the third prompt information is used for prompting a user to load the first database table or the second database table into a memory.
7. The method for determining a sequence number according to claim 3, wherein after obtaining the first database table and the second database table corresponding to the target sequence number node, the method for determining a sequence number further comprises:
acquiring a first pointer corresponding to the target sequence number node, wherein the first pointer is used for positioning a database table of the last acquired sequence number, and the database table is a first database table or a second database table;
and under the condition that all the stored sequence numbers in the database tables corresponding to the first pointers are used, acquiring second pointers corresponding to the target sequence number nodes, wherein the second pointers are used for positioning the database tables with the sequence numbers which are not used completely.
8. A sequence number determining apparatus, comprising:
the first generation unit is used for generating serial numbers through N serial number nodes, wherein N is a positive integer, each serial number node corresponds to a serial number database, the serial number database corresponding to each serial number node is used for storing the serial numbers generated by the serial number node, and the serial numbers are used for responding to the interface request;
the screening unit is used for screening the target sequence number node from the N sequence number nodes according to the interface request, wherein the running state of the target sequence number node is normal;
The query unit is used for querying a first serial number from a serial number database corresponding to the target serial number node, wherein the first serial number is a serial number generated by the target serial number node according to a historical interface request, and the historical interface request is a last historical interface request corresponding to the interface request;
and the first determining unit is used for determining the target sequence number according to the first sequence number.
9. A computer readable storage medium, wherein a computer program is stored in the computer readable storage medium, and wherein the computer program, when executed, controls a device in which the computer readable storage medium is located to perform the method for determining a serial number according to any one of claims 1 to 7.
10. An electronic device comprising one or more processors and a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of determining a serial number of any of claims 1-7.
CN202311562534.9A 2023-11-21 2023-11-21 Method and device for determining serial number, storage medium and electronic equipment Pending CN117827868A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311562534.9A CN117827868A (en) 2023-11-21 2023-11-21 Method and device for determining serial number, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311562534.9A CN117827868A (en) 2023-11-21 2023-11-21 Method and device for determining serial number, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN117827868A true CN117827868A (en) 2024-04-05

Family

ID=90519989

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311562534.9A Pending CN117827868A (en) 2023-11-21 2023-11-21 Method and device for determining serial number, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN117827868A (en)

Similar Documents

Publication Publication Date Title
EP3221795B1 (en) Service addressing in distributed environment
CN104113576A (en) Method and device for updating client
CN109254913B (en) Device sharing method and device, electronic device and computer storage medium
CN109614284B (en) Data processing method and device
CN114356557B (en) Cluster capacity expansion method and device
CN112269661B (en) Partition migration method and device based on Kafka cluster
CN112256433B (en) Partition migration method and device based on Kafka cluster
CN111562884B (en) Data storage method and device and electronic equipment
EP3672203A1 (en) Distribution method for distributed data computing, device, server and storage medium
CN111600771B (en) Network resource detection system and method
CN112559565A (en) Abnormity detection method, system and device
CN108124021B (en) Method, device and system for obtaining Internet Protocol (IP) address and accessing website
CN110333984B (en) Interface abnormality detection method, device, server and system
CN117827868A (en) Method and device for determining serial number, storage medium and electronic equipment
CN104618414A (en) Implementation method of distributed service, service agent device and distributed system
CN111756803A (en) Server-side pushing method, equipment and medium based on block chain technology
CN105763508B (en) Data access method and application server
CN114860536A (en) Monitoring method, monitoring system and related device of GPU card
CN115048186A (en) Method and device for processing expansion and contraction of service container, storage medium and electronic equipment
CN115543372A (en) Terminal equipment upgrade management method, device, system and storage medium
CN110321133B (en) H5 application deployment method and device
CN115033551A (en) Database migration method and device, electronic equipment and storage medium
CN109510855B (en) Event distribution system, method and device
CN108810299B (en) Information analysis method, medium and equipment
CN112751926A (en) Method, system and related device for managing working nodes in cluster

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