A method, device, equipment and storage medium for assigning identification

By presetting the numerical set for business data and generating numerical IDs, the problem of increasing the trend of identification IDs in distributed machine clusters is solved, and the absolute increment of identification and order recognition of business data is realized, expanding the scope of business application.

CN112035460BActive Publication Date: 2025-01-14BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201910481673.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-06-04
Publication Date
2025-01-14
Estimated Expiration
2039-06-04

AI Technical Summary

Technical Problem

In the prior art, the identification ID generated based on time series tends to increase rather than absolute increments in a distributed machine cluster, resulting in the inability to identify the order of service data, limiting business applications that rely on the incremental ID.

Method used

By presetting a numerical set for each service, the numerical values ​​in the numerical set are generated based on the target termination value and the preset storage quantity. When an identification allocation request is received, the minimum value is read and deleted as the identification ID, and the numerical set is updated in real time, so as to Achieve absolute increment of the identification.

Benefits of technology

The absolute increment of the identification is realized, the order of service data can be effectively identified, the scope of business application is expanded, and the problem of application limitations in the prior art is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112035460B_ABST
    Figure CN112035460B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses an identification allocation method, device, equipment and storage medium, the method comprising: upon receiving an identification allocation request for business data, determining a current value set corresponding to the business data; reading the smallest value stored in the current value set, deleting the value read in the current value set, and returning the read value as the identification of the business data; wherein the value in the current value set is pre-generated according to the target termination value corresponding to the stored business data and the first preset storage quantity. Through the technical solution of the embodiment of the present invention, the absolute increment of the identification can be achieved, so that the order of the business data can be effectively identified based on the identification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to computer technology, and in particular to an identification allocation method, apparatus, device and storage medium. Background Art

[0002] With the increasing business and data volume, more and more systems are introducing sharding technology to provide large amounts of data storage and query services. Usually, when storing data, a unique ID needs to be assigned to each piece of stored data so that it can be used for data association or upstream and downstream interactions.

[0003] In the prior art, corresponding identification IDs are often generated and allocated based on time series to implement distributed ID services, thereby solving the single point problem of allocating identifications through database auto-increment, that is, the problem that ID services cannot be used when an abnormality occurs in the database.

[0004] However, in the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0005] Since the time of each machine in the distributed machine cluster is not uniform, the identification ID generated based on the time series of each machine is trend-increasing rather than absolutely increasing. Therefore, it is impossible to identify the order in which each business data is stored based on the identification ID. It cannot be adapted to businesses that rely on ID increments and has certain application limitations. Summary of the invention

[0006] The embodiments of the present invention provide a method, apparatus, device and storage medium for allocating identifiers to achieve absolute increment of identifiers, thereby effectively identifying the sequence of business data based on the identifiers.

[0007] In a first aspect, an embodiment of the present invention provides an identifier allocation method, including:

[0008] Upon receiving an identifier allocation request for service data, determining a current value set corresponding to the service data;

[0009] Read the smallest value stored in the current value set, delete the value read in the current value set, and return the read value as the identifier of the business data;

[0010] The values ​​in the current value set are pre-generated according to the target termination values ​​corresponding to the stored business data and the first preset storage quantity.

[0011] In a second aspect, an embodiment of the present invention further provides an identification allocation device, including:

[0012] A current value set determination module, configured to determine a current value set corresponding to the business data upon receiving an identification allocation request for the business data;

[0013] An identification returning module, used to read the smallest value stored in the current value set, delete the value read in the current value set, and return the read value as the identification of the business data;

[0014] The values ​​in the current value set are pre-generated according to the target termination values ​​corresponding to the stored business data and the first preset storage quantity.

[0015] In a third aspect, an embodiment of the present invention further provides a device, the device comprising:

[0016] one or more processors;

[0017] A memory for storing one or more programs;

[0018] When the one or more programs are executed by the one or more processors, the one or more processors implement the steps of the identifier allocation method provided by any embodiment of the present invention.

[0019] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the identifier allocation method provided in any embodiment of the present invention.

[0020] The embodiments of the above invention have the following advantages or beneficial effects:

[0021] By setting a corresponding value set for each service in advance, the values ​​in the value set can be generated according to the target termination value corresponding to each service and the first preset storage quantity, and each value set can contain multiple values ​​of different sizes. When a request for assigning an identifier of service data is received, the smallest value stored in the current value set corresponding to the service data is read, and the smallest value in the current value set is deleted, so as to update the current value set in real time, so that each time an identifier is assigned, the smallest value in the current value set is returned as the identifier of the service data, so that the size of the identifier can be used to reflect the order of storage of the service data, realizing the absolute increment of the identifier and expanding the scope of service application. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 is a flow chart of an identification allocation method provided in Embodiment 1 of the present invention;

[0023] Figure 2 is a flow chart of an identification allocation method provided by Embodiment 2 of the present invention;

[0024] Figure 3 is a structural diagram of an identification allocation device provided in Embodiment 3 of the present invention;

[0025] Figure 4 It is a structural schematic diagram of a device provided in Embodiment 4 of the present invention. DETAILED DESCRIPTION

[0026] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0027] Embodiment 1

[0028] Figure 1 This is a flowchart of an identification allocation method provided in Embodiment 1 of the present invention. This embodiment is applicable to the case where a corresponding identification ID is allocated to each service data. The method can be executed by an identification allocation device, which can be implemented by software and / or hardware and integrated into a device with information processing function, such as a server. Figure 1 As shown, the method specifically comprises the following steps:

[0029] S110. When receiving an identifier allocation request for business data, determine a current value set corresponding to the business data.

[0030] Among them, business data may refer to data to be stored under a certain business type. Exemplarily, the business type may be, but not limited to, a purchasing business type, a sales business type, an inbound business type, or an outbound business type, etc. An identification allocation request may refer to a request to allocate an identification ID for business data. An identification allocation request may include, but is not limited to, a business identification corresponding to the business data. The business identification may be composed of, but not limited to, at least one of numbers, letters, Chinese characters, and symbols, so as to distinguish different types of business. A value set may refer to a set consisting of multiple values ​​of different sizes. The data structure of a value set may be, but not limited to, an array structure or a queue structure. The current value set may refer to a value set corresponding to the business data at the current moment. The current value set in this embodiment may change in real time with the identification allocation process, that is, each time an identification is allocated, a value is missing from the current value set.

[0031] Among them, the values ​​in the current value set are pre-generated according to the target termination value corresponding to the stored business data and the first preset storage quantity. Each type of business data in this embodiment corresponds to a target termination value. The target termination value may refer to the maximum value in the current value set corresponding to the business data. The first preset storage quantity may refer to the total number of values ​​in the value set before the identifier is assigned, which can be pre-set based on business scenarios and requirements. Exemplarily, the first preset storage quantity can be set to the maximum capacity value of the value set.

[0032] Specifically, in this embodiment, a value set can be set for each type of business in advance, and the target termination value corresponding to each type of business can be stored. Each value in each value set can be generated according to the target termination value corresponding to the corresponding business and the first preset storage quantity. Exemplarily, the values ​​of the first preset storage quantity before the target termination value and including the target termination value can be used as the values ​​in the value set. For example, if the target termination value is 201 and the first preset storage quantity is 100, the 100 values ​​102-201 can be added to the value set.

[0033] Specifically, when a client needs to store a piece of business data in the backend server of the client, the client can generate an identification allocation request for the business data, and send the identification allocation request to the allocation server that executes the identification allocation method provided in this embodiment. When the allocation server receives the identification allocation request, it can parse the identification allocation request to obtain the business identification corresponding to the business data to be assigned the identification, and can determine the value set corresponding to the business identification obtained by parsing based on the correspondence between the pre-stored business identification and the value set, and use it as the current value set corresponding to the business data.

[0034] S120: read the smallest value stored in the current value set, delete the value read in the current value set, and return the read value as an identifier of the business data.

[0035] Specifically, after determining the current value set corresponding to the business data, the minimum value stored in the current value set can be sent to the client as the identifier of the business data, thereby realizing automatic allocation of the identifier, and allowing the client to store the received identifier as the identifier ID of the business data to be stored in the background server for subsequent data association or upstream and downstream interaction, etc. After reading the minimum value in the current value set, it is necessary to delete the read minimum value from the current value set in order to update the current value set in real time, so that the identifier assigned each time is the minimum value in the updated current value set, that is, the identifier assigned each time is a gradually increasing value, thereby realizing absolute increment of the identifier, and can effectively arrange the business data or identify the order of the business data based on the identifier, which is suitable for business scenarios that rely on ID increment, and solves the problem of application limitations in the prior art.

[0036] Exemplarily, when the value set is a value queue of a queue structure, S120 may include: taking out a value in the current value queue, and returning the taken out value as an identifier of the business data, wherein the values ​​in the current value queue are arranged in order from small to large.

[0037] Among them, each value in the value queue follows the first-in-first-out value-taking rule, that is, the value first added to the value queue can be taken out of the value queue first. Specifically, when adding multiple values ​​of different sizes to the value queue, each value can be added to the value queue in order from small to large, so that the smallest value can be directly taken out from the head of the value queue and returned as the identifier of the business data, and the smallest value taken out can be automatically deleted through the queue, thereby further improving the allocation efficiency.

[0038] The technical solution of this embodiment sets a corresponding value set for each service in advance, and the values ​​in the value set can be generated according to the target termination value corresponding to each service and the first preset storage quantity, and each value set can contain multiple values ​​of different sizes. When a request for assigning an identifier of service data is received, the smallest value stored in the current value set corresponding to the service data is read, and the smallest value in the current value set is deleted, so as to update the current value set in real time, so that each time an identifier is assigned, the smallest value in the current value set is returned as the identifier of the service data, so that the size of the identifier can be used to reflect the order of storage of the service data, realizing the absolute increment of the identifier and expanding the scope of service application.

[0039] On the basis of the above technical solution, "determining the current value set corresponding to the business data" in S110 may include: obtaining the target first database identifier stored in the server; based on the correspondence between the preset business identifier and the value set and the target business identifier corresponding to the business data, determining the current value set corresponding to the target business identifier from the target first database corresponding to the target first database identifier.

[0040] Among them, the server may refer to the allocation server in this embodiment or an additionally set server. The first database may refer to a database for storing various sets of values. Exemplarily, the first database may be a Redis database with a Key-Value key-value pair, wherein the key information Key may be used to store the service identifier, and the value information Value may be used to store the corresponding set of values. The first database in this embodiment may be one or more. When there are multiple first databases, each first database stores various sets of values. Each first database in this embodiment may be a distributed database cluster composed of multiple databases, so as to store more sets of values ​​and improve the scalability of the identifier allocation service. The target first database may refer to the first database currently in use. The first database identifier may be composed of but not limited to at least one of numbers, letters, Chinese characters and symbols, so as to distinguish different first databases. The target business identifier may refer to the business identifier corresponding to the business data to be assigned the identifier.

[0041] Specifically, this embodiment can pre-store the target first database identifier currently in use in the server so that the target first database identifier can be obtained through the server, and the target first database can be determined based on the target first database identifier, and the current value set corresponding to the target business identifier can be obtained in the target first database based on the correspondence between the business identifier and the value set pre-stored in the target first database.

[0042] Exemplarily, obtaining the target first database identifier stored in the server may include: obtaining the target first database identifier stored in a target server in a server cluster, wherein each server in the server cluster is a server using Zookeeper coordination service technology.

[0043] Among them, Zookeeper coordination service technology is an open source distributed application coordination service, which can provide consistency service functions for distributed applications, such as distributed coordination / notification, configuration maintenance, distributed locks and distributed queues. Each server in the server cluster stores the target first database identifier. The target server may refer to the server currently in use. After each server adopts Zookeeper coordination service technology, the single point problem can be automatically avoided. That is to say, when there is an abnormality in the currently used target server, it can automatically switch to other servers and obtain the target first database identifier from other servers, thereby ensuring that the stored target first database identifier can always be obtained, thereby improving the availability of the identifier allocation service.

[0044] On the basis of the above technical solution, "generating the values ​​in the current value set according to the target termination value corresponding to the stored business data and the first preset storage quantity" may include: obtaining the target second database identifier stored in the server; obtaining the target termination value corresponding to the target business identifier from the target second database corresponding to the target second database identifier according to the correspondence between the preset business identifier and the termination value and the target business identifier corresponding to the business data; based on the preset numerical interval, taking the target termination value and the values ​​of the second preset storage quantity before the target termination value as the values ​​in the current value set, wherein the second preset storage quantity is the difference between the first preset storage quantity and 1.

[0045] Among them, the second database can be used to store the termination value corresponding to each business. By using the second database to store each termination value, data loss after downtime can be avoided, thereby ensuring the persistence of data and improving the availability of the allocation service. The second database in this embodiment can be one or more. When there are multiple second databases, each second database stores each termination value to avoid single point problems. The target second database may refer to the second database currently in use. The second database identifier may be composed of but not limited to at least one of numbers, letters, Chinese characters and symbols to distinguish different second databases. The preset numerical interval may refer to the interval between two adjacent numerical values, which can be determined in advance based on the business scenario. For example, the preset numerical interval can be set to 1.

[0046] Specifically, in addition to storing the target first database identifier, the server can also store the target second database identifier, so that the target second database identifier currently in use can be obtained through the server, and the target second database can be determined based on the target second database identifier, and the target termination value corresponding to the target business identifier can be obtained in the target second database according to the corresponding relationship between the business identifier and the termination value pre-stored in the target second database. The value of the second preset storage quantity can be obtained every preset value interval before the target termination value, and each of the obtained values ​​and the target termination value are added to the current value set, so that the current value set can be generated. For example, when the first preset storage quantity is 1000, that is, the second preset storage quantity is 999, the target termination value is 3001, and the preset value interval is 1, then the value of the second preset storage quantity is: 2002-3000, and at this time, the 1000 values ​​of 2002-3001 can be added to the current value set.

[0047] Embodiment 2

[0048] Figure 2 This is a flowchart of an identification allocation method provided in Embodiment 2 of the present invention. Based on the above embodiment, this embodiment adds the step of "when it is detected that the current value set meets the preset supplement condition, the current value set is supplemented according to the target end value corresponding to the stored business data". The explanations of the terms that are the same or corresponding to the above embodiment are not repeated here.

[0049] See also Figure 2 The identification allocation method provided in this embodiment specifically includes the following steps:

[0050] S210, upon receiving an identifier allocation request for business data, determining a current value set corresponding to the business data;

[0051] S220: read the smallest value stored in the current value set, delete the value read in the current value set, and return the read value as an identifier of the business data.

[0052] S230: When it is detected that the current value set meets the preset supplement condition, the current value set is supplemented according to the target end value corresponding to the stored business data.

[0053] The preset supplementary condition may refer to a condition that needs to be satisfied when supplementing a value to the current value set, such as no value in the current value set or a usage rate of values ​​in the current value set greater than or equal to a preset usage rate, for example, the preset usage rate may be 70%.

[0054] Specifically, in this embodiment, after the minimum value in the current value set is returned as the identifier of the business data and the minimum value is deleted, the current value set at this time is the current value set after deletion, that is, the current value set is the value set after real-time update. By detecting whether the current value set meets the preset supplementary conditions, it can be determined whether it is necessary to add new values ​​to the current value set in order to perform subsequent identifier allocation. If it is detected that there is no value in the current value set or the value usage rate in the current value set is greater than or equal to the preset usage rate, it can be determined that the current value set needs to be supplemented with values. At this time, new values ​​can be determined based on the target termination value corresponding to the business data, and these new values ​​are added to the current value set to complete the supplement of values. Exemplarily, this embodiment can detect whether the current value set meets the preset supplementary conditions by starting an asynchronous thread, so that the current value set can be supplemented with values ​​more promptly, avoiding too long waiting time for identifier allocation for other business data, thereby improving the efficiency of identifier allocation.

[0055] It should be noted that after determining the current value set in step S210, it is also possible to first detect whether the current value set meets the preset supplement condition. If not, the operation of step S220 can be executed; if so, the current value set can be supplemented according to the target termination value corresponding to the stored business data, and the operation of step S220 can be executed after the value is supplemented.

[0056] Exemplarily, "supplementing the current value set according to the target termination value corresponding to the stored business data" in S230 may include: determining the first termination value according to the target termination value corresponding to the stored business data and the third preset storage quantity, and updating the stored target termination value to the first termination value; generating each target value according to the updated target termination value and the third preset storage quantity, and supplementing each target value to the current value set.

[0057] The third preset storage quantity may refer to the storage quantity that matches the preset supplementary condition. For example, when the preset supplementary condition is that there is no value in the current value set, the third preset storage quantity may be equal to the first preset storage quantity; when the preset supplementary condition is that the value usage rate in the current value set is greater than or equal to the preset usage rate, the third preset storage quantity may be equal to the preset usage rate of the first preset storage quantity. The first termination value may refer to the maximum value in the current value set after supplementation. The target value may refer to the new value to be supplemented.

[0058] Specifically, this embodiment can use the sum of the target termination value and the third preset storage quantity as the first termination value corresponding to the business data, and update the stored target termination value corresponding to the business data to the first termination value, so that the value after the first termination value can be supplemented at the next supplement, so that the values ​​in the value set are always gradually increased, thereby ensuring the absolute increase of the values. In this embodiment, the target termination value is updated once each time a value is supplemented. When supplementing the current value, the values ​​of the third preset storage quantity before and including the updated target termination value need to be used as each target value. Each target value can be supplemented to the current value set in order from small to large, so that the minimum value in the current value set can be obtained more quickly, thereby improving the allocation efficiency.

[0059] The technical solution of this embodiment, after returning the minimum value in the current value set as the identifier of the business data, if it is detected that the current value set meets the preset supplement condition, the current value set can be supplemented in time based on the target end value corresponding to the business data, thereby avoiding too long waiting time for identifier allocation requests of other business data and improving identifier allocation efficiency.

[0060] On the basis of the above scheme, "supplementing the current value set with values ​​according to the target end value corresponding to the stored business data" in S230 may include: detecting whether there is a preloading identifier corresponding to the business data; if so, stopping the operation of supplementing the current value set with values; if not, setting the preloading identifier, supplementing the current value set with values ​​according to the target end value corresponding to the stored business data, and deleting the preset loading identifier after the supplement is completed.

[0061] Among them, the preloading identifier may refer to an identifier used to reflect that the current value supplement is being performed. Each business in this embodiment may correspond to a preloading identifier. Exemplarily, each preloading identifier may be stored in the server so as to better coordinate the service. Specifically, when it is detected that the current value set needs to be supplemented, it can be determined whether the current value set is supplemented by detecting whether the preloading identifier corresponding to the business data is set in the server. If there is a preloading identifier corresponding to the business data, it indicates that the current value set is being supplemented for the identifier allocation request of other business data belonging to the same business type as the business data, and the operation of supplementing the current value set can be stopped at this time. If there is no preloading identifier corresponding to the business data, it indicates that there is no operation of supplementing the current value set at present. At this time, the preloading identifier can be set and the value supplement operation can be performed. When the supplement is completed, the preloading identifier needs to be deleted, so that the state of the current value set can be determined based on the preloading identifier, thereby preventing concurrent operations and improving service performance.

[0062] On the basis of the above scheme, after the stored target termination value is updated to the first termination value, it also includes: storing the updated target termination value in the server when the current value is supplemented; accordingly, when the next value is supplemented, if there is an abnormality in the target second database used to store the target termination value, the second termination value is determined according to the maximum target termination value stored in the server and the third preset storage quantity; the second termination value is stored in the storage location corresponding to the business data in the standby second database, and the current value set is supplemented based on the second termination value; the target second database identifier stored in the server is updated to the identifier corresponding to the standby second database.

[0063] Specifically, this embodiment can store the first termination value determined each time the value is supplemented in the server, so that data recovery can be performed when an abnormality exists in the target second database, thereby improving the availability of the allocation service. Exemplarily, if an abnormality exists in the target second database for storing the target termination value when the value is supplemented, that is, the target termination value cannot be obtained from the target second database, then the maximum target termination value corresponding to the stored business data can be obtained from the server, and the sum of the maximum target termination value and the third preset storage quantity is used as the second termination value, and the second termination value is stored in the standby second database. At the same time, the target second database identifier stored in the server is also updated to the identifier corresponding to the standby second database, so that the target termination value can be directly read from the standby second database during subsequent value supplementation, thereby realizing the recovery of the target termination value, and at the same time, the value can be supplemented based on the second termination value, thereby improving the availability of the second database and the performance of the allocation service.

[0064] Exemplarily, if there is an abnormality in the target second database used to store the target termination value, it is possible to first detect whether there is a second database switching identifier currently in the server. If so, the operation of "determining the second termination value based on the maximum target termination value stored in the server and the third preset storage quantity" can be stopped; if not, the second database switching identifier can be set, and the operation of "determining the second termination value based on the maximum target termination value stored in the server and the third preset storage quantity, storing the second termination value in the storage location corresponding to the business data in the standby second database, and supplementing the current value set based on the second termination value; updating the target second database identifier stored in the server to the identifier corresponding to the standby second database" is performed, and after the execution is completed, the second database switching identifier is deleted, thereby preventing concurrent operations of the second database switching.

[0065] On the basis of the above scheme, "when determining the current value set corresponding to the target business identifier in the target first database corresponding to the target first database identifier", it can also include: if there is an abnormal situation in the target first database, the current value set corresponding to the business data in the standby first database is supplemented with values ​​according to the target termination value corresponding to the stored business data; the target first database identifier stored in the server is updated to the identifier corresponding to the standby first database, so as to determine the current value set corresponding to the target business identifier from the standby first database.

[0066] Specifically, if an abnormality exists in the target first database used to store the current value set, that is, the current value set cannot be obtained from the target first database, a new value can be determined based on the target termination value stored in the target second database, and these new values ​​are added to the current value set in the standby first database. This embodiment updates the target first database identifier stored in the server to the identifier corresponding to the standby first database so that the current value set corresponding to the target business identifier can be determined from the standby first database, thereby ensuring that the current value set can always be obtained, thereby improving the availability of the first database and the performance of the allocation service. It should be noted that when switching the target first database to the standby first database, since the current value set in the standby first database is an empty set, it is necessary to supplement the current value set in the standby first database with values ​​so that the current value set in the standby first database can be used for identifier allocation.

[0067] Exemplarily, "numerically supplementing the current set of values ​​corresponding to the business data in the standby first database according to the target termination value corresponding to the stored business data" may include: detecting whether there is a first database switching identifier currently; if so, stopping the operation of numerically supplementing the current set of values ​​corresponding to the business data in the standby first database; if not, setting the first database switching identifier, numerically supplementing the current set of values ​​corresponding to the business data in the standby first database according to the target termination value corresponding to the stored business data, and deleting the first database switching identifier after the supplement is completed.

[0068] Among them, the first database switching identifier may refer to an identifier used to reflect the switching of the target first data. Exemplarily, the first database switching identifier may be stored in the server for better coordination of services. Specifically, when an abnormality is detected in the target first database, it is possible to determine whether to switch the target first database by detecting whether the first database switching identifier is set in the server. If there is a first database switching identifier, it indicates that the target first database is being switched for an identifier allocation request for other business data of the same business type as the business data, and the switching operation of the target first database can be stopped at this time. If there is no first database switching identifier, it indicates that the target first database is not currently switched. At this time, the first database switching identifier can be set and the switching operation of the target first database can be performed, and the current value set in the standby first database can be supplemented numerically. When the supplement is completed, the first database switching identifier needs to be deleted, so that the state of the first database can be determined based on the first database switching identifier, thereby preventing concurrent operations and improving service performance.

[0069] The following is an embodiment of an identifier allocation device provided by an embodiment of the present invention. The device and the identifier allocation method of the above embodiments belong to the same inventive concept. For details not described in detail in the embodiment of the identifier allocation device, reference can be made to the embodiment of the above identifier allocation method.

[0070] Embodiment 3

[0071] Figure 3 This is a schematic diagram of the structure of an identification allocation device provided in Embodiment 3 of the present invention. This embodiment is applicable to the case where a corresponding identification ID is allocated to each service data. The device may include: a current value set determination module 310 and an identification return module 320 .

[0072] Among them, the current value set determination module 310 is used to determine the current value set corresponding to the business data when receiving an identifier allocation request for the business data; the identifier return module 320 is used to read the smallest value stored in the current value set, delete the value read in the current value set, and return the read value as the identifier of the business data; wherein the values ​​in the current value set are pre-generated according to the target termination value corresponding to the stored business data and the first preset storage quantity.

[0073] Optionally, the current value set determination module 310 includes:

[0074] A target first database identifier acquisition unit, used to acquire a target first database identifier stored in the server;

[0075] The current value set determination unit is used to determine the current value set corresponding to the target business identifier from the target first database corresponding to the target first database identifier based on the correspondence between the preset business identifier and the value set and the target business identifier corresponding to the business data.

[0076] Optionally, the target first database identifier acquisition unit is specifically used to: acquire the target first database identifier stored in a target server in a server cluster, wherein each server in the server cluster is a server using Zookeeper coordination service technology.

[0077] Optionally, the value set is a value queue of a queue structure; accordingly, the identification return module 320 is specifically used to: take out a value in the current value queue, and return the taken out value as the identification of the business data, wherein the values ​​in the current value queue are arranged in order from small to large.

[0078] Optionally, the device further includes: a value determination module, specifically configured to:

[0079] Obtain a target second database identifier stored in the server; obtain a target termination value corresponding to the target business identifier from the target second database corresponding to the target second database identifier according to the correspondence between the preset business identifier and the termination value and the target business identifier corresponding to the business data; based on a preset value interval, use the target termination value and the second preset storage quantity before the target termination value as the values ​​in the current value set, wherein the second preset storage quantity is the difference between the first preset storage quantity and 1.

[0080] Optionally, the device further comprises:

[0081] The value supplement module is used to return the read value as the identifier of the business data, and when it is detected that the current value set meets the preset supplement condition, supplement the current value set according to the target end value corresponding to the stored business data.

[0082] Optionally, the numerical supplement module specifically includes:

[0083] a target termination value updating unit, configured to determine a first termination value according to a target termination value corresponding to the stored business data and a third preset storage quantity, and to update the stored target termination value to the first termination value;

[0084] The value supplement unit is used to generate each target value according to the updated target end value and the third preset storage quantity, and supplement each target value into the current value set.

[0085] Optionally, the numerical supplement module is also specifically used to: detect whether there is a preloading identifier corresponding to the business data; if so, stop the operation of numerically supplementing the current numerical set; if not, set the preloading identifier, supplement the current numerical set according to the target end value corresponding to the stored business data, and delete the preset loading identifier after the supplement is completed.

[0086] Optionally, the device further comprises:

[0087] The target end value storage module is used to store the updated target end value when the current value is supplemented in the server after the stored target end value is updated to the first end value; accordingly, the device includes:

[0088] A second termination value determination module is used to determine the second termination value according to the maximum target termination value stored in the server and the third preset storage quantity when performing the next value supplement if there is an abnormality in the target second database for storing the target termination value;

[0089] A second termination value storage module, used to store the second termination value in a storage location corresponding to the business data in the standby second database, and to supplement the current value set based on the second termination value;

[0090] The target second database identifier updating module is used to update the target second database identifier stored in the server to an identifier corresponding to the standby second database.

[0091] Optionally, the device further comprises:

[0092] The target first database switching module is used to, when determining the current value set corresponding to the target business identifier in the target first database corresponding to the target first database identifier, supplement the current value set corresponding to the business data in the standby first database according to the target termination value corresponding to the stored business data if an abnormality exists in the target first database;

[0093] The target first database identifier updating module is used to update the target first database identifier stored in the server to an identifier corresponding to the standby first database, so as to determine a current value set corresponding to the target service identifier from the standby first database.

[0094] Optionally, the target first database switching module is specifically used to:

[0095] Check whether there is a first database switching identifier currently; if so, stop the operation of supplementing the current set of values ​​corresponding to the business data in the standby first database; if not, set the first database switching identifier, supplement the current set of values ​​corresponding to the business data in the standby first database according to the target termination value corresponding to the stored business data, and delete the first database switching identifier after the supplement is completed.

[0096] The identifier allocation device provided in the embodiment of the present invention can execute the identifier allocation method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of executing the identifier allocation method.

[0097] Embodiment 4

[0098] Figure 4 A schematic diagram of the structure of a device provided in Embodiment 4 of the present invention. Figure 4 A block diagram of an exemplary device 12 suitable for use in implementing embodiments of the present invention is shown. Figure 4 The device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0099] like Figure 4 As shown, device 12 is in the form of a general purpose computing device. Components of device 12 may include, but are not limited to, one or more processors or processing units 16, system memory 28, and bus 18 that connects various system components (including system memory 28 and processing unit 16).

[0100] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.

[0101] Device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by device 12, including volatile and non-volatile media, removable and non-removable media.

[0102] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 4 not shown, usually called a "hard drive"). Although Figure 4 Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.

[0103] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 42 generally perform the functions and / or methods of the embodiments described herein.

[0104] The device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), may communicate with one or more devices that enable a user to interact with the device 12, and / or may communicate with any device that enables the device 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 22. Furthermore, the device 12 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the device 12 via a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the device 12, including, but not limited to, microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0105] The processing unit 16 executes various functional applications and data processing by running the program stored in the system memory 28, for example, implementing a method for assigning an identifier provided in an embodiment of the present invention, the method comprising:

[0106] Upon receiving an identifier allocation request for business data, determining a current value set corresponding to the business data;

[0107] Read the smallest value stored in the current value set, delete the value read in the current value set, and return the read value as the identifier of the business data;

[0108] The values ​​in the current value set are pre-generated according to the target termination values ​​corresponding to the stored business data and the first preset storage quantity.

[0109] Of course, those skilled in the art can understand that the processor can also implement the technical solution of the identifier allocation method provided by any embodiment of the present invention.

[0110] Embodiment 5

[0111] This embodiment 5 provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the steps of the identifier allocation method provided in any embodiment of the present invention are implemented. The method includes:

[0112] Upon receiving an identifier allocation request for business data, determining a current value set corresponding to the business data;

[0113] Read the smallest value stored in the current value set, delete the value read in the current value set, and return the read value as the identifier of the business data;

[0114] The values ​​in the current value set are pre-generated according to the target termination values ​​corresponding to the stored business data and the first preset storage quantity.

[0115] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.

[0116] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0117] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0118] Computer program code for performing the operations of the present invention may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0119] It should be understood by those skilled in the art that the modules or steps of the present invention described above can be implemented by a general-purpose computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, optionally, they can be implemented by a program code executable by a computer device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.

[0120] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A method for allocating an identifier, characterized in that: include: Upon receiving a request for assigning an identifier to service data, Obtaining a target first database identifier stored in the server; Based on the correspondence between the preset service identifier and the value set and the target service identifier corresponding to the service data, determine the current value set corresponding to the target service identifier from the target first database corresponding to the target first database identifier; wherein the target first database refers to the first database currently in use; and the first database is a distributed database cluster composed of multiple databases; Read the smallest value stored in the current value set, delete the value read in the current value set, and return the read value as the identifier of the business data; The values ​​in the current value set are pre-generated according to the target termination value corresponding to the stored business data and the first preset storage quantity; The determining, from the target first database corresponding to the target first database identifier, a current value set corresponding to the target service identifier includes: If the target first database has an abnormality, the current value set corresponding to the business data in the standby first database is supplemented with values ​​according to the stored target termination value corresponding to the business data; The target first database identifier stored in the server is updated to an identifier corresponding to the standby first database, so as to determine a current value set corresponding to the target service identifier from the standby first database.

2. The method according to claim 1, characterized in that Obtaining the target first database identifier stored in the server includes: A target first database identifier stored in a target server in a server cluster is obtained, wherein each server in the server cluster is a server using Zookeeper coordination service technology.

3. The method according to claim 1, characterized in that The value set is a value queue of a queue structure; Accordingly, the smallest value stored in the current value set is read, the value read in the current value set is deleted, and the read value is returned as the identifier of the business data, including: A value in the current value queue is taken out, and the taken out value is returned as the identifier of the business data, wherein the values ​​in the current value queue are arranged in order from small to large.

4. The method according to claim 1, characterized in that: Generating a value in the current value set according to the target termination value corresponding to the stored business data and the first preset storage quantity, including: Obtaining a target second database identifier stored in the server; According to the correspondence between the preset service identifier and the termination value and the target service identifier corresponding to the service data, obtaining the target termination value corresponding to the target service identifier from the target second database corresponding to the target second database identifier; Based on a preset numerical interval, the target end value and the value of the second preset storage number before the target end value are both used as the values ​​in the current numerical set, wherein the second preset storage number is the difference between the first preset storage number and 1.

5. The method according to any one of claims 1 to 4, characterized in that: After returning the read value as the identifier of the business data, the method further includes: When it is detected that the current value set meets the preset supplement condition, the current value set is supplemented according to the target end value corresponding to the stored business data.

6. The method according to claim 5, characterized in that Supplementing the current value set with a value according to the target end value corresponding to the stored business data, including: Determine a first termination value according to the target termination value corresponding to the stored business data and a third preset storage quantity, and update the stored target termination value to the first termination value; Generate each target value according to the updated target end value and the third preset storage quantity, and add each target value to the current value set.

7. The method according to claim 5, characterized in that Supplementing the current value set with a value according to the target end value corresponding to the stored business data, including: Detecting whether there is a preload identifier corresponding to the business data currently; If yes, stop the operation of adding values ​​to the current value set; If not, the preloading flag is set, and the current value set is supplemented with values ​​according to the target end value corresponding to the stored business data, and after the supplementation is completed, the preloading flag is deleted.

8. The method according to claim 6, characterized in that After updating the stored target end value to the first end value, the method further includes: The updated target end value is stored in the server when the current value is supplemented; Accordingly, when the next value supplement is performed, if there is an abnormality in the target second database for storing the target end value, the second end value is determined according to the maximum target end value stored in the server and the third preset storage quantity; storing the second termination value in a storage location corresponding to the business data in the standby second database, and supplementing the current value set based on the second termination value; The target second database identifier stored in the server is updated to an identifier corresponding to the standby second database.

9. The method according to claim 1, characterized in that: According to the stored target termination value corresponding to the service data, a current value set corresponding to the service data in the standby first database is supplemented with a value, including: Detect whether there is a first database switching identifier currently; If yes, stop the operation of supplementing the current value set corresponding to the business data in the standby first database; If not, the first database switching flag is set, and the current value set corresponding to the business data in the standby first database is supplemented according to the target termination value corresponding to the stored business data, and after the supplementation is completed, the first database switching flag is deleted.

10. A label allocation device, characterized in that: include: A current value set determination module, configured to determine a current value set corresponding to the business data upon receiving an identification allocation request for the business data; An identification returning module, used to read the smallest value stored in the current value set, delete the value read in the current value set, and return the read value as the identification of the business data; The values ​​in the current value set are pre-generated according to the target termination value corresponding to the stored business data and the first preset storage quantity; The current value set determination module comprises: A target first database identifier acquisition unit, used to acquire a target first database identifier stored in the server; A current value set determination unit is used to determine a current value set corresponding to a target business identifier from a target first database corresponding to a target first database identifier based on a correspondence between a preset business identifier and a value set and a target business identifier corresponding to the business data; wherein the target first database refers to a first database currently in use; and the first database is a distributed database cluster consisting of a plurality of databases; a target first database switching module, configured to, when determining the current value set corresponding to the target service identifier from the target first database corresponding to the target first database identifier, supplement the current value set corresponding to the service data in the standby first database according to the stored target termination value corresponding to the service data if an abnormality exists in the target first database; The target first database identifier updating module is used to update the target first database identifier stored in the server to the identifier corresponding to the standby first database, so as to determine the current value set corresponding to the target service identifier from the standby first database.

11. A device, characterized in that: The device comprises: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the steps of the identifier allocation method as described in any one of claims 1-9.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the identification allocation method as described in any one of claims 1 to 9 are implemented.

Citation Information

Patent Citations

  • High available ID generator and ID generation method and device thereof

    CN107968847A

  • Service identification management method, device, electronic device and storage medium

    CN109104490A