State machine execution method, system, device, computer equipment and storage medium
By distributing the state machine to be executed to multiple state machine execution devices and executing in distributed mode, the problem of high development difficulty and complexity in complex system interaction scenarios is solved, and the system development efficiency is improved.
Patent Information
- Application Number
- CN202010980283.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-17
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2040-09-17
AI Technical Summary
In the complex system interaction scenario, the business system needs to execute subsequent business logic after interacting with the external system, which leads to high development difficulty and complexity, especially in external interaction -> business logic -> external interaction -> business logic In nesting case.
Through the state machine execution method, the state machine to be executed is distributed to multiple state machine execution devices, and executed in a distributed manner to reduce the development complexity and difficulty.
The distributed execution of state machines is realized, the system development efficiency is improved, and the technical development difficulty and complexity of developers in complex system interaction scenarios are reduced.
Smart Images

Figure CN112162798B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer application technology, and in particular, to a state machine execution method, system, device, computer equipment and storage medium. Background Art
[0002] Some business systems need to interact with external systems in the process of processing business. For example, the financial leasing industry system needs to interact with a large number of external systems when processing financial business, such as calling the wind system to obtain the shibor (Shanghai Interbank Offered Rate) or libor (London Interbank Offered Rate), calling the tax system interface to issue invoices, calling the aggregated data account to obtain the annual holidays, and calling the mail server to send mails.
[0003] At present, there are mainly two implementation schemes for the external interaction logic of business systems: one is to integrate the implementation code and business code for interaction with external systems into one project; the other is to extract the code for interaction with external systems into a separate project, and then access it through inter-process calls or RPC (Remote Procedure Call Protocol) calls.
[0004] The above implementation scheme for the external interaction logic of the business system is only applicable to simple system interaction scenarios. If the business system needs to execute a lot of subsequent business logic after interacting with the external system, and there may be a nested situation of external interaction -> business logic -> external interaction -> business logic. There may even be multiple parallel business processes after one external interaction, and the process engine is required to help implement it. The above complex system interaction scenarios will undoubtedly increase the complexity and development difficulty for business developers to realize their needs. Summary of the invention
[0005] The embodiments of the present invention provide a state machine execution method, system, device, computer equipment and storage medium to reduce the difficulty and complexity of system technology development.
[0006] In a first aspect, an embodiment of the present invention provides a state machine execution method, including:
[0007] Receive the state machines to be executed uploaded by each state machine client;
[0008] Distribute each of the state machines to be executed to a plurality of state machine execution devices, so that each of the state machine execution devices executes each of the state machines to be executed in a distributed manner.
[0009] In a second aspect, an embodiment of the present invention further provides a state machine execution system, including a state machine client, a state machine management center, a message bus, and a plurality of state machine execution devices; wherein:
[0010] The state machine client is in communication connection with the state machine management center, and is used to upload the state machine to be executed to the state machine management center;
[0011] The state machine management center is connected to each of the state machine execution devices through the message bus, and is used to distribute the state machine to be executed to each of the state machine execution devices;
[0012] The state machine execution device is used to execute the received state machine to be executed.
[0013] In a third aspect, an embodiment of the present invention further provides a state machine execution device, including:
[0014] The waiting-for-execution state machine receiving module is used to receive the waiting-for-execution state machines uploaded by each state machine client;
[0015] The to-be-executed state machine distribution module is used to distribute each of the to-be-executed state machines to a plurality of state machine execution devices, so that each of the state machine execution devices executes each of the to-be-executed state machines in a distributed manner.
[0016] In a fourth aspect, an embodiment of the present invention further provides a computer device, the computer device comprising:
[0017] one or more processors;
[0018] A storage device for storing one or more programs;
[0019] When the one or more programs are executed by the one or more processors, the one or more processors implement the state machine execution method provided by any embodiment of the present invention.
[0020] In a fifth aspect, an embodiment of the present invention further provides a computer storage medium on which a computer program is stored, and when the program is executed by a processor, the state machine execution method provided by any embodiment of the present invention is implemented.
[0021] The embodiment of the present invention distributes the state machines to be executed uploaded by each state machine client to multiple state machine execution devices, so that each state machine execution device executes each state machine to be executed respectively, thereby solving the problems of high technical development difficulty and complexity in existing complex system interaction scenarios, thereby reducing the difficulty and complexity of system technology development. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1is a flow chart of a state machine execution method provided in Embodiment 1 of the present invention;
[0023] Figure 2 It is a state mode schematic diagram of a state machine provided by Embodiment 1 of the present invention;
[0024] Figure 3 is a schematic diagram of a state machine execution system provided by Embodiment 2 of the present invention;
[0025] Figure 4 is a schematic diagram of a state machine execution device provided in Embodiment 3 of the present invention;
[0026] Figure 5 A schematic diagram of the structure of a computer device provided in Embodiment 4 of the present invention. DETAILED DESCRIPTION
[0027] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention.
[0028] It should also be noted that, for ease of description, only the part relevant to the present invention but not all the content is shown in the accompanying drawings. It should be mentioned before discussing the exemplary embodiments in more detail that some exemplary embodiments are described as the processing or method described as a flow chart. Although the flow chart describes each operation (or step) as a sequential processing, many operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of each operation can be rearranged. When its operation is completed, the processing can be terminated, but it can also have additional steps not included in the accompanying drawings. The processing can correspond to a method, a function, a procedure, a subroutine, a subprogram, etc.
[0029] Embodiment 1
[0030] Figure 1 is a flow chart of a state machine execution method provided by the first embodiment of the present invention. This embodiment is applicable to the case where each state machine is executed in a distributed manner. The method can be executed by a state machine execution device. The device can be implemented by software and / or hardware and can generally be integrated in a computer device. The computer device can be used as a state machine management center device. Figure 1 As shown, the method includes the following operations:
[0031] S110: receiving the state machines to be executed uploaded by each state machine client.
[0032] The state machine client can be used to upload the state machine to be executed to the state machine management center. The state machine to be executed is also the state machine to be executed.
[0033] In an embodiment of the present invention, the state machine management center can receive the state machines to be executed uploaded by each state machine client to perform distributed processing on the received state machines to be executed. Optionally, each state machine client can upload the corresponding state machines to be executed at the same time, or upload the state machines to be executed at different times. That is, the behaviors of each state machine client uploading the state machines to be executed are independent of each other and do not affect each other.
[0034] In an optional embodiment of the present invention, the state machine to be executed may include an abstract state class and a current state class; wherein the abstract state class is used to define a target state behavior associated with the current state, and the current state class is used to define the current state. The abstract state class may include at least one sub-state class, and the sub-state class is used to define a target sub-state behavior associated with the target state behavior. Each of the sub-state classes is independent of or interdependent on each other.
[0035] The target state behavior may be a behavior related to the characteristic state, and the target sub-state behavior may be a sub-state behavior under the target state behavior.
[0036] Figure 2 is a state mode diagram of a state machine provided by the first embodiment of the present invention. In a specific example, Figure 2As shown, State is the abstract state class, and Context is the current state class. Among them, Context can record the current state through the instance of the maintained Concretestate subclass, and the Handle method of each state implements the business logic and state transition that need to be executed, such as external system calls or simple business logic, and the return value of the Handle method is the next state. State can define an interface to encapsulate the behavior related to a characteristic state of Context, that is, define the target state behavior associated with the current state. Among them, State can include at least one sub-state class, such as ConcreteStateA, ConcreteStateB and ConcreteStateC. Each sub-state class can define a target sub-state behavior associated with the target state behavior, that is, it can implement a behavior related to a state of Context, and each sub-state class is independent of each other or interdependent. Exemplarily, when ConcreteStateA, ConcreteStateB and ConcreteStateC are independent of each other, each sub-state class can be executed independently without affecting each other. If there is a dependency relationship between ConcreteStateC and ConcreteStateA and ConcreteStateB, such as ConcreteStateC needs to be executed according to the execution results of ConcreteStateA and ConcreteStateB, then ConcreteStateC can be executed only after ConcreteStateA and ConcreteStateB are completed.
[0037] The state mode of the above-mentioned state machine to be executed belongs to the state mode based on the programming mode, which can quickly eliminate a large number of if / else and switch statements, and disperse the state migration process into different classes, so as to achieve rapid definition of the state. At the same time, the network can be shielded from developers to achieve parallel development, thereby improving the efficiency of system development.
[0038] S120: Distribute each of the state machines to be executed to multiple state machine execution devices, so that each of the state machine execution devices executes each of the state machines to be executed in a distributed manner.
[0039] The state machine execution device is a device used to execute the state machine.
[0040] Correspondingly, after receiving each state machine to be executed, the state machine management center can send each state machine to be executed to multiple state machine execution devices. After receiving the corresponding state machine to be executed, each state machine execution device can execute the received state machine to be executed. After each state machine execution device completes the execution of the state machine to be executed, it can feed back the execution data of the state machine to the state machine management center. That is, each state machine execution device can execute multiple state machines to be executed at the same time, thereby realizing the distributed implementation of the state machine.
[0041] Optionally, the state machine management center can distribute the state machines to be executed to the state machine execution devices according to the current state of each state machine execution device. For example, after the state machine management center receives two state machines to be executed, if it is determined that state machine execution device 1 and state machine execution device 2 are in an idle state and other state machine execution devices are in an execution state, the two state machines to be executed can be distributed to state machine execution device 1 and state machine execution device 2 for execution respectively.
[0042] Since each state machine to be executed is executed by a different state machine execution device, developers do not need to consider the interaction with other state machines when developing a state machine, and can only develop the corresponding state machine for their own business needs. In other words, developers do not need to consider the complex interaction implementation issues between systems. It can be seen that this state machine execution method can significantly reduce the difficulty and complexity of developers in developing technology for complex system interaction scenarios.
[0043] In an optional embodiment of the present invention, after receiving the state machines to be executed uploaded by each state machine client, the method may further include: converting the state machines to be executed into a directed graph structure for storage.
[0044] In an optional embodiment of the present invention, the distributing the state machines to be executed to multiple state machine execution devices may include: if each of the state machines to be executed is independent of each other, directly distributing the state machines to be executed to multiple state machine execution devices. If each of the state machines to be executed is interdependent, the dependent state machines to be executed are distributed to the state machine execution device, and after the dependent state machines to be executed are executed, the dependent state machines to be executed are distributed to the state machine execution device. Optionally, before distributing the dependent state machines to be executed to the state machine execution device, it may also include: acquiring the execution data of each of the dependent state machines to be executed; the distributing the dependent state machines to be executed to the state machine execution device may include: distributing the execution data of the dependent state machines to be executed and the dependent state machines to be executed to the state machine execution device.
[0045] The dependent to-be-executed state machine is a to-be-executed state machine that needs to rely on the execution results of other state machines, and the dependent to-be-executed state machine is a to-be-executed state machine that the dependent to-be-executed state machine depends on.
[0046] Specifically, after receiving the state machine to be executed, the state management center can convert the state machine to be executed into a directed graph structure for preservation. At the same time, the state management center can also record the state and historical state of the current state machine. Correspondingly, the state management center needs to distribute each state machine to be executed according to the dependency relationship between each state machine to be executed. Specifically, if each state machine to be executed is independent of each other and does not affect each other, the state machine management center can directly distribute the state machine to be executed to multiple state machine execution devices for execution. If each state machine to be executed is interdependent, that is, one or part of the state machine to be executed needs to rely on the execution results of other state machines to be executed for specific execution, then the state machine to be executed needs to be distributed to the state machine execution device first, and after determining that the state machine to be executed is completed, the dependent state machine to be executed is distributed to the state machine execution device for continued execution. After the state machine to be executed is completed, the corresponding execution data can be fed back to the state machine management center, and the state machine management center is notified that the state machine to be executed has been completed, so that the state machine management center can update the completion status of the state machine to be executed.
[0047] It should be noted that in the prior art, when executing a finite state machine, usually only one state machine execution device is responsible for execution. That is, no matter how many state machines there are, they are all executed by a unique state machine execution device. If the state machine execution device is currently in an execution state, that is, it is executing one of the state machines, then only after the state machine execution device completes the execution of the currently processed state machine can it continue to execute the next state machine. The above-mentioned state machine execution method can execute mutually independent state machines to be executed in parallel, thereby improving the execution efficiency of the state machine.
[0048] The embodiment of the present invention distributes the state machines to be executed uploaded by each state machine client to multiple state machine execution devices, so that each state machine execution device executes each state machine to be executed in a distributed manner, thereby solving the problems of high technical development difficulty and complexity in existing complex system interaction scenarios, thereby reducing the difficulty and complexity of system technology development.
[0049] Embodiment 2
[0050] Figure 3 is a schematic diagram of a state machine execution system provided by Embodiment 2 of the present invention, such as Figure 3As shown, the structure of the state machine execution system includes a state machine client 210, a state machine management center 220, a message bus 230 and multiple state machine execution devices 240; wherein: the state machine client 210 is communicated with the state machine management center 220, and is used to upload the state machine to be executed to the state machine management center 220; the state machine management center 220 is communicated with each state machine execution device 240 through the message bus 230, and is used to distribute the state machine to be executed to each state machine execution device 240; the state machine execution device 240 is used to execute the received state machine to be executed.
[0051] Specifically, each state machine client 210 ( Figure 3 Only one state machine client is shown in the figure) uploads the state machine to be executed to the state machine management center 220. After receiving the state machine to be executed, the state machine management center 220 can distribute each state machine to be executed to the state machine execution device 240 according to the relationship between each state machine to be executed. Exemplarily, assuming that the state machine to be executed 1 and the state machine to be executed 2 are independent of each other, the state machine management center 220 can distribute the state machine to be executed 1 and the state machine to be executed 2 to two idle state state machine execution devices 240 through the message bus 230. If the state machine to be executed 1 depends on the state machine to be executed 2, the state machine management center 220 first distributes the state machine to be executed 2 to one of the idle state state machine execution devices 240 through the message bus 230 for execution. When the state machine to be executed 2 is executed, the state machine execution device 240 that executes the state machine to be executed 2 feeds back the execution data of the state machine to be executed 2 to the state machine management center 220 through the message bus 230, and notifies the state machine management center 220 that the state machine to be executed 2 has been executed. At this time, the state machine management center 220 can update the local state of the to-be-executed state machine 220 to be completed. Then, the state machine management center 220 distributes the execution data corresponding to the to-be-executed state machine 1 and the to-be-executed state machine 2 required by the to-be-executed state machine 1 to one of the idle state state machine execution devices 240 for execution through the message bus 230. Optionally, the state machine management center can achieve high availability based on the Raft protocol.
[0052] In an optional embodiment of the present invention, the message fields of the message model corresponding to the message bus 230 include message type, parallelism, custom parameters, timeout period, and transaction message flag.
[0053] Optionally, the communication messages of the message bus 230 can be serialized and deserialized using protobuf. protobuf is an efficient protocol data exchange format tool library provided by Google, which has a high conversion efficiency. Accordingly, developers can implement communication messages through IDL (Interactive Data Language) files.
[0054] Exemplarily, the following necessary fields can be defined through the IDL file: type, i.e., message type, including execution success message and execution failure message; paralism, i.e., parallelism, which can be set to a default value of 1; Param, i.e., custom parameter; timeout, i.e., timeout period; isTrac, i.e., transaction message flag.
[0055] In an optional embodiment of the present invention, the state machine execution system determines the state machine management center 220 and each state machine execution device 240 through a role definition file. Optionally, the role definition file is a YML (Yaml AintMarkup Language) format file; the role definition file is specifically used to determine the state machine management center 220 and each state machine execution device 240 according to the IP address of each device.
[0056] Specifically, in order to identify each role in the state machine execution system, a YML format file can be used to define different roles in the system architecture according to the IP address of each device, that is, to determine the state machine management center 220 and each state machine execution device 240 from each device. If the system deployment environment uses a service discovery component, the application names of different roles can be defined.
[0057] The embodiment of the present invention utilizes the state machine management center in the state machine execution system to receive the state machines to be executed uploaded by each state machine client, and distributes the received state machines to be executed to multiple state machine execution devices, so that each state machine execution device executes each state machine to be executed in a distributed manner, thereby solving the problems of high technical development difficulty and complexity in existing complex system interaction scenarios, thereby reducing the difficulty and complexity of system technology development.
[0058] It should be noted that any arrangement and combination of the technical features in the above embodiments also falls within the protection scope of the present invention.
[0059] Embodiment 3
[0060] Figure 4 is a schematic diagram of a state machine execution device provided by Embodiment 3 of the present invention, such as Figure 4As shown, the device includes: a to-be-executed state machine receiving module 310 and a to-be-executed state machine distributing module 320, wherein:
[0061] The to-be-executed state machine receiving module 310 is used to receive the to-be-executed state machines uploaded by each state machine client;
[0062] The to-be-executed state machine distribution module 320 is used to distribute each of the to-be-executed state machines to a plurality of state machine execution devices, so that each of the state machine execution devices executes each of the to-be-executed state machines in a distributed manner.
[0063] The embodiment of the present invention distributes the state machines to be executed uploaded by each state machine client to multiple state machine execution devices, so that each state machine execution device executes each state machine to be executed in a distributed manner, thereby solving the problems of high technical development difficulty and complexity in existing complex system interaction scenarios, thereby reducing the difficulty and complexity of system technology development.
[0064] Optionally, the state machine to be executed includes an abstract state class and a current state class; wherein the abstract state class is used to define a target state behavior associated with the current state, and the current state class is used to define the current state.
[0065] Optionally, the abstract state class includes at least one sub-state class, and the sub-state class is used to define a target sub-state behavior associated with the target state behavior.
[0066] Optionally, the sub-state classes are independent of or dependent on each other.
[0067] Optionally, the state machine execution device further includes: a directed graph conversion module, used to convert the state machine to be executed into a directed graph structure for storage.
[0068] Optionally, the to-be-executed state machine distribution module 320 is specifically configured to: directly distribute the to-be-executed state machines to multiple state machine execution devices if the to-be-executed state machines are independent of each other.
[0069] Optionally, the to-be-executed state machine distribution module 320 is specifically used to: if the to-be-executed state machines are interdependent, distribute the dependent to-be-executed state machines to the state machine execution device, and after the dependent to-be-executed state machines are executed, distribute the dependent to-be-executed state machines to the state machine execution device.
[0070] Optionally, the state machine execution device further includes: an execution data acquisition module, used to acquire execution data of each of the dependent state machines to be executed;
[0071] The above-mentioned state machine execution device can execute the state machine execution method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. For technical details not described in detail in this embodiment, please refer to the state machine execution method provided by any embodiment of the present invention.
[0072] Since the state machine execution device introduced above is a device that can execute the state machine execution method in the embodiment of the present invention, based on the state machine execution method introduced in the embodiment of the present invention, the technical personnel in this field can understand the specific implementation of the state machine execution device of this embodiment and its various variations, so how the state machine execution device implements the state machine execution method in the embodiment of the present invention is not described in detail here. As long as the technical personnel in this field implement the device used by the state machine execution method in the embodiment of the present invention, it belongs to the scope of protection of this application.
[0073] Embodiment 4
[0074] Figure 5 A schematic diagram of the structure of a computer device provided in Embodiment 4 of the present invention. Figure 5 A block diagram of a computer device 412 suitable for use in implementing embodiments of the present invention is shown. Figure 5 The computer device 412 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0075] like Figure 5 As shown, the computer device 412 is in the form of a general-purpose computing device. The components of the computer device 412 may include, but are not limited to: one or more processors 416, a storage device 428, and a bus 418 connecting various system components (including the storage device 428 and the processor 416).
[0076] Bus 418 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
[0077] The computer device 412 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the computer device 412, including volatile and non-volatile media, removable and non-removable media.
[0078] The storage device 428 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 430 and / or cache memory 432. The computer device 412 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 434 may be used to read and write non-removable, non-volatile magnetic media ( Figure 5 not shown, usually called a "hard drive"). Although Figure 5 Not shown in the figure, a disk drive for reading and writing a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing a removable non-volatile optical disk (e.g., a read-only optical disk (Compact Disc-Read Only Memory, CD-ROM), a digital video disk (Digital Video Disc-Read Only Memory, DVD-ROM) or other optical media) may be provided. In these cases, each drive may be connected to the bus 418 via one or more data medium interfaces. The storage device 428 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.
[0079] A program 436 having a set (at least one) of program modules 426 may be stored, for example, in a storage device 428, such program modules 426 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination thereof may include an implementation of a network environment. Program modules 426 generally perform the functions and / or methods of the embodiments described herein.
[0080] The computer device 412 may also communicate with one or more external devices 414 (e.g., keyboard, pointing device, camera, display 424, etc.), may also communicate with one or more devices that enable a user to interact with the computer device 412, and / or communicate with any device that enables the computer device 412 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed through an input / output (I / O) interface 422. In addition, the computer device 412 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN) and / or a public network, such as the Internet) through a network adapter 420. As shown, the network adapter 420 communicates with other modules of the computer device 412 through a bus 418. It should be understood that although not shown in the figure, other hardware and / or software modules can be used in conjunction with the computer device 412, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, disk arrays (Redundant Arrays of Independent Disks, RAID) systems, tape drives, and data backup storage systems.
[0081] The processor 416 executes various functional applications and data processing by running the programs stored in the storage device 428, such as implementing the state machine execution method provided in the above embodiment of the present invention.
[0082] That is, when the processing unit executes the program, it implements: receiving the state machines to be executed uploaded by each state machine client; distributing each state machine to be executed to multiple state machine execution devices, so that each state machine execution device executes each state machine to be executed in a distributed manner.
[0083] Embodiment 5
[0084] Embodiment 5 of the present invention further provides a computer storage medium storing a computer program, wherein the computer program, when executed by a computer processor, is used to execute the state machine execution method described in any one of the above embodiments of the present invention: receiving the state machines to be executed uploaded by each state machine client; distributing each of the state machines to be executed to multiple state machine execution devices, so that each of the state machine execution devices executes each of the state machines to be executed in a distributed manner.
[0085] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, a device or a device or used in combination with it.
[0086] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0087] The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wire, optical cable, radio frequency (RF), etc., or any suitable combination of the foregoing.
[0088] Computer program code for performing the operations of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0089] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A state machine execution method, characterized in that: include: Receive the state machines to be executed uploaded by each state machine client; Distributing each of the state machines to be executed to a plurality of state machine execution devices, so that each of the state machine execution devices executes each of the state machines to be executed in a distributed manner; The state machine to be executed includes an abstract state class and a current state class; the abstract state class is used to define a target state behavior associated with the current state, and the current state class is used to define the current state; the abstract state class includes at least one sub-state class, and the sub-state class is used to define a target sub-state behavior associated with the target state behavior, and the target state behavior is a behavior related to the characteristic state; The step of distributing each of the state machines to be executed to a plurality of state machine execution devices includes: If the state machines to be executed are independent of each other, directly distributing the state machines to be executed to multiple state machine execution devices; If the to-be-executed state machines are mutually dependent, the dependent to-be-executed state machines are distributed to the state machine execution device, and after the dependent to-be-executed state machines are executed, the dependent to-be-executed state machines are distributed to the state machine execution device.
2. The method according to claim 1, characterized in that The sub-state classes are independent of or dependent on each other.
3. The method according to claim 1, characterized in that After receiving the state machines to be executed uploaded by the state machine clients, the method further includes: The state machine to be executed is converted into a directed graph structure for storage.
4. The method according to claim 1, characterized in that: Before distributing the dependent state machine to be executed to the state machine execution device, the method includes: Obtaining execution data of each of the dependent to-be-executed state machines; The step of distributing the dependent state machine to be executed to the state machine execution device includes: The execution data of the dependent state machine to be executed and the dependent state machine to be executed are distributed to the state machine execution device.
5. A state machine execution system, characterized in that: It includes a state machine client, a state machine management center, a message bus, and multiple state machine execution devices; among which: The state machine client is in communication connection with the state machine management center, and is used to upload the state machine to be executed to the state machine management center; The state machine management center is connected to each of the state machine execution devices through the message bus, and is used to distribute the state machine to be executed to each of the state machine execution devices; The state machine execution device is used to execute the received state machine to be executed; The state machine to be executed includes an abstract state class and a current state class; the abstract state class is used to define a target state behavior associated with the current state, and the current state class is used to define the current state; the abstract state class includes at least one sub-state class, and the sub-state class is used to define a target sub-state behavior associated with the target state behavior, and the target state behavior is a behavior related to the characteristic state; The distributing the state machine to be executed to each of the state machine execution devices includes: If the state machines to be executed are independent of each other, directly distributing the state machines to be executed to multiple state machine execution devices; If the to-be-executed state machines are mutually dependent, the dependent to-be-executed state machines are distributed to the state machine execution device, and after the dependent to-be-executed state machines are executed, the dependent to-be-executed state machines are distributed to the state machine execution device.
6. The system according to claim 5, characterized in that The message fields of the message model corresponding to the message bus include message type, parallelism, custom parameters, timeout period and transaction message flag.
7. The system according to claim 5, characterized in that The state machine execution system determines the state machine management center and each of the state machine execution devices through a role definition file.
8. The system according to claim 7, characterized in that The role definition file is a YML format file; The role definition file is specifically used to determine the state machine management center and each state machine execution device according to the IP address of each device.
9. A state machine execution device, characterized in that: include: The waiting-for-execution state machine receiving module is used to receive the waiting-for-execution state machines uploaded by each state machine client; A to-be-executed state machine distribution module, used to distribute each of the to-be-executed state machines to a plurality of state machine execution devices, so that each of the state machine execution devices executes each of the to-be-executed state machines in a distributed manner; The state machine to be executed includes an abstract state class and a current state class; the abstract state class is used to define a target state behavior associated with the current state, and the current state class is used to define the current state; the abstract state class includes at least one sub-state class, and the sub-state class is used to define a target sub-state behavior associated with the target state behavior, and the target state behavior is a behavior related to the characteristic state; Wherein, the to-be-executed state machine distribution module is specifically used for: If the state machines to be executed are independent of each other, directly distributing the state machines to be executed to multiple state machine execution devices; If the to-be-executed state machines are mutually dependent, the dependent to-be-executed state machines are distributed to the state machine execution device, and after the dependent to-be-executed state machines are executed, the dependent to-be-executed state machines are distributed to the state machine execution device.
10. A computer device, characterized in that: The computer device comprises: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the state machine execution method as described in any one of claims 1 to 4.
11. A computer storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the state machine execution method as described in any one of claims 1 to 4 is implemented.
