Business processing method and device
By using distributed locks and databases to store state information in distributed systems, the problem that finite state machines cannot be applied in distributed systems is solved, and efficient business state processing is achieved.
Patent Information
- Application Number
- CN202210060909.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-19
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2042-01-19
AI Technical Summary
The prior art cannot apply finite state machines to distributed systems because the state update results are stored in device memory, which causes other devices to be unable to process the state adjustment requests corresponding to services, resulting in conflicts and inability to apply in distributed systems.
By using distributed locks in a distributed system, it receives state adjustment requests, acquires distributed locks for services, obtains state information from the database, creates a finite state machine instance, and stores the updated state information in the database, and releases the distributed locks for other devices to process.
It realizes efficient handling of business states in a distributed system, avoids state conflicts, and improves business processing efficiency.
Smart Images

Figure CN114443180B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of computer technology, and in particular to a business processing method and device. Background Art
[0002] A finite state machine is a mathematical model of a finite number of states and the transitions and actions between these states. It can be used to help handle the transitions and triggered actions between multiple states in complex processes and is a commonly used method for business processing.
[0003] In existing business processing methods, after the corresponding event of a business is completed, the business execution direction sends a state adjustment request corresponding to the business. The device containing the finite state machine can then determine the current state of the business corresponding to the state adjustment request based on the business information carried in the received state adjustment request. Based on the determined current state of the business and preset configuration parameters, a finite state machine instance is created. Then, based on the event information carried in the state adjustment request, the current state of the business is updated and the updated result is stored. This allows for the creation of additional state machine instances based on subsequent state adjustment requests corresponding to the business and the updated result of the business, until the business is completed.
[0004] However, in order to make the finite state machine as lightweight as possible, the existing technology usually stores the instance in the memory of the device where the finite state machine is located when storing update results, making it impossible for other devices to process state adjustment requests corresponding to the business processed by the device, and it cannot be applied to distributed systems. Summary of the Invention
[0005] This specification provides a service processing method and device to partially solve the above-mentioned problems existing in the prior art.
[0006] This manual adopts the following technical solutions:
[0007] This specification provides a service processing method for use in a distributed system, wherein a processing unit of the distributed system receives a state adjustment request, comprising:
[0008] Receive a status adjustment request sent by a service executor, wherein the status adjustment request carries service information and event information;
[0009] According to the business information, a distributed lock for the business corresponding to the business information is obtained, where the distributed lock corresponds one-to-one to the business corresponding to the business information stored in the database;
[0010] According to the distributed lock, obtaining the state information corresponding to the business from the database, and creating a finite state machine instance according to the state information and preset configuration parameters;
[0011] Update the state information corresponding to the service according to the event information and the finite state machine instance;
[0012] The updated status information is stored in a database, and the distributed lock is released so that the business executor performs business processing according to the updated status information.
[0013] Optionally, obtaining a distributed lock for a business corresponding to the business information according to the business information specifically includes:
[0014] Determining, based on the service information, an identifier of the service corresponding to the status adjustment request;
[0015] According to the identifier, determining whether there is a distributed lock corresponding to the business;
[0016] If so, after the distributed lock corresponding to the business is destroyed, create a distributed lock corresponding to the business;
[0017] If not, create a distributed lock corresponding to the business.
[0018] Optionally, there are multiple status adjustment requests, and each status adjustment request corresponds to a different service;
[0019] After the distributed lock corresponding to the business is destroyed, creating a distributed lock corresponding to the business specifically includes:
[0020] Determine the business corresponding to each status adjustment request;
[0021] For each business, sort the status adjustment requests corresponding to the business;
[0022] After the distributed lock corresponding to the business is destroyed, a target state adjustment request is determined from the state adjustment requests according to the sorting, and the distributed lock corresponding to the business is created according to the target state adjustment request.
[0023] Optionally, according to the distributed lock, obtaining status information corresponding to the business from the database specifically includes:
[0024] According to the distributed lock, determining whether status information corresponding to the business information exists in the database;
[0025] If so, obtaining status information corresponding to the service;
[0026] If not, the initial state information corresponding to the service is determined according to preset configuration parameters.
[0027] Optionally, updating the state information corresponding to the service according to the event information and the finite state machine instance specifically includes:
[0028] Determine, based on the finite state machine instance and the event information, whether there is an event corresponding to the event information among the triggering events of the state information corresponding to the business information;
[0029] If so, transferring the state corresponding to the business according to the event corresponding to the event information;
[0030] If not, a prompt message is returned according to the status adjustment request, where the prompt message is used to prompt that the status adjustment request fails to be executed.
[0031] Optionally, the multiple businesses executed by the business executor belong to different task stages of the same task, and each task includes at least one task stage;
[0032] Create a finite state machine instance based on the state information and preset configuration parameters, specifically including:
[0033] For each task stage, when the business execution is determined to be completed according to the business stages of each business in the task stage, the next task stage of the task stage is determined as the target task stage;
[0034] The configuration parameters corresponding to the target task stage are determined, and when a state adjustment request for the service of the target task stage is received, a finite state machine instance is created according to the configuration parameters, service state information and preset configuration parameters.
[0035] Optionally, storing the updated status information in a database so that the service executor performs service processing according to the updated status information specifically includes:
[0036] The updated status information is stored in a database, so that when the business executor processes the business, it can obtain the status information of the business from the database and process the business according to the status information of the business.
[0037] This specification provides a service processing device for use in a distributed system, wherein a processing unit of the distributed system receives a state adjustment request, including:
[0038] A receiving module, configured to receive a status adjustment request sent by a service executor, wherein the status adjustment request carries service information and event information;
[0039] An acquisition module, configured to acquire, based on the business information, a distributed lock for the business corresponding to the business information, wherein the distributed lock corresponds one-to-one to the business corresponding to the business information stored in the database;
[0040] A creation module, configured to obtain, from the database, state information corresponding to the business according to the distributed lock, and to create a finite state machine instance according to the state information and preset configuration parameters;
[0041] An updating module, configured to update the state information corresponding to the service according to the event information and the finite state machine instance;
[0042] The storage module is used to store the updated status information in the database and release the distributed lock so that the business executor can perform business processing according to the updated status information.
[0043] This specification provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned business processing method is implemented.
[0044] This specification provides an unmanned driving device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned business processing method when executing the program.
[0045] At least one of the above technical solutions adopted in this specification can achieve the following beneficial effects:
[0046] In the business processing method provided in this specification, by receiving a state adjustment request carrying business information and event information sent by a business executor, a distributed lock of the business corresponding to the business information is obtained according to the business information, and based on the distributed lock, the state information corresponding to the business is obtained from the database, and a finite state machine instance is created based on the state information and preset configuration parameters, and then the state information corresponding to the business is updated according to the event information and the finite state machine instance, the updated state information is stored in the database, and the distributed lock is released so that the business executor can perform business processing according to the updated state information.
[0047] It can be seen from the above method that this method can store the state corresponding to the business in the database, and based on the distributed lock, the finite state machine is applied to the distributed system, which makes the business processing more efficient. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The drawings described herein are used to provide a further understanding of this specification and constitute a part of this specification. The exemplary embodiments and descriptions of this specification are used to explain this specification and do not constitute an improper limitation of this specification. In the drawings:
[0049] Figure 1 A flowchart of the business processing method provided in this manual;
[0050] Figure 2 A flowchart of the business processing method provided in this manual;
[0051] Figure 3 A schematic diagram of the business processing device provided in this manual;
[0052] Figure 4 The corresponding Figure 1 Schematic diagram of electronic equipment. DETAILED DESCRIPTION
[0053] To make the objectives, technical solutions, and advantages of this specification more clear, the following will clearly and completely describe the technical solutions of this specification in conjunction with the specific embodiments of this specification and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without making any creative efforts are within the scope of protection of this specification.
[0054] Typically, after a finite state machine device updates the current service state based on a state adjustment request, it stores the state in its memory. Consequently, for each service, other devices that haven't processed a state adjustment request for that service cannot access the current state of that service. Consequently, even when receiving a state adjustment request for that service, they are unable to modify the state adjustment request. In other words, each state adjustment request for each service can only be processed by one service, making existing technologies unsuitable for use in distributed systems.
[0055] Furthermore, even if existing technologies store update results in a database, this cannot be applied to distributed systems. For example, a distributed system consisting of devices A and B cannot be applied. Assume that service 1 has three states: x, y, and z, and that both y and z can be transferred from x. If devices A and B simultaneously receive different state adjustment requests for service 1, and the state request received by device A carries event information xy, while the state request received by device B carries event information xz, then device A will store the current state of service 1 as y, and device B will store the current state of service 1 as z. Therefore, there is a conflict between whether service 1's current state is y or x.
[0056] Based on the above, it is obvious that finite state machines cannot be applied to distributed systems.
[0057] The technical solutions provided by the embodiments of this specification are described in detail below with reference to the accompanying drawings.
[0058] Figure 1The following is a flowchart of a business processing method in this specification, which specifically includes the following steps:
[0059] S100: Receive a state adjustment request, where the state adjustment request carries service information and event information.
[0060] In one or more embodiments provided in this specification, the business processing method is aimed at a scenario in which, after the event corresponding to the business is executed, the business executor sends a state adjustment request to the processing unit in the distributed system based on the business identifier and event information of the business to change the current state of the business. The business processing process can be specifically executed by the processing unit in the distributed system.
[0061] Generally, during the process of executing services in a distributed system, a processing unit in the distributed system usually receives a state adjustment request and processes the service corresponding to the state adjustment request according to the received state adjustment request.
[0062] Specifically, a processing unit in the distributed system may receive a state adjustment request. The state adjustment request is sent by a service executor to the processing unit in the distributed system based on a service identifier and event information of the service. The state adjustment request includes service information and time information. The service information includes a specific identifier corresponding to the service.
[0063] From a software perspective, a processing unit can also be referred to as a processing node. Each node in the system is code that can run on a server. The functionality of each node is achieved by running the code of each node. In this specification, the code of different nodes is independent of each other, and each node can communicate with other nodes through a pre-defined data interface. From a hardware perspective, the processing units in this specification can be servers or different data processing units running on the same server.
[0064] S102: According to the business information, a distributed lock of the business corresponding to the business information is obtained, where the distributed lock corresponds one-to-one to the business corresponding to the business information stored in the database.
[0065] Unlike existing technologies that fail to apply finite state machines to distributed scenarios due to conflicts and other issues, this specification provides a new business processing method that enables the application of finite state machines in distributed systems based on distributed locks. Based on this, upon receiving a state adjustment request, the processing unit can determine the distributed lock corresponding to the business information carried in the state adjustment request based on the business information.
[0066] Specifically, the processing unit in the distributed system may determine the service corresponding to the service information according to the service information in the acquired state adjustment request.
[0067] Then, the processing unit may obtain the distributed lock corresponding to the business.
[0068] The processing unit may send a distributed lock acquisition request to the processing unit for issuing distributed locks in the distributed system, and the processing unit for issuing distributed locks may return the distributed lock to the processing unit according to the distributed lock acquisition request.
[0069] Of course, the processing unit can also query whether there is a distributed lock corresponding to the business in the distributed system. If so, it can be considered that the business has been occupied and it is necessary to wait for the distributed lock corresponding to the business to be destroyed before creating a distributed lock corresponding to the business.
[0070] If it does not exist, the processing unit may create a distributed lock corresponding to the business.
[0071] Furthermore, multiple state adjustment requests corresponding to the same business may be received by different processing units in the same distributed system. Therefore, if a distributed lock corresponding to a business exists, and there are multiple state adjustment requests corresponding to the business that need to be processed. The processing unit that receives the state adjustment request in the distributed system can determine the business corresponding to each state adjustment request, and then, for each business, sort the state adjustment requests corresponding to the business, and when the distributed lock corresponding to the business is destroyed, according to the sorting, from each state adjustment request, determine the target state adjustment request for which a distributed lock needs to be created, and the processing unit that receives the target state adjustment request creates the distributed lock corresponding to the business according to the target state adjustment request.
[0072] The manner of sorting the status adjustment requests may be to sort the status adjustment requests based on the time at which the status adjustment requests are received.
[0073] Of course, it is also possible to determine the state adjustment request for occupying the distributed lock corresponding to the business, determine the state corresponding to the business, and sort the state adjustment requests according to the state.
[0074] It should be noted that for each business, the distributed lock corresponding to the business locks the location where the status corresponding to the business is stored, or locks the row where the business is located in the table in the database. That is to say, for each business, the business has a unique corresponding storage address or a unique corresponding row in the table in the database, and the distributed lock corresponding to the business locks the storage address corresponding to the business or the row where the business is located, allowing and only allowing one processing unit in the distributed system to read / write the status of the business at the same time. And the distributed locks in the distributed system correspond one-to-one to the businesses corresponding to the business information stored in the database. That is, the distributed locks in the distributed system correspond to the businesses corresponding to the business information stored in the database. That is, at each moment, if a distributed lock exists for the business corresponding to the business information stored in the database, there is one and only one unique distributed lock corresponding to the business.
[0075] S104: According to the distributed lock, obtain the state information corresponding to the business from the database, and create a finite state machine instance according to the state information and preset configuration parameters.
[0076] In one or more embodiments provided herein, after determining a distributed lock, the processing unit may retrieve and modify the state information corresponding to the service, i.e., perform read and / or write operations. Modifying the state of a service requires determining the finite state machine instance corresponding to the service based on preset configuration parameters, and performing modifications based on that instance.
[0077] Based on this, the processing unit can determine the finite state machine instance corresponding to the service.
[0078] Specifically, the processing unit may obtain status information corresponding to the business from the database according to the distributed lock.
[0079] The processing unit may query the service and the status information corresponding to the service from the database corresponding to the distributed system based on the service identifier corresponding to the service. If the status information corresponding to the service can be queried, a finite state machine instance may be created based on the status information and preset configuration parameters. If the status information corresponding to the service cannot be queried, the processing unit may determine the initial state corresponding to the service based on the preset configuration parameters as the current state of the service, and create a finite state machine instance based on the status information and the preset configuration parameters.
[0080] Among them, the preset configuration parameters are the states contained in the business corresponding to the finite state machine, and the events corresponding to each state jump. Taking the business corresponding to mapping as an example, the states corresponding to each business usually include several processes such as not starting mapping, mapping in progress, and mapping completed. Therefore, for the mapping business, each processing unit can receive state adjustment requests corresponding to multiple events such as "start drawing" and "drawing completed". For the quality inspection business after the mapping business, the states corresponding to each business usually include several processes such as not starting quality inspection, quality inspection in progress, quality inspection completed, and starting random inspection, random inspection in progress, and random inspection completed. Therefore, for the quality inspection business, each processing unit can receive state adjustment requests corresponding to multiple events such as "start quality inspection" and "quality inspection completed".
[0081] Of course, the distributed lock corresponding to the business may also carry the storage address of the business in the database, and the processing unit may also determine the current state of the business from the database based on the storage address. If the distributed lock does not have the storage address corresponding to the business, the processing unit may also store the current state of the business based on the business and the initial state corresponding to the business, and establish a connection between the storage address and the distributed lock.
[0082] It should be noted that the above configuration parameters may be determined through a configuration file. When processing a drawing service, the configuration parameters may be read to determine the state machine corresponding to the drawing service, and a state machine instance may be generated based on the state machine.
[0083] S106: Update the state information corresponding to the service according to the event information and the finite state machine instance.
[0084] In one or more embodiments provided in this specification, after determining the finite state machine instance corresponding to the service, the processing unit may update the state corresponding to the service based on the event information and the finite state machine instance.
[0085] Specifically, the processing unit may determine the current state corresponding to the service in the finite state machine, and judge whether there is an event corresponding to the event information among the triggering events of the state information corresponding to the service.
[0086] If so, the processing unit may transfer the state corresponding to the business according to the event corresponding to the event information.
[0087] If not, the processing unit may return prompt information according to the status adjustment request, wherein the prompt information is used to prompt that the status adjustment request fails to be executed.
[0088] S108: The updated state information is stored in the database, and the distributed lock is released, so that the business executor performs business processing according to the updated state information.
[0089] In one or more embodiments provided in this specification, since the business processing method in this specification processes the business corresponding to each business stage in a task, after determining each business stage, it is also necessary to store the status corresponding to each business so that the business executor can perform business processing based on the updated status information.
[0090] Specifically, the processing unit may store the updated state information in a database, so that each processing unit in the distributed system can obtain the state information corresponding to the service.
[0091] At the same time, the processing unit may also release the distributed lock so that other processing units that receive a status adjustment request corresponding to the service can adjust the status information of the service.
[0092] The subsequent business execution party can then process the business according to the updated status of each business. For example, after all mapping tasks are completed, the business execution party can perform quality inspection tasks according to the completion status of each mapping task.
[0093] based on Figure 1 A business processing method receives a state adjustment request from a business executor carrying business information and event information, obtains a distributed lock for the business corresponding to the business information based on the business information, obtains the state information corresponding to the business from a database based on the distributed lock, and creates a finite state machine instance based on the state information and preset configuration parameters. The state information corresponding to the business is then updated based on the event information and the finite state machine instance, and the updated state information is stored in the database. The distributed lock is then released, allowing the business executor to perform business processing based on the updated state information. This method can store the state corresponding to the business in a database and, based on the distributed lock, applies the finite state machine to a distributed system, resulting in higher business processing efficiency.
[0094] In addition, based on Figure 1 , this manual also provides a business processing flow diagram, such as Figure 2 shown. Figure 2 In the process, after receiving the state adjustment processing request, the processing unit can obtain the distributed lock, and determine the current state corresponding to the business based on the obtained distributed lock, and then create a state machine instance based on the current state of the business, and update and store the current state of the business based on the state machine instance, and release the distributed lock after storing the current state of the business, that is, destroy the distributed lock.
[0095] In addition, in this specification, the business processing method is applied to a scenario where a task has multiple task stages, each task stage corresponds to a different business, and each business has multiple states.
[0096] For example, the task of generating an HD map involves multiple stages, including map drawing, map quality inspection, map synthesis, and combined map quality inspection. For example, if the HD map can be divided into six regions, then during the HD map drawing phase, each of these six regions can correspond to different services, such as the mapping service for Region 1 and the mapping service for Region 2. Each mapping service has a corresponding status, such as "not started," "drawing in progress," or "completed."
[0097] For each region in the HD map, the service executor can first query the status of the corresponding service before executing the service corresponding to that region, and then execute the service based on the queried status. For example, during the drawing phase, the service executor can query the status of region 1 before executing the service corresponding to region 1. If the status of region 1 is "not drawing started", the service executor can execute the drawing operation based on this status. After starting the drawing, the service executor sends a status adjustment request to the processing unit in the distributed system with the service information "Drawing service for region 1" and the event information "Drawing in progress".
[0098] When the processing unit in the distributed system receives the state adjustment request, it can obtain the distributed lock corresponding to the business according to the state adjustment request, and determine that the state corresponding to the business is "drawing" based on the business information, time information, and the distributed lock in the state adjustment request, and store the state.
[0099] In addition, after the map drawing phase is completed, the task may enter the mapping quality inspection phase, which may include two modules: quality inspection and random inspection. If distributed locks are not applied in this solution, it is possible that processing units in the distributed system simultaneously receive state adjustment requests with event information corresponding to the business, indicating "quality inspection passed" and "random inspection failed", respectively. This may cause different processing units in the distributed system to change the state corresponding to the business to "passed" and "failed", resulting in conflicting states for the business and the risk of machine downtime. However, when distributed locks are applied, if state adjustment requests with event information indicating "quality inspection passed" and "random inspection failed" are received simultaneously, only one processing unit can obtain and change the state corresponding to the business at a time. The processing unit that receives the other state request can wait and, after obtaining the distributed lock, change the state corresponding to the business. Of course, if the current state information of the business does not match the event information, the processing unit can return a "processing failed" prompt message based on the state adjustment request.
[0100] Furthermore, when a business executor processes a business, it is possible that other business executors may repeatedly process the business, or may also need to process the business. However, it is obvious that different business executors may have different processing results for the same business, such as the "quality inspection" and "spot inspection" operations performed by the aforementioned business executor. Even if they are the same, different business executors or different execution units in the same business executor perform the same operation on the same business, which will waste the computing resources of the business executor. Therefore, after receiving the status adjustment request sent by the business executor, the processing unit in the distributed system can verify the status adjustment request to avoid the situation where multiple other business executors obtain the status and business information of the same business.
[0101] Specifically, after receiving the status adjustment request, the processing unit can determine the current status of the business and the business executor of the status adjustment request corresponding to the current status of the business based on the business information carried in the status adjustment request, that is, the business executor who last adjusted the status of the business, and determine whether the business executor is the same business executor as the business executor corresponding to the status adjustment request received this time.
[0102] If yes, the processing unit may process the service according to the current status of the service and the status adjustment request. If no, the processing unit may return an early warning message to the service executor corresponding to the status adjustment request and the service executor who last adjusted the status of the service, respectively, to indicate that an error has occurred in the status corresponding to the service.
[0103] Furthermore, when multiple business executors or different execution units of a business executor execute the various businesses corresponding to the same task with multiple task stages, the amount of data corresponding to the business corresponding to the task and the status corresponding to each business is large. If the status information is stored within the business executor, not only will it be challenging to query this status information, but it will also have a certain impact on the business executor's storage resources and operational efficiency. In addition, the business executor needs to query the status corresponding to the business before executing the business. If the query speed is slow, it will lead to a decrease in the execution efficiency of the business. Based on this, the status corresponding to the business can be stored in the corresponding database of the distributed system, and the processing units in the distributed system can perform read / write operations on this database.
[0104] Of course, in order to ensure the security of the business and avoid multiple business executors from executing a business at the same time, the processing unit can also store the business information corresponding to the business when storing the status corresponding to the business. Before executing the business, the business executor needs to query the status corresponding to the business, and send status adjustment information to the processing unit based on the status and the business to be executed. The processing unit adjusts the status corresponding to the business according to the received status adjustment request, and sends the stored business information to the business executor according to the status adjustment request. After the business executor completes the execution of the business, the status corresponding to the business is updated and the business information is stored. Among them, the business information includes the data required to execute the business, as well as the files constructed during the business execution process. For example, the business information of the map drawing business can be the elements contained in the map construction, the existing map framework, etc.
[0105] In addition, for each business, it can be roughly divided into three steps: unexecuted, in execution, and completed. When the business is in the unexecuted or completed state, the processing unit can process the state corresponding to the business according to the state adjustment request sent by each business executor. However, when the business is in the executing state, the processing unit can only adjust the state corresponding to the business based on the state adjustment request of the business executor corresponding to the state adjustment request to change the state corresponding to the business to the executing state. If the business information corresponding to the business and the state information corresponding to the business are stored in the database together using a distributed lock, it may happen that other business executors cannot obtain the business information except for the business executor who adjusted the state of the business last time. Obviously, each business executor cannot synchronously process other businesses corresponding to the business. In the scenario where each business executor executes each business corresponding to the same task with multiple task stages, the execution efficiency is low.
[0106] Therefore, the processing unit can also receive query requests and status adjustment requests from various service execution parties. Query requests are used to query the status of each service and the service information contained within it, but cannot delete, modify, or add operations to the status or service information corresponding to the service. Status adjustment requests are used to modify the status of a service, store the modified status, and update the service information corresponding to the service. Upon receiving a query request, the processing unit can query the status of the service from the database based on the service identifier carried in the query request, and return the status to the service execution party corresponding to the query request. Upon receiving a status adjustment request, the processing unit can verify the status adjustment request based on the identifier of the service execution party that last modified the service status and the status of the service. If verification is successful, the processing unit can request a distributed lock and modify the status of the service based on the status adjustment request. If verification is unsuccessful, the processing unit can send a notification message to the service execution party that requested the status adjustment and the service execution party that last modified the service status, indicating that the status adjustment request failed.
[0107] The above is a service processing method provided by one or more embodiments of this specification. Based on the same idea, this specification also provides a corresponding service processing device, such as Figure 3 shown.
[0108] Figure 3 This is a schematic diagram of a business processing device provided in this specification, which is used in a distributed system. The processing unit of the distributed system receives a state adjustment request, specifically including:
[0109] The receiving module 200 is configured to receive a status adjustment request sent by a service executor, wherein the status adjustment request carries service information and event information.
[0110] The acquisition module 202 is configured to acquire, based on the business information, a distributed lock for the business corresponding to the business information, wherein the distributed lock corresponds one-to-one to the business corresponding to the business information stored in the database.
[0111] The creation module 204 is configured to obtain the state information corresponding to the business from the database according to the distributed lock, and to create a finite state machine instance according to the state information and preset configuration parameters.
[0112] The updating module 206 is configured to update the state information corresponding to the service according to the event information and the finite state machine instance.
[0113] The storage module 208 is used to store the updated state information in a database and release the distributed lock so that the business executor can perform business processing according to the updated state information.
[0114] Optionally, the acquisition module 202 is used to determine the identifier of the business corresponding to the status adjustment request based on the business information, and judge whether there is a distributed lock corresponding to the business based on the identifier. If so, create a distributed lock corresponding to the business after the distributed lock corresponding to the business is destroyed; if not, create a distributed lock corresponding to the business.
[0115] Optionally, there are multiple state adjustment requests, and each state adjustment request corresponds to a different business. The acquisition module 202 is used to determine the business corresponding to each state adjustment request, and for each business, sort the state adjustment requests corresponding to the business. After the distributed lock corresponding to the business is destroyed, according to the sorting, the target state adjustment request is determined from each state adjustment request, and the distributed lock corresponding to the business is created according to the target state adjustment request.
[0116] Optionally, the creation module 204 is used to determine whether status information corresponding to the business information exists in the database based on the distributed lock. If so, obtain the status information corresponding to the business; if not, determine the initial status information corresponding to the business based on preset configuration parameters.
[0117] Optionally, the update module 206 is used to determine whether there is an event corresponding to the event information in each triggering event of the state information corresponding to the business information based on the finite state machine instance and the event information. If so, the state corresponding to the business is transferred according to the event corresponding to the event information. If not, a prompt message is returned according to the state adjustment request, and the prompt message is used to prompt that the execution of the state adjustment request has failed.
[0118] Optionally, the creation module 204 is used to determine, for each task stage, the next task stage of the task stage as the target task stage when the business execution is determined to be completed according to the business stages of each business in the task stage, determine the configuration parameters corresponding to the target task stage, and when a status adjustment request for the business of the target task stage is received, create a finite state machine instance according to the configuration parameters, the status information of the business and the preset configuration parameters.
[0119] Optionally, the storage module 208 is configured to store the updated status information in a database, so that the service executor can obtain the status information of the service from the database when processing the service, and perform service processing according to the status information of the service.
[0120] This specification also provides a computer-readable storage medium, which stores a computer program that can be used to execute the above Figure 1 Provided business processing methods.
[0121] This manual also provides Figure 4 The schematic structure diagram of the electronic device shown in FIG. Figure 4 As mentioned above, at the hardware level, the unmanned driving device includes a processor, an internal bus, a network interface, a memory and a non-volatile memory, and may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 1 Of course, in addition to software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0122] In the 1990s, technological improvements could be clearly distinguished as either hardware improvements (for example, improvements to circuit structures like diodes, transistors, and switches) or software improvements (improvements to process flows). However, with the advancement of technology, many process flow improvements today can now be considered direct improvements to hardware circuit structures. Designers almost always create the corresponding hardware circuit structure by programming the improved process flow into the hardware circuit. Therefore, it cannot be said that a process flow improvement cannot be implemented using hardware modules. For example, a programmable logic device (PLD), such as a field programmable gate array (FPGA), is an integrated circuit whose logical function is determined by user programming. Designers can "integrate" a digital system on a PLD through their own programming, without having to hire a chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly done using "logic compiler" software. This is similar to the software compiler used when developing programs. Before compilation, the original code must also be written in a specific programming language, called a hardware description language (HDL). There is not just one HDL, but many, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art will also understand that by simply programming the method flow in one of these hardware description languages and then programming it into an integrated circuit, a hardware circuit that implements the logic method flow can be easily obtained.
[0123] The controller can be implemented in any suitable manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that in addition to implementing the controller in a purely computer-readable program code format, the controller can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the devices for implementing various functions can be considered as both software modules that implement the method and structures within the hardware component.
[0124] The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0125] For the convenience of description, the above devices are described as being divided into various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0126] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0127] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0128] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0129] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0130] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0131] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0132] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0133] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0134] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Thus, this specification may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0135] This specification may be described in the general context of computer-executable instructions, such as program modules, executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media, including storage devices.
[0136] The various embodiments in this specification are described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiments are generally similar to the method embodiments, so the description is relatively simple. For relevant parts, refer to the description of the method embodiments.
[0137] The foregoing is merely an example of the present invention and is not intended to limit the present invention. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be included within the scope of the claims of the present invention.
Claims
1. A business processing method, characterized in that: Used in a distributed system, a processing unit of the distributed system receiving a state adjustment request, comprising: Receive a status adjustment request sent by a service executor, wherein the status adjustment request carries service information and event information; According to the business information, a distributed lock for the business corresponding to the business information is obtained, where the distributed lock corresponds one-to-one to the business corresponding to the business information stored in the database; According to the distributed lock, obtaining the state information corresponding to the business from the database, and creating a finite state machine instance according to the state information and preset configuration parameters; Update the state information corresponding to the service according to the event information and the finite state machine instance; The updated status information is stored in the database, and the distributed lock is released so that the business executor performs business processing according to the updated status information; Multiple businesses executed by the business executor belong to different task stages of the same task, and each task contains at least one task stage; Create a finite state machine instance based on the state information and preset configuration parameters, specifically including: For each task stage, when the business execution is determined to be completed according to the business stages of each business in the task stage, the next task stage of the task stage is determined as the target task stage; The configuration parameters corresponding to the target task stage are determined, and when a state adjustment request for the service of the target task stage is received, a finite state machine instance is created according to the configuration parameters, service state information and preset configuration parameters.
2. The method according to claim 1, wherein According to the business information, obtaining a distributed lock for the business corresponding to the business information specifically includes: Determining, based on the service information, an identifier of the service corresponding to the status adjustment request; According to the identifier, determining whether there is a distributed lock corresponding to the business; If so, after the distributed lock corresponding to the business is destroyed, create a distributed lock corresponding to the business; If not, create a distributed lock corresponding to the business.
3. The method according to claim 2, wherein There are multiple status adjustment requests, and each status adjustment request corresponds to a different service; After the distributed lock corresponding to the business is destroyed, creating a distributed lock corresponding to the business specifically includes: Determine the business corresponding to each status adjustment request; For each business, sort the status adjustment requests corresponding to the business; After the distributed lock corresponding to the business is destroyed, a target state adjustment request is determined from the state adjustment requests according to the sorting, and the distributed lock corresponding to the business is created according to the target state adjustment request.
4. The method according to claim 1, wherein According to the distributed lock, obtaining status information corresponding to the business from the database specifically includes: According to the distributed lock, determining whether status information corresponding to the business information exists in the database; If so, obtaining status information corresponding to the service; If not, the initial state information corresponding to the service is determined according to preset configuration parameters.
5. The method according to claim 1, wherein Updating the state information corresponding to the service according to the event information and the finite state machine instance, specifically including: Determine, based on the finite state machine instance and the event information, whether there is an event corresponding to the event information among the triggering events of the state information corresponding to the business information; If so, transferring the state corresponding to the business according to the event corresponding to the event information; If not, a prompt message is returned according to the status adjustment request, where the prompt message is used to prompt that the status adjustment request fails to be executed.
6. The method according to claim 1, wherein Storing the updated status information in a database so that the business executor performs business processing according to the updated status information specifically includes: The updated status information is stored in a database, so that when the business executor processes the business, it can obtain the status information of the business from the database and process the business according to the status information of the business.
7. A business processing device, characterized in that: Used in a distributed system, a processing unit of the distributed system receiving a state adjustment request, comprising: A receiving module, configured to receive a status adjustment request sent by a service executor, wherein the status adjustment request carries service information and event information; An acquisition module, configured to acquire, based on the business information, a distributed lock for the business corresponding to the business information, wherein the distributed lock corresponds one-to-one to the business corresponding to the business information stored in the database; A creation module, configured to obtain, from the database, state information corresponding to the business according to the distributed lock, and to create a finite state machine instance according to the state information and preset configuration parameters; An updating module, configured to update the state information corresponding to the service according to the event information and the finite state machine instance; A storage module, configured to store the updated status information in a database and release the distributed lock so that the business executor performs business processing according to the updated status information; Multiple businesses executed by the business executor belong to different task stages of the same task, and each task contains at least one task stage; Create a finite state machine instance based on the state information and preset configuration parameters, specifically including: For each task stage, when the business execution is determined to be completed according to the business stages of each business in the task stage, the next task stage of the task stage is determined as the target task stage; The configuration parameters corresponding to the target task stage are determined, and when a state adjustment request for the service of the target task stage is received, a finite state machine instance is created according to the configuration parameters, service state information and preset configuration parameters.
8. A computer-readable storage medium, characterized in that The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Transaction processing method, device and equipment based on block chain, and storage medium
CN110231979A
Business order process creation and implementation method and device, storage medium and system
CN111507676A