A data processing method and related device
Patent Information
- Application Number
- CN202211077228.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-02
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2042-09-02
AI Technical Summary
[0076]In this embodiment, an access request from a target identifier generator, carrying a target machine number, is received. The target identifier generator is then verified for access based on the target machine number. If the target identifier generator passes the access verification, it is connected to the distributed system. Finally, the target identifier generators in the distributed system are scheduled to provide identifier generation services to the business system based on the target machine number. On one hand, this distributed system provides stable and highly available identifier generation services to the business system. On the other hand, the access verification mechanism based on the target machine number, which unifies the management of identifier generators in the distributed system, ensures the performance of the entire distributed system.
Smart Images

Figure CN117688002B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to a data processing method, a data processing device, a computer equipment, a computer-readable storage medium, and a computer program product. Background Technology
[0002] As business systems become increasingly feature-rich, their demand for identifier generation services is also growing. For example, in a document business system, every time a new document is generated, it needs to request a unique identifier for that document. How to provide a stable and highly available identifier generation service for business systems is a problem that urgently needs to be solved. Summary of the Invention
[0003] This application provides a data processing method and related equipment that can provide stable and highly available identifier generation services for business systems.
[0004] On one hand, embodiments of this application provide a data processing method applied to a distributed system, which schedules one or more identifier generators to provide identifier generation services to a business system; the method includes:
[0005] Receive the access request from the target identifier generator, which carries the target machine number in the access request;
[0006] Access verification is performed on the target identifier generator based on the target machine number;
[0007] If the target identifier generator passes the access verification, then the target identifier generator will be connected to the distributed system; and,
[0008] In a distributed scheduling system, the target identifier generator provides identifier generation services to the business system based on the target machine number.
[0009] On one hand, embodiments of this application provide a data processing method applied to a distributed system, which schedules one or more identifier generators to provide identifier generation services to a business system; the method includes:
[0010] Send an access request to the service center device of the distributed system. The access request carries the target machine number. The access request is used to request the service center device to perform access verification on the target identifier generator according to the target machine number, and to request the service center device to connect the target identifier generator to the distributed system after the access verification is passed.
[0011] According to the scheduling of the service center equipment, the identifier generation service is provided to the business system based on the target machine number.
[0012] On one hand, embodiments of this application provide a data processing apparatus applied to a distributed system. The distributed system schedules one or more identifier generators to provide identifier generation services to a business system. The apparatus includes:
[0013] The receiving unit is used to receive the access request from the target identifier generator, which carries the target machine number in the access request;
[0014] The processing unit is used to perform access verification on the target identifier generator based on the target machine number;
[0015] The processing unit is further configured to connect the target identifier generator to the distributed system if the target identifier generator passes the access verification; and,
[0016] The processing unit is also used to schedule the target identifier generator in the distributed system to provide identifier generation services to the business system based on the target machine number.
[0017] In one embodiment, the distributed system includes a first machine number list, which records at least one machine number that is already in use.
[0018] When performing access verification on the target identifier generator based on the target machine number, the processing unit can specifically be used for:
[0019] Compare the target machine number with at least one machine number that is already in use in the first machine number list;
[0020] If the target machine number is not an already occupied machine number, then the target identifier generator is confirmed to have passed the access verification.
[0021] If the target machine number is already in use, then the target identifier generator has failed the access verification.
[0022] In one embodiment, the database of the distributed system further includes a second machine number list, which includes at least one allowed machine number; the target machine number refers to any machine number allowed in the second machine number list.
[0023] When the processing unit connects the target identifier generator to the distributed system if the target identifier generator passes the access verification, it can be specifically used for:
[0024] If the target identifier generator passes the access verification, the target machine number and the communication address of the target identifier generator will be associated and stored in the database of the distributed system; and,
[0025] Change the status of the target machine number from "allowed" to "occupied", remove the occupied target machine number from the second machine number list, and add the occupied target machine number to the first machine number list.
[0026] In one embodiment, the processing unit is further configured to:
[0027] When integrating the target identifier generator into a distributed system, a time-to-live (TTL) is set for the target identifier generator.
[0028] If a renewal request is received from the target identifier generator within the time limit of the lifetime, the lifetime is reset.
[0029] If no renewal request is received from the target identifier generator when the time-to-live expires, the target identifier generator is removed from the distributed system and the target machine number is released; the released target machine number changes from an occupied state to an allowed state.
[0030] In one embodiment, the processing unit is further configured to:
[0031] Within the time frame of the survival period, if the target identifier generator is detected to have crashed, the usage duration of the target machine number is obtained;
[0032] If the target machine number is used for a longer period than its lifetime, then release the target machine number.
[0033] In one embodiment, the receiving unit is further configured to receive the most recent usage time of the target machine number reported by the target identifier generator;
[0034] The processing unit is also used to associate and store the target machine number and the time of the most recent use of the target machine number in the database of the distributed system.
[0035] In one embodiment, when the processing unit schedules the target identifier generator in the distributed system to provide identifier generation services to the business system based on the target machine number, it can be specifically used for:
[0036] Receive the identifier generation request from the business system. The identifier generation request carries business data.
[0037] The identifier generation request is sent to the target identifier generator, so that the target identifier generator can generate an identifier for the business data based on the business type to which the business data belongs and the target machine number, and return it to the business system.
[0038] In one embodiment, the target identifier generator generates an identifier in a first format for the business data, converts the identifier in the first format into an identifier in a second format, and returns it to the business system; the first format is a numeric format, and the second format is a character format.
[0039] The first format identifier includes a time field, a type field, and a machine field; the time field is used to represent the timestamp of the generation of the first format identifier; the type field is used to represent the business type to which the business data belongs; and the machine field is used to represent the target machine number.
[0040] The number of identifier generators allowed to access a distributed system is determined by the length of the machine bit field.
[0041] On one hand, embodiments of this application provide a data processing apparatus applied to a distributed system. The distributed system schedules one or more identifier generators to provide identifier generation services to a business system. The apparatus includes:
[0042] The sending unit is used to send an access request to the service center device of the distributed system. The access request carries the target machine number. The access request is used to request the service center device to perform access verification on the target identifier generator according to the target machine number, and to request the service center device to connect the target identifier generator to the distributed system after the access verification is passed.
[0043] The processing unit is used to provide identifier generation services to the business system based on the target machine number, according to the scheduling of the service center equipment.
[0044] In one embodiment, the processing unit is further configured to:
[0045] The service center equipment retrieves the second machine number list, which includes at least one allowed machine number.
[0046] Select the target machine number from the second machine number list and generate an access request; the target machine number refers to any machine number allowed in the second machine number list.
[0047] In one embodiment, the processing unit is further configured to:
[0048] The service center equipment retrieves the first machine number list, which records at least one machine number that is already in use;
[0049] Based on the first list of machine numbers and the number of identifier generators allowed to access the distributed system, a second list of machine numbers is determined. The second list of machine numbers includes at least one machine number that is allowed to be used. The number of identifier generators allowed to access the distributed system is determined by the length of the machine bit field.
[0050] Select the target machine number from the second machine number list and generate an access request; the target machine number refers to any machine number allowed in the second machine number list.
[0051] In one embodiment, the processing unit is further configured to:
[0052] If the target identifier generator fails the access verification and is refused access to the distributed system, a new allowed machine number is selected from the second machine number list and the access request is re-initiated.
[0053] In one embodiment, the processing unit is further configured to:
[0054] When the target identifier generator is connected to the distributed system, obtain the lifetime set by the service center device for the target identifier generator;
[0055] Within the lifetime period, a renewal request is sent to the service center equipment. This renewal request is used to request the service center equipment to reset the lifetime; and...
[0056] Report the target identifier generator's most recent usage time for the target machine number to the service center equipment.
[0057] In one embodiment, when the processing unit provides an identifier generation service to the business system based on the target machine number according to the scheduling of the service center equipment, it can be specifically used for:
[0058] Receive the identification generation request from the service center's equipment scheduling system. The identification generation request carries business data.
[0059] Generate a first-format identifier for the business data based on the business type and target machine number;
[0060] Convert the identifier in the first format to the identifier in the second format, and return the identifier in the second format to the business system.
[0061] In one embodiment, the processing unit is further configured to:
[0062] Upon receiving an identifier generation request from the business system sent by the service center's equipment scheduling, the current system time of the target identifier generator is obtained;
[0063] Based on the target machine number, retrieve the most recent usage time of the target machine number from the service center equipment;
[0064] Based on the most recent usage time of the target machine number and the current system time, determine whether the target identifier generator has a clock rollback.
[0065] If it is determined that there is no clock rollback in the target identifier generator, the step of generating an identifier in the first format for the business data based on the business type to which the business data belongs and the target machine number is executed.
[0066] In one embodiment, when the processing unit determines whether the target identifier generator has a clock rollback based on the most recent usage time of the queried target machine number and the current system time, it can specifically be used to:
[0067] Compare the most recent usage time of the target machine number with the current system time;
[0068] If the most recent usage time of the target machine number is earlier than the current system time, it is determined that the target identifier generator does not have a clock rollback.
[0069] In one embodiment, the processing unit is further configured to:
[0070] If the most recent usage time of the target machine number is equal to or later than the current system time, it is determined that the target identifier generator has a clock rollback situation, the identifier generation service process is stopped, and an alarm message is output.
[0071] On one hand, embodiments of this application provide a computer device, the computer device comprising:
[0072] A processor is used to execute computer programs;
[0073] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the data processing method described above.
[0074] On one hand, embodiments of this application provide a computer-readable storage medium storing a computer program that is loaded by a processor and executed as described above in the data processing method.
[0075] On one hand, embodiments of this application provide a computer program product comprising a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, causing the computer device to perform the aforementioned data processing method.
[0076] In this embodiment, an access request from a target identifier generator, carrying a target machine number, is received. The target identifier generator is then verified for access based on the target machine number. If the target identifier generator passes the access verification, it is connected to the distributed system. Finally, the target identifier generators in the distributed system are scheduled to provide identifier generation services to the business system based on the target machine number. On one hand, this distributed system provides stable and highly available identifier generation services to the business system. On the other hand, the access verification mechanism based on the target machine number, which unifies the management of identifier generators in the distributed system, ensures the performance of the entire distributed system. Attached Figure Description
[0077] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0078] Figure 1 This is a schematic diagram of the architecture of a data processing system provided in an exemplary embodiment of this application;
[0079] Figure 2 This is a flowchart illustrating a data processing method provided in an exemplary embodiment of this application;
[0080] Figure 3 This is a flowchart illustrating a data processing method provided in another exemplary embodiment of this application;
[0081] Figure 4 This is a schematic diagram of a clock rollback determination process provided in an exemplary embodiment of this application;
[0082] Figure 5 This is a flowchart illustrating a data processing method provided in yet another exemplary embodiment of this application;
[0083] Figure 6 This is a schematic diagram of the structure of a data processing apparatus provided in an exemplary embodiment of this application;
[0084] Figure 7 This is a schematic diagram of the structure of a data processing apparatus provided in another exemplary embodiment of this application;
[0085] Figure 8 This is a schematic diagram of the structure of a computer device provided in an exemplary embodiment of this application. Detailed Implementation
[0086] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0087] This application provides a data processing scheme applied in a distributed system. This distributed system allows the access of one or more identifier generators and schedules these generators to provide high-capacity, highly stable identifier generation services to the business system. In this data processing scheme, the target identifier generator requesting access is verified based on its target machine number. This mechanism of unified management of identifier generators in the distributed system using machine numbers ensures the performance of the entire distributed system. Furthermore, the scheduling of accessed target identifier generators to provide identifier generation services is based on the target machine number. That is, accessed identifier generators must provide identifier generation services using their own machine number. This not only effectively ensures the global uniqueness of the generated identifiers but also allows for the identification of the corresponding identifier generator through the identifier, thereby achieving efficient and intelligent ID location. In this application embodiment, before accessing the distributed system, the target identifier generator represents any identifier generator requesting access to the distributed system; after the target identifier generator is accessed, it represents any identifier generator within the distributed system.
[0088] The distributed system involved in the embodiments of this application will be described in detail below.
[0089] Please see Figure 1 , Figure 1 This is a schematic diagram of the architecture of a distributed system provided in an embodiment of this application; the distributed system may include a service center device 111, at least one identifier generator 112, and a database 113. The service center device 111, at least one identifier generator 112, and the database 113 can be directly or indirectly connected via wired or wireless communication.
[0090] Service center device 111 can provide identifier generator access verification services. When a new node (i.e., an identifier generator) connects, access verification is performed on that identifier generator. Only identifier generators that pass the access verification can connect to the distributed system, which can also be understood as identifier generators that pass the access verification successfully registering in the service center device. Furthermore, service center device 111 can schedule one or more identifier generators already connected to the distributed system to provide identifier (ID) generation services for the business system. It is understood that service center device 111 can be any type of physical device, including but not limited to terminal devices or servers. Terminal devices can include, but are not limited to, smartphones, tablets, laptops, desktop computers, smart speakers, smartwatches, in-vehicle terminals, smart wearable devices, etc. Servers can be independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
[0091] The identifier generator 112, also known as a number generator, is a device capable of generating a unique identifier for business data in a distributed system. Each identifier generator 112 connected to the distributed system possesses a unique machine number, which can be used to provide identifier generation services to the business system. The identifier generator 112 can construct identifiers in a first format, which can be binary or quaternary; this first format identifier can be a long integer (such as a 64-bit long integer) numeric identifier; for example, the identifier generator 112 can generate the 64-bit long integer numeric identifier 371317204647465423. Further, the identifier generator 112 can convert the first format identifier into a second format identifier, which can be hexadecimal or a character identifier; for example, converting the 64-bit long integer numeric identifier 371317204647465423 to hexadecimal yields the character identifier B5272F07C200D1CF. In other words, the identifier generated by identifier generator 112 is ultimately output as a string. After identifier generator 112 generates a character-type identifier for business data in the business system, the corresponding business data can be indexed through this character-type identifier.
[0092] Database 113 can store the correspondence between identifier generators and machine numbers in a key-value pair manner; in addition, database 113 can also store machine numbers that have been occupied by identifier generator 112 and allowed machine numbers. In one embodiment, the database can be ETCD, which is a very reliable key-value database often used in distributed systems to store critical data.
[0093] The distributed system mentioned in this application is mainly used for access verification and unified management of identifier generators, and for scheduling one or more identifier generators connected to the distributed system to provide identifier (ID) generation services for business systems. Here, a business system refers to a system that processes business data (such as generating business data, storing business data, publishing business data, etc.), and this business system may include, but is not limited to, document business systems, e-commerce business systems, drawing and production business systems, etc. The distributed system can interface with various types of business systems, thereby enabling the data processing solution of this application to be widely applied in various business scenarios, such as document publishing scenarios, order storage scenarios in e-commerce, etc.
[0094] Taking a document business scenario as an example, where the business system refers to the document business system, the data processing flow of the distributed system in this application is roughly as follows: The document business system can send an identifier generation request to the distributed system. The identifier generation request carries the document to be identified. The service center device can schedule the identifier generator in the distributed system to generate a corresponding identifier for the document based on the machine number, and return the identifier to the document business system. The business system can save the document based on the identifier, and subsequently, the document can be quickly indexed through the identifier.
[0095] Taking the order storage scenario in e-commerce as an example, where the business system refers to the e-commerce business system, the data processing flow of the distributed system in this application is roughly as follows: the e-commerce business system can send an identifier generation request to the distributed system. The identifier generation request carries the order content. The service center device can schedule the identifier generator in the distributed system to generate a corresponding identifier for the order content based on the machine number and return the identifier to the e-commerce business system. The e-commerce business system can store the corresponding order content based on the identifier.
[0096] It is understood that in the embodiments of this application, business data is involved, such as the document content and order content of the object. When the above embodiments of this application are applied to specific products or technologies, permission or consent from the object is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0097] Through the above distributed system, the data processing scheme of this application has at least the following advantages: (1) One or more identifier generators accessed by the distributed system can provide the business system with a large capacity and high stability identifier generation service, which can effectively solve the problem that a single point of failure will not affect the entire identifier generation service and achieve high availability; (2) The identifier generators that have been accessed need to provide identifier generation services through their own machine numbers. This can not only effectively ensure that the generated identifiers are globally unique, but also know how to locate the corresponding identifier generator through the identifier, thereby achieving efficient and intelligent ID positioning.
[0098] The data processing method provided in the embodiments of this application will be described below. Please read... Figure 2 , Figure 2 This is a flowchart illustrating a data processing method provided in an embodiment of this application. This data processing method can be applied to... Figure 1 In the distributed system shown, the data processing method described in this embodiment can be executed by the service center device 111 in the aforementioned distributed system, and may include the following steps S201-S204:
[0099] S201. Receive the access request from the target identifier generator, which carries the target machine number.
[0100] When a target identifier generator wants to access a distributed system, it can generate an access request based on the target machine number and send the access request to the service center device. Correspondingly, the service center device can receive the access request sent by the target identifier generator. The access request is used to request the service center device to allow the target identifier generator to access the distributed system to provide identifier generation services.
[0101] In one embodiment, the database of the distributed system may store a second list of machine numbers. This list may include at least one allowed machine number, meaning a machine number that is not currently occupied or used by another identifier generator. The target machine number can be any machine number from the second list.
[0102] The second machine number list can be determined based on the first machine number list and the number of identifier generators allowed to access the distributed system. The first machine number list records at least one machine number that is currently occupied; that is, when any machine number is occupied, it can be added to the first machine number list. The number of identifier generators allowed to access the distributed system can be determined based on the length of the machine bit field, which can be set according to requirements. For example, if the machine bit field length is 5 bits, the maximum number of identifier generators allowed to access the distributed system is 32; correspondingly, the machine numbers allowed for identifier generators can be 0 to 31. Assuming that the machine numbers already occupied in the first machine number list are 0 to 12, then the machine numbers allowed in the second machine number list are 13 to 31. As another example, if the machine bit field length is 6 bits, the maximum number of identifier generators allowed to access the distributed system is 64; correspondingly, the machine numbers allowed for identifier generators are 0 to 63; assuming that the machine numbers already occupied in the first machine number list are 0 to 30, then the machine numbers allowed in the second machine number list are 31 to 63.
[0103] S202. Perform access verification on the target identifier generator based on the target machine number.
[0104] The purpose of access verification is primarily to check whether the target machine number requested by the target identifier generator has already been used. In other words, it mainly verifies whether the target machine number already exists in the distributed system. The access verification mechanism ensures that each identifier generator connected to the distributed system has a unique machine number, thereby facilitating unified management of identifier generators based on machine numbers.
[0105] In one embodiment, performing access verification on the target identifier generator based on the target machine number may include: comparing the target machine number with at least one machine number already occupied in the first machine number list; if it is determined that the target machine number is not an occupied machine number, then the target identifier generator is determined to have passed the access verification, and S203 is executed; if it is determined that the target machine number is an occupied machine number, then the target identifier generator is determined to have failed the access verification; at this time, the service center device may send a failed access prompt message to the target identifier generator. This failed access prompt message can be used to indicate that access to the distributed system based on the target machine number has failed. By sending the failed prompt message, the target identifier generator can reselect a new machine number from the second machine number list and re-initiate the access request to the service center device.
[0106] S203. If the target identifier generator passes the access verification, then the target identifier generator will be connected to the distributed system.
[0107] If the target identifier generator passes the access verification, the target machine number and the target identifier generator's communication address are associated and stored in the distributed system's database, thereby enabling the target identifier generator to access the distributed system. The communication address can include at least one of the following: the target identifier generator's IP (Internet Protocol) address, port number, or MAC (Media Access Control Address) address. When the database stores the target machine number and the target identifier generator's communication address in key-value pairs, the target machine number can be used as the key, and the target identifier generator's communication address as the value corresponding to the key. Optionally, the key can be based on the service type served by the target identifier generator and the target machine number, i.e., the key is [service type]_[target machine number], and the value is IP address:port number.
[0108] When a target identifier generator passes the access verification, it means that the target machine number is already in use by the generator. Therefore, the status of the target machine number can be changed from "allowed" to "occupied" in the second machine number list, and the occupied target machine number can be removed from the second machine number list and added to the first machine number list. By removing the occupied target machine number from the second machine number list and adding it to the first machine number list, other identifier generators attempting to access the distributed system using the target machine number cannot be prevented from doing so, thus improving the success rate of identifier generator access.
[0109] In one embodiment, when a service center device connects a target identifier generator to a distributed system, it can set a Time To Live (TTL) for the target identifier generator. This can be understood as setting a TTL for the target machine number of the target identifier generator to effectively ensure that the target identifier generator can use the target machine number to provide identifier generation services to the business system within the TTL. When the TTL expires, if the service center device does not receive a renewal request from the target identifier generator, it removes the target identifier generator from the distributed system and releases the target machine number; the released target machine number changes from an occupied state to an allowed state. This method solves the problem of limited machine numbers, ensuring that other identifier generators can use the released target machine number. Furthermore, the released target machine number is removed from the first machine number list and added back to the second machine number list.
[0110] To ensure the long-term use of the target machine number, the target identifier generator can be allowed to send renewal requests within its lifetime. Correspondingly, if the service center device receives a renewal request from the target identifier generator within the lifetime, it can reset the generation time of the target identifier generator. For example, if the lifetime of the target identifier generator is 9 hours, and the service center device receives a renewal request from the target identifier generator within 9 hours, then the lifetime can be reset. Resetting the lifetime can be done in two ways: (1) Restarting the timing of the target machine number of the target identifier generator to ensure its validity within 9 hours; (2) Resetting the lifetime, such as resetting the lifetime of the target identifier generator from 9 hours to 20 hours after receiving a renewal request.
[0111] In one embodiment, the service center device and the target identifier generator can establish a heartbeat connection, and the service device can allocate traffic corresponding to the heartbeat connection to the target identifier generator. Through this heartbeat connection, the service center device can monitor the current status of the target identifier generator (such as whether it is running) and communicate with the target identifier generator (such as sending lease renewal requests).
[0112] Within the lifetime, if a target identifier generator is detected to have crashed (e.g., due to a restart or malfunction), the usage duration of the target machine number can be obtained. It can then be determined whether this usage duration exceeds the lifetime. If the usage duration exceeds the lifetime, the target machine number is released. At this point, the target machine number is changed from an occupied state to an allowed state, removed from the first machine number list, and added to the second machine number list. This allows subsequent identifier generators to initiate access requests based on the target machine number, resolving the issue of limited machine number availability. If the usage duration is less than or equal to the lifetime, the target machine number does not need to be released; it remains available for the target identifier generator to use within its lifetime, while other identifier generators cannot use it. Optionally, when a target identifier generator crash is detected, the service center device can also remove the traffic corresponding to the heartbeat connection allocated to the target identifier generator.
[0113] S204. The target identifier generator in the scheduling distributed system provides identifier generation services to the business system based on the target machine number.
[0114] The distributed system includes one or more connected identifier generators, one of which is a target identifier generator. When a business system sends an identifier generation request to the distributed system, the request carries business data. The process of scheduling the target identifier generator in the distributed system to provide identifier generation services to the business system based on the target machine number can be as follows: the service center device can receive the identifier generation request and send it to the target generator, so that the target identifier generator generates an identifier for the business data based on the business type and the target machine number, and returns it to the business system.
[0115] In one implementation, upon receiving the identifier generation request, the service center device can acquire idle identifier generators and select the target identifier generator from among them. In another implementation, each identifier generator corresponds to a reference business type. The service center device can determine the business type to which the business data in the identifier generation request belongs and identify the identifier generator (i.e., the target identifier generator) corresponding to that business type. For example, identifier generator 1 corresponds to webpage data, and identifier generator 2 corresponds to an article type. If the service center device determines that the business type of the business data in the identifier generation request is an article type, it can identify an identifier generator 2 for that article type. The service center device can then schedule the machine number of identifier generator 2 and the article type to generate an identifier for the business data and return it to the business system.
[0116] The aforementioned target identifier generator generates an identifier in a first format for the business data, converts the first format identifier into an identifier in a second format, and returns it to the business system. The first format is a numeric format (such as a binary identifier or a quaternary identifier), and the second format is a character format (such as a hexadecimal identifier). The first format identifier may include a time field, a type field, and a machine field. The time field indicates the timestamp of the first format identifier's generation; the type field indicates the business type to which the business data belongs; and the machine field indicates the target machine number.
[0117] In one embodiment, since the identifier generated for business data contains a generation timestamp of the identifier in a first format, it relies on the local clock. However, the local clock is prone to drift and can be reset by the NTP (Network Time Protocol) service, leading to clock rollback. In this case, the service center device can receive the most recent usage time of the target machine number reported by the target identifier generator (e.g., if the target machine number was used at 10:00, 11:00, or 12:00, then the most recent usage time of the target machine number is 12:00), and store the target machine number and its most recent usage time together in the database of the distributed system. Storing the most recent usage time of the target machine number helps the target identifier generator determine whether clock rollback has occurred when starting the identifier generation service, thereby resolving the problem of time inconsistencies in the generated identifiers.
[0118] In this embodiment, an access request from a target identifier generator is received, the access request carrying a target machine number; the target identifier generator is verified for access based on the target machine number; if the target identifier generator passes the access verification, the target identifier generator is connected to the distributed system; and the target identifier generator in the distributed system is scheduled to provide identifier generation services to the business system based on the target machine number; the service center device in the distributed system can uniformly manage and schedule the identifier generator, and can provide a stable and highly available identifier generation service to the business system, effectively ensuring the entire identifier generation service; and the identifier generator generates identifiers for business data based on the machine number, so the generated identifiers have global uniqueness to a certain extent.
[0119] Please see Figure 3 , Figure 3 This is a schematic diagram illustrating a data processing method provided in an embodiment of this application. This data processing method can be applied to... Figure 1 In the distributed system shown, the specific execution can be performed by any identifier generator 112 in the distributed system. In this embodiment, the target identifier generator in the distributed system is used as an example for description. The data processing method may include the following steps S301-S302:
[0120] S301. Send an access request to the service center device of the distributed system. The access request carries the target machine number. The access request is used to request the service center device to perform access verification on the target identifier generator according to the target machine number, and to request the service center device to connect the target identifier generator to the distributed system after the access verification is passed.
[0121] When the target identifier generator wants to access the distributed system, it can obtain the target machine number used for access, then generate an access request based on the target machine number, and send the access request to the service center device.
[0122] There are two ways to obtain the target machine number used for access: (1) The database of the distributed system stores a second machine number list, which includes at least one allowed machine number. The target identifier generator can query the second machine number list from the service center device and select the target machine number from the second machine number list. At this time, the target machine number refers to any machine number allowed in the second machine number list. (2) The distributed system includes a first machine number list. The target identifier generator can calculate the allowed machine number based on the first machine number list and the number of identifier generators allowed to access the distributed system. Specifically, the target identifier generator can query the first machine number list from the service center device, where the first machine number list records at least one machine number that has been occupied; then, based on the first machine number list and the number of identifier generators allowed to access the distributed system, the second machine number list is determined; then, the target identifier generator can arbitrarily select a machine number from the second machine number list as the target machine number. In this system, the number of identifier generators allowed to access the distributed system is determined by the length of the machine number field. For example, if the machine number field is 5 bits long, then the maximum number of identifier generators allowed to access the distributed system is 32, and the machine numbers can be 0 to 31. The first machine number list records the machine numbers 9 to 31 that are already in use. The target identifier generator can determine the second machine number list based on the first machine number list and the number of identifier generators allowed to access the distributed system. That is, the second machine number list includes machine numbers 0 to 8 that are allowed to be used. Then, the target identifier generator can arbitrarily select a machine number from 0 to 8 as the target machine number.
[0123] In one embodiment, if the target identifier generator is refused access to the distributed system due to failing access verification, a new allowed machine number is selected from the second machine number list, and the access request is re-initiated. It should be understood that if the re-selected machine number still fails access verification after initiating the access request, the target identifier generator can continue to select a new allowed machine number from the second machine number list and continue initiating the access request until the target identifier generator passes access verification and accesses the distributed system; or, until all machine numbers in the second machine number list fail to enable the target identifier generator to pass access verification. In this case, the target identifier generator cannot be accessed to the distributed system, and the identifier generation service cannot be started. In some optional embodiments, each time the target identifier generator is refused access to the distributed system due to failing access verification, an access failure message sent by the service center device can be received, and a new allowed machine number can be selected from the second machine number list to continue initiating the access request based on the access failure message.
[0124] When the target identifier generator is connected to the distributed system after passing the access verification, the target identifier generator can obtain the time-to-live (TTL) set by the service center device for the target identifier generator, and send a renewal request to the service center device within the TTL. This renewal request is used to request the service center device to reset the TTL of the target identifier generator, thereby ensuring that the target machine number can continue to be used within the TTL.
[0125] In some optional embodiments, the target identifier generator can report the most recent usage time of the target machine number to the service center device. As one implementation, the target identifier generator can periodically (e.g., every 6 hours, every 30 minutes) report the most recent usage time of the target machine number to the service center device, which can save resources. Another implementation is to report the most recent usage time of the target machine number to the service center device in real time. Reporting the most recent usage time of the target machine number helps in subsequent determination of whether the target identifier generator has experienced clock rollback.
[0126] S302. According to the scheduling of the service center equipment, provide the identification generation service to the business system based on the target machine number.
[0127] The service center equipment can schedule a target identifier generator to provide identifier generation services to the business system based on the target machine number. In one implementation, the target identifier generator can receive an identifier generation request from the business system, which carries business data, sent by the service center equipment. Then, based on the business type and target machine number of the business data, it generates an identifier in a first format for the business data, converts the first format identifier into a second format identifier, and returns the second format identifier to the business system. The first format identifier is a numeric format, such as a long integer (64-bit, 128-bit, etc.), the length of which can be set as needed; this application does not limit this. The second format identifier is a character format, which can be a hexadecimal string. For example, if the first format identifier is 371317204647465423, the target identifier generator can convert it to hexadecimal to obtain the second format identifier, i.e., the second format identifier is B5272F07C200D1CF.
[0128] The identifier in the first format may include a time field, a type field, and a machine field. The time field represents the timestamp of the identifier's generation; the type field represents the business type to which the business data belongs (e.g., the type field indicates the article type); and the machine field represents the target machine number of the target identifier generator. Optionally, the identifier in the first format may also include a symbol field, an in-machine auto-incrementing sequence number field, and a version field, whereby the version field can indicate the version number of the target identifier generator.
[0129] For example, taking the first format identifier as a 64-bit long integer as an example, the first format identifier is constructed as follows: [Sign Field][Time Field][Type Field][Version Field][Machine Auto-Incrementing Serial Number Field][Machine Field]; where the sign field can be 1 bit long and can be 0 or 1; the time field can be 40 bits long and has a precision of 1ms, meaning that the timestamp generated by the first format identifier can be accurate to the millisecond level. The type field can be 11 bits long, supporting a maximum of 2048 types; the version field can be 1 bit long. The length of the machine-internal auto-incrementing sequence number field can be 6 bits. Through this machine-internal auto-incrementing sequence number field, each identifier generator can distribute 64 auto-incrementing sequence numbers within 1 ms. The length of the machine field can be 5 bits, indicating that the distributed system can provide a maximum of 32 allowed machine numbers. Therefore, the distributed system can allow a maximum of 32 identifier generators to connect. It should be noted that when the database in the distributed system is ETCD, a machine number will be reserved for ETCD. In this case, a maximum of 31 identifier generators are allowed to connect.
[0130] It should be understood that the length of the bit field included in the identifier of the first format can be adjusted as needed, and this application does not limit it. For example, the length of the machine-internal auto-incrementing sequence number bit field included in the identifier of the first format can be 5 bits, and the length of the machine bit field can be 6 bits.
[0131] After converting the first-format identifier to the second-format identifier, the second-format identifier can include a generation timestamp, service type, and machine number. Therefore, by parsing the second-format identifier, the corresponding generation timestamp and service type can be obtained. For example, taking the conversion of a 64-bit long integer identifier in the first format to the second-format identifier as an example, the 40-bit time field in the first format identifier can be converted into a 6-digit date and 6-digit uppercase letter in the second format identifier; the 11-bit type field in the first format identifier can be converted into a 3-digit uppercase letter in the second format identifier; the 6-bit auto-incrementing machine number in the first format identifier can be converted into a 2-digit number or a 2-letter number in the second format identifier; and the 5-bit machine number in the first format identifier can be converted into a 1-digit number or a 1-letter number in the second format identifier. That is, the length of the second-format identifier can be 18 bits, such as the second-format identifier 201612ABCDEFABOAB1.
[0132] In this embodiment, the aforementioned time field, type field, and machine field can generate a globally unique identifier for business data. The identifier includes a generation timestamp, allowing the business data to be sorted and stored according to these timestamps. Furthermore, the length of each field can generate a massive number of identifiers. Additionally, using the time field and an internally incrementing sequence number allows for the generation of reliably increasing, non-repeating, and non-contiguous identifiers.
[0133] In one embodiment, the identifier generated for business data includes a generation timestamp, thus relying on a local clock. However, the local clock is prone to drift and can be reset by the NTP service, leading to clock rollback. Therefore, this application embodiment addresses the clock rollback problem as follows: Figure 4As shown: Step ① Upon receiving the identifier generation request from the service center device's scheduling system, the target identifier generator starts the identifier generation service and then retrieves the target machine number from the database. Step ② Determines whether retrieving the target machine number from the database was successful. If yes, proceed to step ③; otherwise, proceed to step ⑨. Step ③ retrieves the current system time of the target identifier generator. Step ④ Queryes the most recent usage time of the target machine number from the service center device based on the target machine number. Step ⑤ Determines whether the most recent usage time of the target machine number was successfully retrieved. If yes, proceed to step ⑥; otherwise, proceed to step ⑦. Step ⑥, based on the queried most recent usage time of the target machine number and the current system time, determines whether the target identifier generator has clock rollback. Specifically, determining whether the target identifier generator has clock rollback based on the queried most recent usage time of the target machine number and the current system time can include: comparing the queried most recent usage time of the target machine number with the current system time. If the queried most recent usage time of the target machine number is earlier than the current system time, it is determined that the target identifier generator does not have clock rollback, and step ⑧ is executed. If the most recent usage time of the target machine number is equal to or later than the current system time, it is determined that the target identifier generator has a clock rollback situation, and step ⑨ is executed.
[0134] Step 7: If the service center device does not find the most recent usage time of the target machine number, then the target identifier generator is determined to be a newly connected identifier generator in the distributed system. At this time, the target identifier generator can provide identifier generation service normally, and step 8 is executed; that is, the step of generating the first format identifier for the business data according to the business type to which the business data belongs and the target machine number.
[0135] Step 8: If it is determined that there is no clock rollback in the target identifier generator, the target identifier generator can normally provide identifier generation services, that is, perform the step of generating an identifier of the first format for the business data according to the business type to which the business data belongs and the target machine number.
[0136] Step 9: If it is determined that the target identifier generator has clock rollback issues, or if the target machine number is not successfully obtained, stop the identifier generation service process and output an alarm message. Overcoming the clock rollback problem can resolve the issue of time-disordered generated identifiers, which is beneficial for sorting business data according to the generation timestamp.
[0137] In this embodiment, an access request is sent to the service center device of the distributed system, carrying the target machine number. The access request is used to request the service center device to perform access verification on the target identifier generator based on the target machine number, and to request the service center device to connect the target identifier generator to the distributed system after the access verification is passed. According to the scheduling of the service center device, the identifier generation service is provided to the business system based on the target machine number. Providing the identifier generation service through the machine number of the identifier generator can not only effectively ensure the uniqueness of the identifier generated for the business data, but also know how to locate the corresponding identifier generator through the identifier, thereby achieving efficient and intelligent ID positioning.
[0138] Please see Figure 5 , Figure 5 This application provides a data processing method that can be jointly executed by a service center device of a distributed system and a target identifier generator. The data processing target identifier generator sends an access request to the service center device of the distributed system. The access request carries the target machine information. The method may include the following steps S501-S507:
[0139] S501, the target identifier generator sends an access request to the service center device in the distributed system, carrying the target machine number. Specifically, the target identifier generator can first obtain a first list of machine numbers from the service center device, and based on this first list and the number of identifier generators allowed to access the distributed system, determine a second list of machine numbers. It then selects the target machine number from the second list and generates an access request based on that target machine number. This access request requests the service center device to perform access verification on the target identifier generator based on the target machine number, and requests that the service center device, after successful access verification, allow the target identifier generator to access the distributed system.
[0140] S502. The service center equipment performs access verification on the target identifier generator based on the target machine number.
[0141] The service center device receives an access request from the target identifier generator. In response to the access request, it performs access verification on the target identifier generator based on the target machine number. If the target identifier generator passes the access verification, it generates an access success message and sends the access success message to the target identifier generator, and executes step S503. If the target identifier generator fails the access verification, it generates an access failure message and sends the access failure message to the target identifier generator. Upon receiving the access failure message, the target identifier generator selects a machine number from the second machine number list and generates an access request based on the newly selected machine number, sending the access request to the service center device. The service center device then receives the access request and continues to perform access verification on the target identifier generator based on the machine number.
[0142] S503. If the target identifier generator passes the access verification, the service center device will connect the target identifier generator to the distributed system and associate the target machine number with the communication address of the target identifier generator in the database of the distributed system.
[0143] In one embodiment, when the target identifier generator is connected to the distributed system, a time-to-live (TTL) is set for the target identifier generator; within the TTL period, if a renewal request is received from the target identifier generator, the TTL is reset; when the TTL expires, if no renewal request is received from the target identifier generator, the target identifier generator is removed from the distributed system, the target machine number is released, the target machine number is changed from an occupied state to an allowed state, and the target machine number is added to the second machine number list.
[0144] In one embodiment, the service center device may receive the most recent usage time of the target machine number reported by the target identifier generator, and store the target machine number and the most recent usage time of the target machine number together in the database of the distributed system.
[0145] S504. The business system sends an identifier generation request to the service center equipment, which carries business data.
[0146] S505, The service center equipment sends an identifier generation request to the target identifier generator to schedule the target identifier generator to generate an identifier for the service data based on the target machine number.
[0147] The service center equipment can receive identifier generation requests sent by the business system, and then determine the target identifier generator to be scheduled based on the business data in the identifier generation request. The service center equipment can then send the identifier generator to the target identifier generator. The specific implementation of determining the target identifier generator to be scheduled based on the business data can be found in the corresponding section above, and will not be repeated here.
[0148] S506. In response to the identifier generation request, the target identifier generator generates an identifier for the business data based on the target machine number.
[0149] The target identifier generator receives an identifier generation request sent by the service center device. In response to the identifier generation request, it can generate an identifier in a first format based on the target machine number, the service type to which the service data belongs, the identifier generation timestamp, and the machine's auto-incrementing sequence number. It then converts the identifier in the first format into an identifier in a second format, and finally obtains the identifier for the service data.
[0150] S507, The target identifier generator returns the identifier of the business data to the business system.
[0151] In this embodiment, the target identifier generator sends an access request to the service center device of the distributed system. The service center device verifies the access of the target identifier generator based on the target machine number. If the target identifier generator passes the access verification, the service center device connects the target identifier generator to the distributed system. The business system sends an identifier generation request to the service center device, scheduling the target identifier generator to generate an identifier for the business data based on the target machine number. In response to the identifier generation request, the target identifier generator generates an identifier for the business data based on the target machine number and returns the identifier to the business system. Distributing the identifier generator enables high availability, and single-point failures do not affect availability. Furthermore, experiments have shown that scheduling the identifier generator can control the response time to within 5ms to a certain extent, achieving rapid identifier generation. The target identifier generator provides identifier generation services based on the machine number, ensuring, to a certain extent, the globally uniqueness of the generated identifier.
[0152] Please see Figure 6 , Figure 6 This is a schematic diagram of the structure of a data processing device provided in an embodiment of this application; the data processing device can be a computer program (including program code) running in a service center device of a distributed system, for example, the data processing device can be application software in the service center device; the data processing device can be used to execute Figure 2 Some or all of the steps in the method embodiments shown. Please refer to [link / reference]. Figure 6 The data processing device includes the following units:
[0153] The receiving unit 601 is used to receive the access request from the target identifier generator, wherein the access request carries the target machine number;
[0154] Processing unit 602 is used to perform access verification on the target identifier generator based on the target machine number;
[0155] Processing unit 602 is further configured to connect the target identifier generator to the distributed system if the target identifier generator passes the access verification; and,
[0156] The processing unit 602 is also used to schedule the target identifier generator in the distributed system to provide identifier generation services to the business system based on the target machine number.
[0157] In one embodiment, the distributed system includes a first machine number list, which records at least one machine number that is already in use.
[0158] When processing unit 602 performs access verification on the target identifier generator based on the target machine number, it can specifically be used for:
[0159] Compare the target machine number with at least one machine number that is already in use in the first machine number list;
[0160] If the target machine number is not an already occupied machine number, then the target identifier generator is confirmed to have passed the access verification.
[0161] If the target machine number is already in use, then the target identifier generator has failed the access verification.
[0162] In one embodiment, the database of the distributed system further includes a second machine number list, which includes at least one allowed machine number; the target machine number refers to any machine number allowed in the second machine number list.
[0163] When the processing unit 602 connects the target identifier generator to the distributed system if the target identifier generator passes the access verification, it can be specifically used for:
[0164] If the target identifier generator passes the access verification, the target machine number and the communication address of the target identifier generator will be associated and stored in the database of the distributed system; and,
[0165] Change the status of the target machine number from "allowed" to "occupied", remove the occupied target machine number from the second machine number list, and add the occupied target machine number to the first machine number list.
[0166] In one embodiment, the processing unit 602 is further configured to:
[0167] When integrating the target identifier generator into a distributed system, a time-to-live (TTL) is set for the target identifier generator.
[0168] If a renewal request is received from the target identifier generator within the time limit of the lifetime, the lifetime is reset.
[0169] If no renewal request is received from the target identifier generator when the time-to-live expires, the target identifier generator is removed from the distributed system and the target machine number is released; the released target machine number changes from an occupied state to an allowed state.
[0170] In one embodiment, the processing unit 602 is further configured to:
[0171] Within the time frame of the survival period, if the target identifier generator is detected to have crashed, the usage duration of the target machine number is obtained;
[0172] If the target machine number is used for a longer period than its lifetime, then release the target machine number.
[0173] In one embodiment, the receiving unit 601 is further configured to receive the most recent usage time of the target machine number reported by the target identifier generator;
[0174] The processing unit 602 is also used to associate and store the target machine number and the most recent usage time of the target machine number in the database of the distributed system.
[0175] In one embodiment, when the processing unit 602 provides an identifier generation service to the business system based on the target machine number in the scheduling distributed system, it can be specifically used for:
[0176] Receive the identifier generation request from the business system. The identifier generation request carries business data.
[0177] The identifier generation request is sent to the target identifier generator, so that the target identifier generator can generate an identifier for the business data based on the business type to which the business data belongs and the target machine number, and return it to the business system.
[0178] In one embodiment, the target identifier generator generates an identifier in a first format for the business data, converts the identifier in the first format into an identifier in a second format, and returns it to the business system; the first format is a numeric format, and the second format is a character format.
[0179] The first format identifier includes a time field, a type field, and a machine field; the time field is used to represent the timestamp of the generation of the first format identifier; the type field is used to represent the business type to which the business data belongs; and the machine field is used to represent the target machine number.
[0180] The number of identifier generators allowed to access a distributed system is determined by the length of the machine bit field.
[0181] In this embodiment, an access request from a target identifier generator is received, the access request carrying a target machine number; the target identifier generator is verified for access based on the target machine number; if the target identifier generator passes the access verification, the target identifier generator is connected to the distributed system; and the target identifier generator in the distributed system is scheduled to provide identifier generation services to the business system based on the target machine number; the service center device in the distributed system can uniformly manage and schedule the identifier generator, and can provide a stable and highly available identifier generation service to the business system, effectively ensuring the entire identifier generation service; and the identifier generator generates identifiers for business data based on the machine number, so the generated identifiers have global uniqueness to a certain extent.
[0182] Please see Figure 7 , Figure 7 This is a schematic diagram of the structure of a data processing device provided in an embodiment of this application; the data processing device can be a computer program (including program code) running in an identifier generator of a distributed system, for example, the data processing device can be an application software in the identifier generator; the data processing device can be used to execute Figure 3 Some or all of the steps in the method embodiments shown. Please refer to [link / reference]. Figure 7 The data processing device includes the following units:
[0183] The sending unit 701 is used to send an access request to the service center device of the distributed system. The access request carries the target machine number. The access request is used to request the service center device to perform access verification on the target identifier generator according to the target machine number, and to request the service center device to connect the target identifier generator to the distributed system after the access verification is passed.
[0184] Processing unit 702 is used to provide an identifier generation service to the business system based on the target machine number according to the scheduling of the service center equipment.
[0185] In one embodiment, the processing unit 702 is further configured to:
[0186] The service center equipment retrieves the second machine number list, which includes at least one allowed machine number.
[0187] Select the target machine number from the second machine number list and generate an access request; the target machine number refers to any machine number allowed in the second machine number list.
[0188] In one embodiment, the processing unit 702 is further configured to:
[0189] The service center equipment retrieves the first machine number list, which records at least one machine number that is already in use;
[0190] Based on the first list of machine numbers and the number of identifier generators allowed to access the distributed system, a second list of machine numbers is determined. The second list of machine numbers includes at least one machine number that is allowed to be used. The number of identifier generators allowed to access the distributed system is determined by the length of the machine bit field.
[0191] Select the target machine number from the second machine number list and generate an access request; the target machine number refers to any machine number allowed in the second machine number list.
[0192] In one embodiment, the processing unit 702 is further configured to:
[0193] If the target identifier generator fails the access verification and is refused access to the distributed system, a new allowed machine number is selected from the second machine number list and the access request is re-initiated.
[0194] In one embodiment, the processing unit 702 is further configured to:
[0195] When the target identifier generator is connected to the distributed system, obtain the lifetime set by the service center device for the target identifier generator;
[0196] Within the lifetime period, a renewal request is sent to the service center equipment. This renewal request is used to request the service center equipment to reset the lifetime; and...
[0197] Report the target identifier generator's most recent usage time for the target machine number to the service center equipment.
[0198] In one embodiment, when processing unit 702 provides identifier generation service to the business system based on the target machine number according to the scheduling of the service center equipment, it may specifically be used for:
[0199] Receive the identification generation request from the service center's equipment scheduling system. The identification generation request carries business data.
[0200] Generate a first-format identifier for the business data based on the business type and target machine number;
[0201] Convert the identifier in the first format to the identifier in the second format, and return the identifier in the second format to the business system.
[0202] In one embodiment, the processing unit 702 is further configured to:
[0203] Upon receiving an identifier generation request from the business system sent by the service center's equipment scheduling, the current system time of the target identifier generator is obtained;
[0204] Based on the target machine number, retrieve the most recent usage time of the target machine number from the service center equipment;
[0205] Based on the most recent usage time of the target machine number and the current system time, determine whether the target identifier generator has a clock rollback.
[0206] If it is determined that there is no clock rollback in the target identifier generator, the step of generating an identifier in the first format for the business data based on the business type to which the business data belongs and the target machine number is executed.
[0207] In one embodiment, when the processing unit 702 determines whether the target identifier generator has a clock rollback based on the most recent usage time of the queried target machine number and the current system time, it may specifically be used to:
[0208] Compare the most recent usage time of the target machine number with the current system time;
[0209] If the most recent usage time of the target machine number is earlier than the current system time, it is determined that the target identifier generator does not have a clock rollback.
[0210] In one embodiment, the processing unit 702 is further configured to:
[0211] If the most recent usage time of the target machine number is equal to or later than the current system time, it is determined that the target identifier generator has a clock rollback situation, the identifier generation service process is stopped, and an alarm message is output.
[0212] In this embodiment, an access request is sent to the service center device of the distributed system, carrying the target machine number. The access request is used to request the service center device to perform access verification on the target identifier generator based on the target machine number, and to request the service center device to connect the target identifier generator to the distributed system after the access verification is passed. According to the scheduling of the service center device, the identifier generation service is provided to the business system based on the target machine number. The connected identifier generator needs to provide the identifier generation service through its own machine number. This can not only effectively ensure that the generated identifier has global uniqueness, but also know how to locate the corresponding identifier generator through the identifier, thereby realizing efficient and intelligent ID positioning.
[0213] Furthermore, this application also provides a schematic diagram of the structure of a computer device, which can be found in [reference needed]. Figure 8The computer device can be a service center device or an identifier generator in the aforementioned distributed system. The computer device may include a processor 801, an input device 802, an output device 803, and a memory 804. The processor 801, input device 802, output device 803, and memory 804 are connected via a bus. The memory 804 stores computer programs, including program instructions, and the processor 801 executes the program instructions stored in the memory 804.
[0214] When the computer device is a service center device in the aforementioned distributed system, in this embodiment of the application, the processor 801 performs the following operations by running the executable program code in the memory 804:
[0215] Receive the access request from the target identifier generator, which carries the target machine number;
[0216] The target identifier generator is access verified based on the target machine number.
[0217] If the target identifier generator passes the access verification, then the target identifier generator is connected to the distributed system; and,
[0218] The target identifier generator in the distributed system is scheduled to provide identifier generation services to the business system based on the target machine number.
[0219] In one embodiment, the distributed system includes a first machine number list, which records at least one machine number that is already in use;
[0220] When performing access verification on the target identifier generator based on the target machine number, the processor 801 can be specifically used for:
[0221] The target machine number is compared with at least one machine number that is already in use in the first machine number list;
[0222] If the target machine number is not an already occupied machine number, then the target identifier generator is determined to have passed the access verification.
[0223] If the target machine number is already in use, then the target identifier generator has failed the access verification.
[0224] In one embodiment, the database of the distributed system further includes a second machine number list, which includes at least one allowed machine number; the target machine number refers to any machine number allowed in the second machine number list.
[0225] When the processor 801 connects the target identifier generator to the distributed system if the target identifier generator passes the access verification, it can be specifically used for:
[0226] If the target identifier generator passes the access verification, the target machine number is associated with and stored in the database of the distributed system along with the communication address of the target identifier generator; and,
[0227] Change the status of the target machine number from "allowed" to "occupied", remove the occupied target machine number from the second machine number list, and add the occupied target machine number to the first machine number list.
[0228] In one embodiment, the processor 801 is also used for:
[0229] When connecting the target identifier generator to the distributed system, a time-to-live (TTL) is set for the target identifier generator.
[0230] If a renewal request is received from the target identifier generator within the time frame of this lifetime, the lifetime is reset.
[0231] If no renewal request is received from the target identifier generator when the expiration time of the lifecycle is reached, the target identifier generator is removed from the distributed system and the target machine number is released; wherein, the released target machine number changes from the occupied state to the allowed state.
[0232] In one embodiment, the processor 801 is also used for:
[0233] Within the timeframe of this lifetime, if the target identifier generator is detected to have crashed, the usage duration of the target machine number is obtained.
[0234] If the usage duration of the target machine number exceeds the lifetime limit, then the target machine number is released.
[0235] In one embodiment, the processor 801 is also used for:
[0236] Receive the most recent usage time of the target machine number reported by the target identifier generator;
[0237] The target machine number and its most recent usage time are associated and stored in the database of the distributed system.
[0238] In one embodiment, when the processor 801 schedules the target identifier generator in the distributed system to provide identifier generation services to the business system based on the target machine number, it may specifically be used to:
[0239] Receive the identifier generation request from the business system, which carries business data;
[0240] The identifier generation request is sent to the target identifier generator, so that the target identifier generator can generate an identifier for the business data based on the business type to which the business data belongs and the target machine number, and return it to the business system.
[0241] In one embodiment, the target identifier generator generates an identifier in a first format for the business data, converts the identifier in the first format into an identifier in a second format, and returns it to the business system; the first format is a numeric format, and the second format is a character format.
[0242] The identifier in the first format includes a time field, a type field, and a machine field; the time field is used to represent the timestamp of the generation of the identifier in the first format; the type field is used to represent the service type to which the service data belongs; and the machine field is used to represent the target machine number.
[0243] The number of identifier generators allowed to access this distributed system is determined by the length of the machine's bit segment.
[0244] In this embodiment, an access request from a target identifier generator is received, the access request carrying a target machine number; the target identifier generator is verified for access based on the target machine number; if the target identifier generator passes the access verification, the target identifier generator is connected to the distributed system; and the target identifier generator in the distributed system is scheduled to provide identifier generation services to the business system based on the target machine number; the service center device in the distributed system can uniformly manage and schedule the identifier generator, and can provide a stable and highly available identifier generation service to the business system, effectively ensuring the entire identifier generation service; and the identifier generator generates identifiers for business data based on the machine number, so the generated identifiers have global uniqueness to a certain extent.
[0245] Optionally, when the computer device is a service center device in the aforementioned distributed system, in this embodiment, the processor 801 performs the following operations by running the executable program code in the memory 804:
[0246] Send an access request to the service center device of the distributed system. The access request carries the target machine number. The access request is used to request the service center device to perform access verification on the target identifier generator according to the target machine number, and to request the service center device to connect the target identifier generator to the distributed system after the access verification is passed.
[0247] According to the scheduling of the service center equipment, the identification generation service is provided to the business system based on the target machine number.
[0248] In one embodiment, the processor 801 is also used for:
[0249] The service center equipment retrieves a second list of machine numbers, which includes at least one permitted machine number.
[0250] Select the target machine number from the second machine number list and generate the access request; the target machine number refers to any machine number allowed in the second machine number list.
[0251] In one embodiment, the processor 801 is also used for:
[0252] The service center equipment is used to query the first machine number list, which records at least one machine number that has been occupied.
[0253] Based on the first machine number list and the number of identifier generators allowed to access the distributed system, a second machine number list is determined, which includes at least one allowed machine number; the number of identifier generators allowed to access the distributed system is determined by the length of the machine bit field.
[0254] Select the target machine number from the second machine number list and generate the access request; the target machine number refers to any machine number allowed in the second machine number list.
[0255] In one embodiment, the processor 801 is also used for:
[0256] If the target identifier generator fails the access verification and is refused access to the distributed system, a new allowed machine number is selected from the second machine number list and the access request is re-initiated.
[0257] In one embodiment, the processor 801 is also used for:
[0258] When the target identifier generator is connected to the distributed system, obtain the time-to-live (TTL) set by the service center device for the target identifier generator;
[0259] Within the timeframe of the specified lifetime, a renewal request is sent to the service center device, which requests the service center device to reset the lifetime; and,
[0260] Report the most recent usage time of the target identifier generator to the service center equipment regarding the target machine number.
[0261] In one embodiment, when the processor 801 provides an identifier generation service to the business system based on the target machine number according to the scheduling of the service center device, it may specifically be used for:
[0262] Receive the identification generation request for the business system sent by the equipment scheduling of the service center, which carries business data;
[0263] A first-format identifier is generated for the business data based on the business type to which the business data belongs and the target machine number;
[0264] The identifier in the first format is converted into an identifier in the second format, and the identifier in the second format is returned to the business system.
[0265] In one embodiment, the processor 801 is also used for:
[0266] Upon receiving an identifier generation request from the service center's equipment scheduling system for the business system, the current system time of the target identifier generator is obtained;
[0267] Based on the target machine number, query the service center equipment for the most recent usage time of the target machine number;
[0268] Based on the most recent usage time of the target machine number and the current system time, determine whether the target identifier generator has a clock rollback situation;
[0269] If it is determined that the target identifier generator does not have a clock rollback, the step of generating an identifier in the first format for the service data based on the service type to which the service data belongs and the target machine number is performed.
[0270] In one embodiment, when the processor 801 determines whether the target identifier generator has a clock rollback based on the most recent usage time of the queried target machine number and the current system time, it can specifically be used to:
[0271] Compare the most recent usage time of the target machine number with the current system time;
[0272] If the most recent usage time of the target machine number is earlier than the current system time, it is determined that the target identifier generator does not have a clock rollback.
[0273] In one embodiment, the processor 801 is also used for:
[0274] If the most recent usage time of the target machine number obtained in the query is equal to or later than the current system time, it is determined that the target identifier generator has a clock rollback situation, the identifier generation service process is stopped, and an alarm message is output.
[0275] In this embodiment, an access request is sent to the service center device of the distributed system, carrying the target machine number. The access request is used to request the service center device to perform access verification on the target identifier generator based on the target machine number, and to request the service center device to connect the target identifier generator to the distributed system after the access verification is passed. According to the scheduling of the service center device, the identifier generation service is provided to the business system based on the target machine number. Providing the identifier generation service through the machine number of the identifier generator can not only effectively ensure the uniqueness of the identifier generated for the business data, but also know how to locate the corresponding identifier generator through the identifier, thereby achieving efficient and intelligent ID positioning.
[0276] Furthermore, it should be noted that this application also provides a computer-readable storage medium storing a computer program, which includes program instructions. When a processor executes these program instructions, it can execute the aforementioned... Figure 2 , Figure 3 and Figure 5 The methods described in the corresponding embodiments are therefore not repeated here. For technical details not disclosed in the computer-readable storage medium embodiments related to this application, please refer to the description of the method embodiments of this application. As an example, program instructions may be deployed on a computer device, executed on multiple computer devices located in one location, or executed on multiple computer devices distributed in multiple locations and interconnected through a communication network.
[0277] According to one aspect of this application, a computer program product is provided, comprising a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, enabling the computer device to perform the aforementioned... Figure 2 , Figure 3 and Figure 5 The methods described in the corresponding embodiments are therefore not repeated here.
[0278] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0279] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Those skilled in the art will understand that implementing all or part of the processes of the above embodiments and making equivalent changes in accordance with the claims of this application are still within the scope of the invention.
Claims
1. A data processing method, characterized in that, The method is applied to a distributed system, which includes one or more identifier generators and a service center device. The service center device manages the access of the one or more identifier generators and schedules the accessed identifier generators to provide identifier generation services to the business system. The distributed system includes a first machine number list and a second machine number list. The first machine number list records at least one machine number that is currently in use. The second machine number list includes at least one machine number that is allowed to be used. The method is executed by the service center device and includes: Receive an access request from the target identifier generator, wherein the access request carries a target machine number, and the target machine number refers to any machine number allowed in the second machine number list; The target identifier generator is access verified based on the target machine number and the first machine number list; the access verification is used to ensure that each identifier generator connected to the distributed system has a unique machine number, so as to realize the unified management of the identifier generator by the service center equipment based on the machine number; If the target identifier generator passes the access verification, the target identifier generator is connected to the distributed system; and the target identifier generator in the distributed system is scheduled to provide identifier generation services to the business system based on the target machine number. If the target identifier generator fails the access verification and is refused access to the distributed system, then the system receives an access request initiated by the target identifier generator using an allowed machine number reselected from the second machine number list, so as to perform access verification based on the reselected allowed machine number.
2. The method as described in claim 1, characterized in that, The step of performing access verification on the target identifier generator based on the target machine number and the first machine number list includes: The target machine number is compared with at least one machine number that is already in use in the first machine number list; If the target machine number is not an already occupied machine number, then the target identifier generator is determined to have passed the access verification. If the target machine number is already in use, then the target identifier generator is determined to have failed the access verification.
3. The method as described in claim 2, characterized in that, The database of the distributed system also includes the second machine number list; If the target identifier generator passes the access verification, then connecting the target identifier generator to the distributed system includes: If the target identifier generator passes the access verification, then the target machine number is associated with and stored in the database of the distributed system along with the communication address of the target identifier generator; and, Change the status of the target machine number from the allowed use status to the occupied status, remove the occupied target machine number from the second machine number list, and add the occupied target machine number to the first machine number list.
4. The method as described in claim 1, characterized in that, The method further includes: When the target identifier generator is connected to the distributed system, a time-to-live (TTL) is set for the target identifier generator. If a renewal request is received from the target identifier generator within the time frame of the stated lifetime, the lifetime is reset. If no renewal request is received from the target identifier generator when the time-to-live expires, the target identifier generator is removed from the distributed system and the target machine number is released; wherein, the released target machine number changes from an occupied state to an allowed state.
5. The method as described in claim 4, characterized in that, The method further includes: Within the timeframe of the stated lifetime, if the target identifier generator is detected to have crashed, the duration of use of the target machine number is obtained. If the usage duration of the target machine number exceeds the lifetime, then the target machine number is released.
6. The method as described in claim 1, characterized in that, The method further includes: Receive the most recent usage time of the target machine number reported by the target identifier generator; The target machine number and the time of its most recent use are associated and stored in the database of the distributed system.
7. The method according to any one of claims 1-6, characterized in that, The scheduling of the target identifier generator in the distributed system to provide identifier generation services to the business system based on the target machine number includes: Receive the identifier generation request from the business system, wherein the identifier generation request carries business data; The identifier generation request is sent to the target identifier generator, so that the target identifier generator generates an identifier for the business data based on the business type to which the business data belongs and the target machine number, and returns it to the business system.
8. The method as described in claim 7, characterized in that, The target identifier generator generates an identifier in a first format for the business data, and converts the identifier in the first format into an identifier in a second format before returning it to the business system; the first format is a numeric format, and the second format is a character format; The identifier of the first format includes a time field, a type field, and a machine field; the time field is used to represent the generation timestamp of the identifier of the first format; the type field is used to represent the business type to which the business data belongs; and the machine field is used to represent the target machine number. The number of identifier generators allowed to access the distributed system is determined by the length of the machine bit segment.
9. A data processing method, characterized in that, The method is applied to a distributed system, which includes one or more identifier generators and a service center device. The service center device manages the access of one or more identifier generators and schedules the accessed identifier generators to provide identifier generation services to the business system. The distributed system includes a first machine number list and a second machine number list. The first machine number list records at least one machine number that is already in use. The second machine number list includes at least one machine number that is allowed to be used. The method is executed by the target identifier generator and includes: An access request is sent to the service center device of the distributed system, the access request carrying a target machine number; the access request is used to request the service center device to perform access verification on the target identifier generator according to the target machine number and the first machine number list, and to request the service center device to connect the target identifier generator to the distributed system after the access verification of the target identifier generator passes; the access verification is used to ensure that each identifier generator connected to the distributed system has a unique machine number, so as to realize the unified management of identifier generators by the service center device based on the machine number; According to the scheduling of the service center equipment, an identifier generation service is provided to the business system based on the target machine number; If the target identifier generator fails the access verification and is refused access to the distributed system, a new allowed machine number is selected from the second machine number list and the access request is re-initiated so that the service center device can perform access verification based on the newly selected allowed machine number.
10. The method as described in claim 9, characterized in that, The method further includes: The service center equipment is used to query a second machine number list, wherein the second machine number list includes at least one allowed machine number; Select the target machine number from the second machine number list and generate the access request; the target machine number refers to any machine number allowed in the second machine number list.
11. The method as described in claim 9, characterized in that, The method further includes: Query the first machine number list from the service center equipment; A second list of machine numbers is determined based on the first list of machine numbers and the number of identifier generators allowed to access the distributed system; the number of identifier generators allowed to access the distributed system is determined by the length of the machine bit segment. Select the target machine number from the second machine number list and generate the access request; the target machine number refers to any machine number allowed in the second machine number list.
12. The method as described in claim 9, characterized in that, The method further includes: When the target identifier generator is connected to the distributed system, the time-to-live (TTL) set by the service center device for the target identifier generator is obtained; Within the timeframe of the stated lifetime, a renewal request is sent to the service center device, the renewal request being used to request the service center device to reset the lifetime; and... The service center device reports the most recent usage time of the target identifier generator regarding the target machine number.
13. The method as described in claim 9, characterized in that, The step of providing an identifier generation service to the business system based on the target machine number according to the scheduling of the service center equipment includes: Receive the identifier generation request of the business system sent by the service center equipment scheduling, wherein the identifier generation request carries business data; A first-format identifier is generated for the business data based on the business type to which the business data belongs and the target machine number; The identifier in the first format is converted into an identifier in the second format, and the identifier in the second format is returned to the business system.
14. The method as described in claim 13, characterized in that, The method further includes: Upon receiving the identifier generation request from the business system sent by the service center equipment scheduling, the current system time of the target identifier generator is obtained; Based on the target machine number, query the service center equipment for the most recent usage time of the target machine number; Based on the most recent usage time of the target machine number and the current system time, determine whether the target identifier generator has a clock rollback situation; If it is determined that the target identifier generator does not have a clock rollback, then the step of generating an identifier in the first format for the service data according to the service type to which the service data belongs and the target machine number is executed; If it is determined that the target identifier generator has a clock rollback, then the identifier generation service process is stopped and an alarm message is output. Wherein, the case where the target identifier generator does not have clock rollback means that the most recent usage time of the queried target machine number is earlier than the current system time; the case where the target identifier generator has clock rollback means that the most recent usage time of the queried target machine number is equal to or later than the current system time.
15. A data processing apparatus, characterized in that, The device is applied to a distributed system, which includes one or more identifier generators and a service center device. The service center device manages the access of one or more identifier generators and schedules the accessed identifier generators to provide identifier generation services to the business system. The distributed system includes a first machine number list and a second machine number list. The first machine number list records at least one machine number that has been occupied. The second machine number list includes at least one machine number that is allowed to be used. The device is deployed in the service center equipment, and the device includes: The receiving unit is configured to receive an access request from the target identifier generator, wherein the access request carries a target machine number; the target machine number refers to any machine number allowed in the second machine number list; The processing unit is used to perform access verification on the target identifier generator according to the target machine number and the first machine number list; the access verification is used to ensure that each identifier generator connected to the distributed system has a unique machine number, so as to realize the unified management of the identifier generator by the service center device based on the machine number; The processing unit is further configured to, if the target identifier generator passes the access verification, connect the target identifier generator to the distributed system; and, The processing unit is also configured to schedule the target identifier generator in the distributed system to provide identifier generation services to the business system based on the target machine number; The receiving unit is further configured to receive an access request initiated by the target identifier generator from the second list of allowed machine numbers if the target identifier generator fails the access verification and is refused access to the distributed system, so as to perform access verification based on the reselected allowed machine number.
16. A data processing apparatus, characterized in that, The device is applied to a distributed system, which includes one or more identifier generators and a service center device. The service center device manages the access of one or more identifier generators and schedules the accessed identifier generators to provide identifier generation services to the business system. The distributed system includes a first machine number list and a second machine number list. The first machine number list records at least one machine number that has been occupied. The second machine number list includes at least one machine number that is allowed to be used. The device is deployed in the target identifier generator, and the device includes: The sending unit is configured to send an access request to the service center device of the distributed system, the access request carrying a target machine number; the access request is configured to request the service center device to perform access verification on the target identifier generator according to the target machine number and the first machine number list, and to request the service center device to connect the target identifier generator to the distributed system after the access verification of the target identifier generator passes; the access verification is configured to ensure that each identifier generator connected to the distributed system has a unique machine number, so as to realize the unified management of the identifier generator by the service center device based on the machine number; The processing unit is configured to provide an identifier generation service to the business system based on the target machine number, according to the scheduling of the service center equipment. The processing unit is further configured to, if the target identifier generator fails the access verification and is refused access to the distributed system, select a new allowed machine number from the second machine number list and re-initiate the access request, so that the service center device can perform access verification based on the newly selected allowed machine number.
17. A computer device, characterized in that, include: A processor is used to execute computer programs; A computer-readable storage medium storing a computer program, which, when executed by the processor, performs the data processing method as described in any one of claims 1-14.
18. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a processor, performs the data processing method as described in any one of claims 1-14.
19. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the data processing method as described in any one of claims 1-14.
Citation Information
Patent Citations
A method and apparatus for generating data object identifiers
CN109240848A
Identification generation method and device, electronic equipment and storage medium
CN114116142A