Order identification generation method, device, server and storage medium
Patent Information
- Application Number
- CN202010358127.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-04-29
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2040-04-29
AI Technical Summary
不同数据库的数据,如果继续采用数据库的自增订单号的方式来生成订单标识,显然不能满足需求,容易造成不同数据库访问时的冲突
[0047] Based on the above technical solution, in the present invention, the server database identification corresponding to the target database is determined through the naming service of the distributed service framework zookeeper, which can be used to distinguish the number segment values on different servers. Through the redis asynchronous cache, it can avoid system use time The congestion and lag phenomenon can also be reduced. At the same time, it can also reduce the impact of access to the database. According to the order number identification, the organization identification, the server database identification and the target number identification, the generated order identification is unique. In a distributed system, the global uniqueness of order identification is guaranteed and conflicts during database access are avoided.
Smart Images

Figure CN111694841B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of distributed technology of blockchain, and in particular to an order identification generation method, device, server and storage medium. Background Art
[0002] Currently, the system uses a single database to generate order numbers through the database's auto-increment sequence. For distributed systems, different fields will use different databases, and it is necessary to distinguish the uniqueness of a large amount of data and messages. If the data in different databases continue to use the database's auto-increment order number method to generate order identifiers, it obviously cannot meet the needs and is likely to cause conflicts when accessing different databases. Summary of the invention
[0003] In view of the above, it is necessary to provide an order identification generation method, device, server and storage medium. The present invention also relates to the field of artificial intelligence technology and can be applied to smart cities. It can make the generated order identification unique and avoid conflicts during database access.
[0004] A first aspect of the present invention provides a method for generating an order identifier, the method comprising:
[0005] Receiving an order confirmation request sent by a front-end device, wherein the order confirmation request carries an order type and a region to which the order belongs;
[0006] Determine the order number identifier according to the order type, the value weight of the order corresponding to the order type, and the order total amount data of the order, and query the institution identifier corresponding to the area to which the order belongs from the correspondence between the preset order area and the preset institution identifier;
[0007] Among the multiple databases included in the distributed system, the server database identifier corresponding to the target database is determined through the naming service of the distributed service framework Zookeeper;
[0008] Loading a first preset number of first number segments from the number segment information table of the target database into the remote dictionary service redis cache;
[0009] Extract the target number identifier of the first number segment from the redis cache;
[0010] Generate an order ID according to the order number ID, the organization ID, the server database ID and the target number ID;
[0011] In response to the order confirmation request, the order identification is sent to the front-end device.
[0012] In a possible implementation, determining the order number identifier according to the order type, the value weight of the order corresponding to the order type, and the order total amount data of the order includes:
[0013] According to the order type, determine the value weight of the order corresponding to the order type;
[0014] Obtaining order total data of the order;
[0015] Determine order priority according to the value weight and the order total amount data;
[0016] The priority identifier corresponding to the order priority is determined as the order number identifier.
[0017] In a possible implementation, determining the server database identifier corresponding to the target database through the naming service of the distributed service framework zookeeper in the multiple databases included in the distributed system includes:
[0018] Determining a target database among multiple databases included in the distributed system according to the bearing capacity value of each of the databases;
[0019] Generate a server identifier for the server to which the target database belongs through the naming service of the distributed service framework zookeeper;
[0020] The server database identifier corresponding to the target database is determined according to the database identifier of the target database and the server identifier.
[0021] In a possible implementation, determining the target database according to the tolerance value of each of the multiple databases included in the distributed system includes:
[0022] Obtain the historical access count of each database of the distributed system and the crash count of each database within a preset time;
[0023] Determine the tolerance value of each of the databases according to the historical access times and the crash times;
[0024] A target database is determined from the plurality of databases according to the tolerance value.
[0025] In a possible implementation, generating a server identifier for a server to which the target database belongs by using a naming service of a distributed service framework Zookeeper includes:
[0026] Get the flag from the database flag table;
[0027] Determine whether there is an identification bit in the identification bits that can identify the server to which the target database belongs;
[0028] If there is no identification bit in the identification bit that can identify the server to which the target database belongs, a temporary node is created through the naming service of the distributed service framework zookeeper;
[0029] The node identifier of the temporary node is determined as the server identifier of the server.
[0030] In a possible implementation, the order identifier generation method further includes:
[0031] Create a listening event;
[0032] Through the monitoring event, the usage status of the first number segment in the redis cache is monitored.
[0033] In a possible implementation, the order identifier generation method further includes:
[0034] According to the usage status, obtaining a current usage value;
[0035] Determine whether the position of the currently used value is within the boundary value range of the first number segment;
[0036] If the position of the currently used value is within the boundary value range of the first number segment, a second preset number of second number segments is asynchronously loaded from the number segment information table into the redis cache.
[0037] A second aspect of the present invention provides an order identification generating device, the order identification generating device comprising:
[0038] A receiving module, configured to receive an order confirmation request sent by a front-end device, wherein the order confirmation request carries an order type and a region to which the order belongs;
[0039] A determination module, configured to determine the order number identifier according to the order type, the value weight of the order corresponding to the order type, and the order total amount data of the order, and to query the institution identifier corresponding to the area to which the order belongs from the correspondence between the preset order area and the preset institution identifier;
[0040] The determination module is further used to determine the server database identifier corresponding to the target database through the naming service of the distributed service framework zookeeper among the multiple databases included in the distributed system;
[0041] A loading module, used for loading a first preset number of first number segments from the number segment information table of the target database into a remote dictionary service redis cache;
[0042] An extraction module, used for extracting the target number identifier of the first number segment from the redis cache;
[0043] A generating module, used for generating an order identifier according to the order number identifier, the institution identifier, the server database identifier and the target number identifier;
[0044] The sending module is used to respond to the order confirmation request and send the order identification to the front-end device.
[0045] A third aspect of the present invention provides a server, the server comprising a processor and a memory, the processor being configured to implement the order identification generation method when executing a computer program stored in the memory.
[0046] A fourth aspect of the present invention provides a computer-readable storage medium, comprising a data storage area and a program storage area, wherein the data storage area stores data created according to the use of a blockchain node, and the program storage area stores a computer program, wherein the computer program implements the order identifier generation method when executed by a processor.
[0047] According to the above technical scheme, in the present invention, the server database identifier corresponding to the target database is determined through the naming service of the distributed service framework Zookeeper, which can be used to distinguish the segment values on different servers. Through the redis asynchronous cache, congestion and jamming during system use can be avoided. At the same time, the impact on database access can be reduced. The order identifier generated according to the order number identifier, the organization identifier, the server database identifier and the target number identifier is unique. In the distributed system, the global uniqueness of the order identifier is guaranteed, and conflicts during database access are avoided. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 It is a flow chart of a preferred embodiment of a method for generating an order identifier disclosed by the present invention.
[0049] Figure 2 It is a functional module diagram of a preferred embodiment of an order identification generating device disclosed in the present invention.
[0050] Figure 3 It is a schematic diagram of the structure of a server of a preferred embodiment of the method for generating an order identifier according to the present invention. DETAILED DESCRIPTION
[0051] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0052] The terms "first" and "second" in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, but not necessarily to describe a specific order or sequence, and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein, and the features defined as "first" and "second" can explicitly or implicitly include at least one of the features.
[0053] In addition, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus that includes a series of steps or elements is not necessarily limited to those steps or elements explicitly listed, but may include other steps or elements not explicitly listed or inherent to such process, method, product, or apparatus.
[0054] In addition, the technical solutions between the various embodiments can be combined with each other, but it must be based on the fact that ordinary technicians in the field can implement it. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0055] Figure 1 The flowchart of a preferred embodiment of the order identification generation method disclosed in the present invention is applied to a server. According to different requirements, the order of the steps in the flowchart can be changed and some steps can be omitted.
[0056] S11. Receive an order confirmation request sent by a front-end device, wherein the order confirmation request carries the order type and the region to which the order belongs.
[0057] The front-end device is for users, and may include but is not limited to a smartphone, a personal computer, an IPAD or other electronic devices that can be operated by the user. The user can perform operations on the front-end device, such as submitting a product order when purchasing an online product.
[0058] In an embodiment of the present invention, when an order confirmation request is received from a front-end device, it indicates that the user needs to purchase the goods corresponding to the order. At this time, the order has not generated an order identifier, that is, an order number that uniquely identifies the order, and the server needs to be triggered to generate a unique order identifier based on the order confirmation request.
[0059] Among them, the order type can be used to indicate the type of goods that the user needs to purchase, such as insurance, and the order region can be used to indicate the region where the front-end device is located when the order is submitted, such as a certain city.
[0060] S12. Determine the order number identifier according to the order type, the value weight of the order corresponding to the order type, and the total order amount data of the order, and query the institution identifier corresponding to the area to which the order belongs from the correspondence between the preset order area and the preset institution identifier.
[0061] Among them, the order number identification corresponding to different order types is different, and the institution identification corresponding to different order regions is also different.
[0062] Specifically, determining the order number identifier according to the order type, the value weight of the order corresponding to the order type, and the order total amount data of the order includes:
[0063] According to the order type, determine the value weight of the order corresponding to the order type;
[0064] Obtaining order total data of the order;
[0065] Determine order priority according to the value weight and the order total amount data;
[0066] The priority identifier corresponding to the order priority is determined as the order number identifier.
[0067] In this embodiment, the value weights of orders corresponding to different order types are different. The value weights can be used to measure the value of a certain order, and the range of the value weights can be set to [0,1]. Generally, the larger the value weight, the greater the value of the order, and also indicates that the order is very important to the user. The total order amount data can reflect the data that the user needs to pay to purchase the order. The order priority can be determined based on the value weight and the total order amount data, such as multiplying the value weight by the total order amount data to obtain the product value, and then searching for the order priority corresponding to the product value based on the product value. Finally, the priority identifier corresponding to the order priority can be determined as the order number identifier. Among them, the order priority can reflect the priority order in which the order is processed. After the order identifier is generated, the order order of the orders can be determined based on the order priority in the order identifier, so as to provide more efficient order processing services and user experience for high-quality users.
[0068] Among them, a correspondence between the area to which an order belongs and the institution identification can be established in advance. In this correspondence, each area to which an order belongs corresponds to an institution identification, for example: the institution identification corresponding to Fuzhou City is 3910.
[0069] Optionally, a correspondence between order types and order numbers may be pre-established, in which each order type corresponds to an order number, for example, the order number corresponding to the quotation is Q, and the order number corresponding to the insurance policy is 10.
[0070] S13. Among the multiple databases included in the distributed system, determine the server database identifier corresponding to the target database through the naming service of the distributed service framework zookeeper.
[0071] The distributed system may include multiple databases, and different servers may share a database or configure a database separately. The target database may be a database bound to the started server, or the target database may be a database determined from multiple databases in the distributed system according to the bearing capacity of the database.
[0072] Among them, ZooKeeper is a distributed, open source distributed application coordination service, an open source implementation of Google's Chubby, and an important component of Hadoop and Hbase. It is a software that provides consistency services for distributed applications, and its functions include: configuration maintenance, domain name services, distributed synchronization, group services, etc.
[0073] Specifically, in the multiple databases included in the distributed system, determining the server database identifier corresponding to the target database through the naming service of the distributed service framework zookeeper includes:
[0074] Determining a target database among multiple databases included in the distributed system according to the bearing capacity value of each of the databases;
[0075] Generate a server identifier for the server to which the target database belongs through the naming service of the distributed service framework zookeeper;
[0076] According to the database identifier of the target database and the server identifier, a server database identifier corresponding to the target database is determined.
[0077] In this implementation, a target database can be selected from multiple databases in a distributed system to reduce the impact on databases with weaker tolerance. At the same time, a unique server identifier is generated through the naming service of the distributed service framework Zookeeper. According to the database identifier and the server identifier, the server database identifier corresponding to the target database is determined. The server database identifier can be used to distinguish the number segment values of databases of different servers. Each database can store multiple number segment values in advance.
[0078] Specifically, among the multiple databases included in the distributed system, determining the target database according to the bearing capacity value of each of the databases includes:
[0079] Obtain the historical access count of each database of the distributed system and the crash count of each database within a preset time;
[0080] Determine the tolerance value of each of the databases according to the historical access times and the crash times;
[0081] A target database is determined from the plurality of databases according to the tolerance value.
[0082] In the distributed system, the storage capacity of each database is different, the number of historical accesses to each database is also different, and the number of crashes of each database within a preset time (such as within a month) is also different. If the number of accesses is large and the number of crashes is small, it indicates that the database has a good tolerance. Therefore, the target database can be selected according to the tolerance of the database.
[0083] Specifically, weight values can be set for the number of historical accesses and the number of crashes, respectively, wherein the weight value of the number of historical accesses can be set higher than the weight value of the number of crashes. According to the weight value, the number of historical accesses and the number of crashes, the bearing capacity value of each database is determined, and a target database whose bearing capacity value exceeds a preset threshold is selected from multiple databases. In this way, databases with high bearing capacity and not prone to crash can be selected first, so that the databases in the distributed system can be reasonably utilized, reducing the impact on databases with weaker bearing capacity, and improving the service life of the database.
[0084] Specifically, generating a server identifier for the server through a naming service of a distributed service framework Zookeeper includes:
[0085] Get the flag from the database flag table;
[0086] Determine whether there is an identification bit in the identification bits that can identify the server;
[0087] If there is no identification bit that can identify the server in the identification bit, create a temporary node through the naming service of the distributed service framework zookeeper;
[0088] The node identifier of the temporary node is determined as the server identifier of the server.
[0089] Among them, a database identifier can be created for each database in advance, and a database identifier table can be created based on the database identifier. Since different servers can share the same database, in order to distinguish different servers, a unique server identifier can be created for each server through the naming service of the distributed service framework zookeeper. The database identifier table can be updated based on the database identifier and the server identifier, that is, the updated database identifier table can be used to distinguish the segment values of databases of different servers.
[0090] Usually, different servers go online and offline at different times. If the server is started for the first time, it has no server ID, that is, the ID in the current database ID table cannot identify the server. Therefore, Zookeeper needs to create a unique server ID for the server. At the same time, update the database ID table.
[0091] S14. Load a first preset number of first number segments from the number segment information table of the target database into the remote dictionary service redis cache.
[0092] Among them, a new segment information table will be created in each database, and the segment information table includes multiple numbers. After determining the target database, the first preset number of first segments in the segment information table of the target database can be loaded into the remote dictionary service redis cache, wherein the first preset number is, for example, 100, for example, segments from 1 to 100 can be loaded into redis, and the segments can be directly extracted from redis later without extracting from the database, thereby reducing the access impact on the database.
[0093] Specifically, when loading, a number value queue can be generated in the redis cache. For example, when loading a number segment from 1 to 100, a queue [1, 2, 3...100] is generated.
[0094] S15. Extract the target number identifier of the first number segment from the redis cache.
[0095] Usually, the server will go online or offline due to some reasons (such as human operation, failure), which will cause the number segments stored on the server to be lost. In order to avoid this situation as much as possible, in the embodiment of the present invention, when deploying the device, the redis cache is deployed separately from the server, that is, the redis cache is not integrated on the server. Since the stability of the redis cache is higher than that of the server, there are rarely problems. The first number segment is stored in the remote dictionary service redis cache, and the target number identifier is subsequently extracted from the redis cache without the need to extract the target number identifier from the server. The online / offline of the server will not affect redis. Even if the server is offline, the segment identifier can still be extracted from the redis cache, reducing the loss of the segment.
[0096] The order identification generation method further includes:
[0097] Create a listening event;
[0098] Through the monitoring event, the usage status of the first number segment in the redis cache is monitored.
[0099] In this implementation, each time the target number identifier is extracted from the redis cache, a monitoring event can be created, and the monitoring event is used to monitor the usage status of the first number segment in the redis cache, that is, it can monitor which number is currently used by the first number segment. For example, if the target number identifier of the first number segment is extracted as 90, it can be monitored that the number "90" is currently used. By monitoring events, the usage of the number segments in the redis cache can be monitored in a timely manner to prevent the loss of number segments, and at the same time, it is convenient for the timely replenishment of subsequent number segments.
[0100] The order identification generation method further includes:
[0101] According to the usage status, obtaining a current usage value;
[0102] Determine whether the position of the currently used value is within the boundary value range of the first number segment;
[0103] If the position of the currently used value is within the boundary value range of the first number segment, a second preset number of second number segments is asynchronously loaded from the number segment information table into the redis cache.
[0104] In this embodiment, the first number segment is composed of multiple numbers, that is, it represents the range of a number segment, and the boundary value range of the number segment is usually the value range of the number close to the end of the number segment. For example, the range of the first number segment is [1,100], and the boundary value range can be set to [90,100]. If the position of the currently used value is in the boundary value range of the first number segment, it indicates that the first number segment is about to be used up. For example, if the current usage value is 90, it is in the boundary value range. In order to avoid the situation where the number segment in redis is used up but no number segment is loaded, when the position of the currently used value is in the boundary value range of the first number segment, the second number segment of a second preset number can be asynchronously loaded from the segment information table to the redis cache to ensure that there are enough number segments available in redis. For example, 100 second number segment values of [101,200] can be loaded into redis.
[0105] This asynchronous caching method avoids congestion and lag when the system is in use.
[0106] S16. Generate an order ID according to the order number ID, the organization ID, the server database ID and the target number ID.
[0107] Optionally, the order number identifier, the organization identifier, the server database identifier and the target number identifier may be superimposed together according to a preset identifier superposition rule to generate an order identifier.
[0108] Optionally, the order number identifier, the organization identifier, the server database identifier and the target number identifier can also be input into an identifier generation model to generate an order identifier, wherein the identifier generation model is pre-trained and calculates a unique identifier (such as an order identifier) by inputting identifiers of several parameters (such as the order number identifier, the organization identifier, the server database identifier and the target number identifier).
[0109] In a distributed system, it can be used to generate a unique identifier.
[0110] S17. Respond to the order confirmation request and send the order identifier to the front-end device.
[0111] Among them, after the server sends the order identification to the front-end device, the order identification and other information about the order, such as the order address, the orderer, the order after-sales service, etc., can be output on the front-end device.
[0112] exist Figure 1 In the described method flow, the server database identifier corresponding to the target database is determined through the naming service of the distributed service framework Zookeeper, which can be used to distinguish the number segment values on different servers. Through the redis asynchronous cache, congestion and jamming during system use can be avoided. At the same time, the impact on database access can be reduced. The order identifier generated according to the order number identifier, the organization identifier, the server database identifier and the target number identifier is unique. In the distributed system, the global uniqueness of the order identifier is guaranteed, and conflicts during database access are avoided.
[0113] The above is only a specific implementation of the present invention, but the protection scope of the present invention is not limited thereto. For ordinary technicians in this field, improvements can be made without departing from the creative concept of the present invention, but these all belong to the protection scope of the present invention.
[0114] Figure 2 It is a functional module diagram of a preferred embodiment of an order identification generating device disclosed in the present invention.
[0115] In some embodiments, the order identification generating device is run in a server. The order identification generating device may include a plurality of functional modules composed of program code segments. The program code of each program segment in the order identification generating device may be stored in a memory and executed by at least one processor to execute Figure 1 Part or all of the steps in the described method for generating an order identifier.
[0116] In this embodiment, the order identification generating device can be divided into multiple functional modules according to the functions it performs. The functional modules may include: a receiving module 201, a determining module 202, a loading module 203, an extracting module 204, a generating module 205 and a sending module 206. The module referred to in the present invention refers to a series of computer program segments that can be executed by at least one processor and can complete fixed functions, which are stored in a memory.
[0117] The receiving module 201 is used to receive an order confirmation request sent by a front-end device, wherein the order confirmation request carries an order type and a region to which the order belongs.
[0118] The front-end device is for users, and may include but is not limited to a smartphone, a personal computer, an IPAD or other electronic devices that can be operated by the user. The user can perform operations on the front-end device, such as submitting a product order when purchasing an online product.
[0119] In an embodiment of the present invention, when an order confirmation request is received from a front-end device, it indicates that the user needs to purchase the goods corresponding to the order. At this time, the order has not generated an order identifier, that is, an order number that uniquely identifies the order, and the server needs to be triggered to generate a unique order identifier based on the order confirmation request.
[0120] Among them, the order type can be used to indicate the type of goods that the user needs to purchase, such as insurance, and the order region can be used to indicate the region where the front-end device is located when the order is submitted, such as a certain city.
[0121] Determination module 202 is used to determine the order number identifier based on the order type, the value weight of the order corresponding to the order type and the order total amount data of the order, and to query the institution identifier corresponding to the area to which the order belongs from the correspondence between the preset order area and the preset institution identifier.
[0122] Among them, the order number identification corresponding to different order types is different, and the institution identification corresponding to different order regions is also different.
[0123] Optionally, a correspondence between order types and order numbers can be established in advance. In this correspondence, each order type corresponds to an order number, for example, the order number corresponding to the quotation is Q, and the order number corresponding to the insurance policy is 10 heads. Similarly, a correspondence between the region to which the order belongs and the institution identification can be established in advance. In this correspondence, each order region corresponds to an institution identification, for example, the institution identification corresponding to Fuzhou is 3910.
[0124] Optionally, determining the order number identifier according to the order type, the value weight of the order corresponding to the order type, and the order total amount data of the order includes:
[0125] According to the order type, determine the value weight of the order corresponding to the order type;
[0126] Obtaining order total data of the order;
[0127] Determine order priority according to the value weight and the order total amount data;
[0128] The priority identifier corresponding to the order priority is determined as the order number identifier.
[0129] In this embodiment, the value weights of orders corresponding to different order types are different. The value weights can be used to measure the value of a certain order, and the range of the value weights can be set to [0,1]. Generally, the larger the value weight, the greater the value of the order, and also indicates that the order is very important to the user. The total order amount data can reflect the data that the user needs to pay to purchase the order. The order priority can be determined based on the value weight and the total order amount data, such as multiplying the value weight by the total order amount data to obtain the product value, and then searching for the order priority corresponding to the product value based on the product value. Finally, the priority identifier corresponding to the order priority can be determined as the order number identifier. Among them, the order priority can reflect the priority order in which the order is processed. After the order identifier is generated, the order order of the orders can be determined based on the order priority in the order identifier, so as to provide more efficient order processing services and user experience for high-quality users.
[0130] The determination module 202 is further used to determine the server database identifier corresponding to the target database through the naming service of the distributed service framework zookeeper among the multiple databases included in the distributed system.
[0131] The distributed system may include multiple databases, and different servers may share a database or configure a database separately. The target database may be a database bound to the started server, or the target database may be a database determined from multiple databases in the distributed system according to the bearing capacity of the database.
[0132] Specifically, in the multiple databases included in the distributed system, determining the server database identifier corresponding to the target database through the naming service of the distributed service framework zookeeper includes:
[0133] Determining a target database among multiple databases included in the distributed system according to the bearing capacity value of each of the databases;
[0134] Generate a server identifier for the server to which the target database belongs through the naming service of the distributed service framework zookeeper;
[0135] The server database identifier corresponding to the target database is determined according to the database identifier of the target database and the server identifier.
[0136] In this implementation, a target database can be selected from multiple databases in a distributed system to reduce the impact on databases with weaker tolerance. At the same time, a unique server identifier is generated through the naming service of the distributed service framework Zookeeper. According to the database identifier and the server identifier, the server database identifier corresponding to the target database is determined. The server database identifier can be used to distinguish the number segment values of databases of different servers. Each database can store multiple number segment values in advance.
[0137] Specifically, among the multiple databases included in the distributed system, determining the target database according to the bearing capacity value of each of the databases includes:
[0138] Obtain the historical access count of each database of the distributed system and the crash count of each database within a preset time;
[0139] Determine the tolerance value of each of the databases according to the historical access times and the crash times;
[0140] A target database is determined from the plurality of databases according to the tolerance value.
[0141] In the distributed system, the storage capacity of each database is different, the number of historical accesses to each database is also different, and the number of crashes of each database within a preset time (such as within a month) is also different. If the number of accesses is large and the number of crashes is small, it indicates that the database has a good tolerance. Therefore, the target database can be selected according to the tolerance of the database.
[0142] Specifically, weight values can be set for the number of historical accesses and the number of crashes, respectively, wherein the weight value of the number of historical accesses can be set higher than the weight value of the number of crashes. According to the weight value, the number of historical accesses and the number of crashes, the bearing capacity value of each database is determined, and a target database whose bearing capacity value exceeds a preset threshold is selected from multiple databases. In this way, databases with high bearing capacity and not prone to crash can be selected first, so that the databases in the distributed system can be reasonably utilized, reducing the impact on databases with weaker bearing capacity, and improving the service life of the database.
[0143] Specifically, generating a server identifier for the server through a naming service of a distributed service framework Zookeeper includes:
[0144] Get the flag from the database flag table;
[0145] Determine whether there is an identification bit in the identification bits that can identify the server;
[0146] If there is no identification bit that can identify the server in the identification bit, create a temporary node through the naming service of the distributed service framework zookeeper;
[0147] The node identifier of the temporary node is determined as the server identifier of the server.
[0148] Among them, a database identifier can be created for each database in advance, and a database identifier table can be created based on the database identifier. Since different servers can share the same database, in order to distinguish different servers, a unique server identifier can be created for each server through the naming service of the distributed service framework zookeeper. The database identifier table can be updated based on the database identifier and the server identifier, that is, the updated database identifier table can be used to distinguish the segment values of databases of different servers.
[0149] Usually, different servers go online and offline at different times. If the server is started for the first time, it has no server ID, that is, the ID in the current database ID table cannot identify the server. Therefore, Zookeeper needs to create a unique server ID for the server. At the same time, update the database ID table.
[0150] The loading module 203 is used to load a first preset number of first number segments from the number segment information table of the target database into the remote dictionary service redis cache.
[0151] Among them, a new segment information table will be created in each database, and the segment information table includes multiple numbers. After determining the target database, the first preset number of first segments in the segment information table of the target database can be loaded into the remote dictionary service redis cache, wherein the first preset number is, for example, 100, for example, segments from 1 to 100 can be loaded into redis, and the segments can be directly extracted from redis later without extracting from the database, thereby reducing the access impact on the database.
[0152] Specifically, when loading, a number value queue can be generated in the redis cache. For example, when loading a number segment from 1 to 100, a queue [1, 2, 3...100] is generated.
[0153] The extraction module 204 is used to extract the target number identifier of the first number segment from the redis cache.
[0154] Usually, the server will go online or offline due to some reasons (such as human operation, failure), which will cause the number segments stored on the server to be lost. In order to avoid this situation as much as possible, in the embodiment of the present invention, when deploying the device, the redis cache is deployed separately from the server, that is, the redis cache is not integrated on the server. Since the stability of the redis cache is higher than that of the server, there are rarely problems. The first number segment is stored in the remote dictionary service redis cache, and the target number identifier is subsequently extracted from the redis cache without the need to extract the target number identifier from the server. The online / offline of the server will not affect redis. Even if the server is offline, the segment identifier can still be extracted from the redis cache, reducing the loss of the segment.
[0155] The generating module 205 is used to generate an order identifier according to the order number identifier, the organization identifier, the server database identifier and the target number identifier.
[0156] Optionally, the order number identifier, the organization identifier, the server database identifier and the target number identifier may be superimposed together according to a preset identifier superposition rule to generate an order identifier.
[0157] Optionally, the order number identifier, the organization identifier, the server database identifier and the target number identifier can also be input into an identifier generation model to generate an order identifier, wherein the identifier generation model is pre-trained and calculates a unique identifier (such as an order identifier) by inputting identifiers of several parameters (such as the order number identifier, the organization identifier, the server database identifier and the target number identifier).
[0158] In a distributed system, it can be used to generate a unique identifier.
[0159] The sending module 206 is used to respond to the order confirmation request and send the order identification to the front-end device.
[0160] Among them, after the server sends the order identification to the front-end device, the order identification and other information about the order, such as the order address, the orderer, the order after-sales service, etc., can be output on the front-end device.
[0161] exist Figure 2In the described device, the server database identifier corresponding to the target database is determined through the naming service of the distributed service framework Zookeeper, which can be used to distinguish the segment values on different servers. Through the redis asynchronous cache, congestion and jamming during system use can be avoided. At the same time, the impact on database access can be reduced. The order identifier generated according to the order number identifier, the organization identifier, the server database identifier and the target number identifier is unique. In the distributed system, the global uniqueness of the order identifier is guaranteed, and conflicts during database access are avoided.
[0162] Figure 3 The server 3 includes a memory 31, at least one processor 32, a computer program 33 stored in the memory 31 and executable on the at least one processor 32, and at least one communication bus 34.
[0163] Those skilled in the art will understand that Figure 3 The schematic diagram shown is merely an example of the server 3 and does not constitute a limitation on the server 3. The server 3 may include more or fewer components than shown in the diagram, or a combination of certain components, or different components. For example, the server 3 may also include input and output devices, network access devices, etc.
[0164] The at least one processor 32 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 32 may be a microprocessor or any conventional processor, etc. The processor 32 is the control center of the server 3, and uses various interfaces and lines to connect various parts of the entire server 3.
[0165] The memory 31 can be used to store the computer program 33 and / or modules / units. The processor 32 implements various functions of the server 3 by running or executing the computer program and / or modules / units stored in the memory 31 and calling the data stored in the memory 31. The memory 31 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data (such as audio data) created according to the use of the server 3, etc. In addition, the memory 31 can include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices.
[0166] Combination Figure 1 The memory 31 in the server 3 stores a plurality of instructions to implement a method for generating an order identifier, and the processor 32 can execute the plurality of instructions to implement:
[0167] Receiving an order confirmation request sent by a front-end device, wherein the order confirmation request carries an order type and a region to which the order belongs;
[0168] Determine the order number identifier according to the order type, the value weight of the order corresponding to the order type, and the order total amount data of the order, and query the institution identifier corresponding to the area to which the order belongs from the correspondence between the preset order area and the preset institution identifier;
[0169] Among the multiple databases included in the distributed system, the server database identifier corresponding to the target database is determined through the naming service of the distributed service framework Zookeeper;
[0170] Loading a first preset number of first number segments from the number segment information table of the target database into the remote dictionary service redis cache;
[0171] Extract the target number identifier of the first number segment from the redis cache;
[0172] Generate an order ID according to the order number ID, the organization ID, the server database ID and the target number ID;
[0173] In response to the order confirmation request, the order identification is sent to the front-end device.
[0174] Specifically, the specific implementation method of the processor 32 for the above instructions can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0175] exist Figure 3 In the described server 3, the server database identifier corresponding to the target database is determined through the naming service of the distributed service framework Zookeeper, which can be used to distinguish the segment values on different servers. Through the redis asynchronous cache, congestion and jamming during system use can be avoided. At the same time, the impact on database access can be reduced. The generated order identifier is unique based on the order number identifier, the organization identifier, the server database identifier and the target number identifier. In the distributed system, the global uniqueness of the order identifier is guaranteed, and conflicts during database access are avoided.
[0176] If the module / unit integrated in the server 3 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory and read-only memory (ROM, Read-Only Memory).
[0177] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0178] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0179] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0180] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0181] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0182] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0183] It is obvious to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential features of the present invention. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present invention is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any accompanying figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the system claim may also be implemented by one unit or device through software or hardware.
[0184] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A method for generating an order identifier, applied in a server, It is characterized in that The order identification generation method comprises: Receiving an order confirmation request sent by a front-end device, wherein the order confirmation request carries an order type and a region to which the order belongs; Determine the order number identifier according to the order type, the value weight of the order corresponding to the order type, and the order total amount data of the order; From the correspondence between the preset order region and the preset organization identifier, query the organization identifier corresponding to the order region; Among the multiple databases included in the distributed system, the server database identifier corresponding to the target database is determined through the naming service of the distributed service framework Zookeeper; Loading a first preset number of first number segments from the number segment information table of the target database into the remote dictionary service redis cache; Extract the target number identifier of the first number segment from the redis cache; Generate an order ID according to the order number ID, the organization ID, the server database ID and the target number ID; In response to the order confirmation request, the order identification is sent to the front-end device.
2. The method for generating an order identifier according to claim 1, It is characterized in that Determining the order number identifier according to the order type, the value weight of the order corresponding to the order type, and the order total amount data of the order includes: According to the order type, determine the value weight of the order corresponding to the order type; Obtaining order total data of the order; Determine order priority according to the value weight and the order total amount data; The priority identifier corresponding to the order priority is determined as the order number identifier.
3. The method for generating an order identifier according to claim 1, It is characterized in that Determining the server database identifier corresponding to the target database through the naming service of the distributed service framework zookeeper in the multiple databases included in the distributed system includes: Determining a target database among multiple databases included in the distributed system according to the bearing capacity value of each of the databases; Generate a server identifier for the server to which the target database belongs through the naming service of the distributed service framework zookeeper; The server database identifier corresponding to the target database is determined according to the database identifier of the target database and the server identifier.
4. The method for generating an order identifier according to claim 3, It is characterized in that The step of determining the target database according to the bearing capacity value of each of the multiple databases included in the distributed system comprises: Obtain the historical access count of each database of the distributed system and the crash count of each database within a preset time; Determine the tolerance value of each of the databases according to the historical access times and the crash times; A target database is determined from the plurality of databases according to the tolerance value.
5. The method for generating an order identifier according to claim 3, It is characterized in that The generating of a server identifier for the server to which the target database belongs by using the naming service of the distributed service framework zookeeper includes: Get the flag from the database flag table; Determine whether there is an identification bit in the identification bits that can identify the server to which the target database belongs; If there is no identification bit in the identification bit that can identify the server to which the target database belongs, a temporary node is created through the naming service of the distributed service framework zookeeper; The node identifier of the temporary node is determined as the server identifier of the server.
6. The method for generating an order identifier according to any one of claims 1 to 5, It is characterized in that The order identification generation method further includes: Create a listening event; Through the monitoring event, the usage status of the first number segment in the redis cache is monitored.
7. The method for generating an order identifier according to claim 6, further comprising: include: According to the usage status, obtaining a current usage value; Determine whether the position of the currently used value is within the boundary value range of the first number segment; If the position of the currently used value is within the boundary value range of the first number segment, a second preset number of second number segments is asynchronously loaded from the number segment information table into the redis cache.
8. An order identification generating device, It is characterized in that The order identification generating device comprises: A receiving module, configured to receive an order confirmation request sent by a front-end device, wherein the order confirmation request carries an order type and a region to which the order belongs; A determination module, configured to determine the order number identifier according to the order type, the value weight of the order corresponding to the order type, and the order total amount data of the order, and to query the institution identifier corresponding to the area to which the order belongs from the correspondence between the preset order area and the preset institution identifier; The determination module is further used to determine the server database identifier corresponding to the target database through the naming service of the distributed service framework zookeeper among the multiple databases included in the distributed system; A loading module, used for loading a first preset number of first number segments from the number segment information table of the target database into a remote dictionary service redis cache; An extraction module, used for extracting the target number identifier of the first number segment from the redis cache; A generating module, used for generating an order identifier according to the order number identifier, the organization identifier, the server database identifier and the target number identifier; The sending module is used to respond to the order confirmation request and send the order identification to the front-end device.
9. A server, It is characterized in that The server includes a processor and a memory, and the processor is used to execute a computer program stored in the memory to implement the order identification generation method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, comprising a data storage area and a program storage area, wherein the data storage area stores data created according to the use of a blockchain node, and the program storage area stores a computer program, It is characterized in that When the computer program is executed by a processor, the order identification generating method as described in any one of claims 1 to 7 is implemented.
