WO2024109003A1 - Task processing method and apparatus, and node - Google Patents
Task processing method and apparatus, and node Download PDFInfo
- Publication number
- WO2024109003A1 WO2024109003A1 PCT/CN2023/101285 CN2023101285W WO2024109003A1 WO 2024109003 A1 WO2024109003 A1 WO 2024109003A1 CN 2023101285 W CN2023101285 W CN 2023101285W WO 2024109003 A1 WO2024109003 A1 WO 2024109003A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- task
- node
- database
- target
- target task
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/485—Task life-cycle, e.g. stopping, restarting, resuming execution
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
Definitions
- the present application relates to the field of information technology (IT) technology, and in particular to a task processing method, device and node.
- IT information technology
- clusters can be divided into active-standby clusters and active-active clusters.
- active-standby cluster only the primary node works, and the standby node does not work.
- active-active cluster each node works, and a load balancer needs to be deployed at the front end to achieve load sharing of the cluster.
- active-active clusters have higher performance and are more commonly used.
- the present application provides a task processing method, device, node, computer storage medium and computer product, which can reprocess the task requested by the user when the task processing fails, thereby ensuring that the result returned by the node is consistent with the actual result, thereby improving the user experience.
- the present application provides a task processing method that can be applied to a first node.
- the method may include: obtaining an application programming interface API request issued by a user; creating a target task according to the API request, and storing the task information of the target task in a database; executing the target task and obtaining the execution status of the target task; when the execution status of the target task is failed, re-executing the target task according to the task information of the target task stored in the database.
- the node after receiving an API request, the node creates a task for the request and persists it in the database.
- the task processing corresponding to the request fails, the task corresponding to the request can be retrieved from the database and re-executed. Therefore, by adding retry self-healing data (i.e., the task created for the API request) in the database, the node can retry self-healing when the task execution fails, ensuring the correctness of the result returned by the node.
- the method further includes: storing the execution status of the target task in a database, thereby refreshing the status of the task in the database.
- obtaining the execution status of the target task may include: obtaining the execution status of the target task from the database.
- the method may further include: obtaining heartbeat information of the second node from a database, the heartbeat information being used to indicate whether the second node fails; when the second node fails, obtaining task information of at least one task created by the second node and not executed or failed to execute from the database; executing at least one task according to the task information of the at least one task, and storing the execution status of each task in the at least one task in the database. In this way, the situation of task processing failure caused by node failure is avoided, and the reliability of task processing is ensured.
- the method may further include: when the number of times the target task is executed reaches a preset number and the last execution status is failure, outputting an alarm message, so that the user can be informed of the resource processing failure and perform manual repair.
- the API request is used to request the creation of a target resource and the execution of a target task, including: creating a target resource.
- the method further includes: returning the execution status of the target task to the user, so that the user can know the execution status of the task.
- the present application provides a task processing device.
- the device can be deployed on a first node.
- the device includes: a request acquisition module, used to acquire an application programming interface API request issued by a user; a task creation module, used to create a target task according to the API request and store the task information of the target task in a database; a task processing module, used to execute the target task and acquire the execution status of the target task; and, when the execution status of the target task is failed, re-execute the target task according to the task information of the target task stored in the database.
- the task processing module after executing the target task, is further used to: store the execution status of the target task in a database; wherein, when obtaining the execution status of the target task, the task processing module is specifically used to: obtain the execution status of the target task from the database; state.
- the task processing module is further used to: obtain heartbeat information of the second node from a database, where the heartbeat information is used to indicate whether the second node fails; when the second node fails, obtain task information of at least one task created by the second node and not executed or failed to execute from the database;
- At least one task is executed according to the task information of at least one task, and the execution status of each task in the at least one task is stored in a database.
- the task processing module is further used to: output an alarm message when the number of times the target task is executed reaches a preset number and the last execution status is failure.
- the API request is used to request the creation of a target resource
- the task processing module when executing the target task, is specifically used to: create the target resource
- the task processing module is further configured to return the execution status of the target task to the user.
- the present application provides a node, comprising: at least one memory for storing programs; and at least one processor for executing the programs stored in the memory; wherein, when the program stored in the memory is executed, the processor is used to execute the method described in the first aspect or any possible implementation of the first aspect.
- the present application provides a computing device, comprising: at least one memory for storing a program; at least one processor for executing the program stored in the memory; wherein, when the program stored in the memory is executed, the processor is used to execute the method described in the first aspect or any possible implementation of the first aspect.
- the computing device may be a node in a device cluster, such as node 1 shown in FIG. 2 .
- the present application provides a computing device cluster, comprising at least one computing device, each computing device comprising a processor and a memory; the processor of at least one computing device is used to execute instructions stored in the memory of at least one computing device, so that the computing device cluster executes the method described in the first aspect or any possible implementation of the first aspect.
- the present application provides a computer-readable storage medium, which stores a computer program.
- the computer program runs on a processor, the processor executes the method described in the first aspect or any possible implementation of the first aspect.
- the present application provides a computer program product.
- the processor executes the method described in the first aspect or any possible implementation of the first aspect.
- FIG1 is a schematic diagram of a working process of a node in a master-master cluster provided in an embodiment of the present application
- FIG2 is a schematic diagram of the system architecture of a task processing system of a master-master cluster provided in an embodiment of the present application
- FIG3 is a schematic diagram of resources included in an API request provided in an embodiment of the present application.
- FIG4 is a schematic diagram of task processing when a node fails according to an embodiment of the present application.
- FIG. 5 is a schematic diagram of a change in resource state when a node processes resources provided by an embodiment of the present application
- FIG6 is a flowchart of a task processing method provided in an embodiment of the present application.
- FIG7 is a schematic diagram of the structure of a task processing device provided in an embodiment of the present application.
- FIG8 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application.
- FIG. 9 is a schematic diagram of the structure of a computing device cluster provided in an embodiment of the present application.
- a and/or B in this article is a description of the association relationship of associated objects, indicating that there can be three relationships.
- a and/or B can represent: A exists alone, A and B exist at the same time, and B exists alone.
- the symbol "/" in this article indicates that the associated objects are in an or relationship, for example, A/B means A or B.
- first and second in the specification and claims herein are used to distinguish different objects rather than to describe a specific order of the objects.
- a first response message and a second response message are used to distinguish different response messages rather than to describe a specific order of the response messages.
- multiple means two or more than two.
- multiple processing units refer to two or more processing units, etc.; multiple elements refer to two or more elements, etc.
- FIG1 shows a schematic diagram of the working process of a node in a master-master cluster.
- an asynchronous processing method is often used inside node 1.
- a part of threads in the thread pool of node 1 can obtain one or more application programming interface (API) requests, and store the resources of each API request in the database layer (DB layer).
- API application programming interface
- node 1 can read the storage result from the database through the thread that processes the API request.
- the thread returns the request result representing the successful processing to the user.
- Another part of the threads in the thread pool can be used for internal processing resources, such as calling APIs of other services.
- the resource handler in node 1 can call the services provided by other nodes through a thread.
- node 1 can send the results returned by other nodes to the user.
- the services provided by other nodes can also be called "downstream services", that is, services located downstream of the services provided by node 1, or services that node 1 needs to call.
- node 1 provides service 1
- node 2 provides service 2. If service 1 needs to call service 2 during operation, service 2 can be called the downstream service of service 1.
- node 1 when the resource processor in node 1 fails, or the node corresponding to the downstream service fails, etc., node 1 will find it difficult to obtain the results returned by other nodes, causing the result returned to the user by node 1 when storing the corresponding resource in its database to be inconsistent with the result it actually needs to return to the user (i.e., the result returned by other nodes).
- an embodiment of the present application provides a task processing method, which can create a task for each resource in the API request when storing the resources in the API request in the database, and store the created tasks in the database. Then, each task can be executed. When a task fails to execute, the task can be retrieved from the database and reprocessed, thereby ensuring that the resources of the API request can be processed, and then ensuring the correctness of the results returned by the node to the user. Therefore, by adding retry self-healing data to the database (i.e., tasks created for each resource in the API request), the node can retry self-healing when the task fails to execute, thereby ensuring the correctness of the results returned by the node.
- Fig. 2 shows an architecture of a task processing system of a master-master cluster.
- the task processing system 200 of the master-master cluster may include: a master-master cluster 210 and a database 220.
- the master-master cluster 210 includes n nodes, where n ⁇ 2.
- each node in the master-master cluster 210 includes: a request acquisition module 211 , a task creation module 212 , a task scheduling module 213 and a task processing module 214 .
- the request acquisition module 211 in each node is mainly used to obtain the API request issued by the user.
- the user can issue an API request through the user interface provided by the node.
- the API request may include one or more resources to be processed, such as products purchased or updated by the user or tenant.
- the resources contained in the API request can be stored in the database 220 to complete the persistence of the resources.
- the request acquisition module 211 can also transmit the API request it obtains to the task creation module 212.
- the task creation module 212 is mainly used to create tasks for the resources contained in the API request through a preconfigured function after obtaining the API request sent by the request acquisition module 211, and store the created tasks in the database 220 to complete the persistence of the created tasks.
- each task can be associated with a user or tenant, and/or associated with a resource.
- different tasks can be associated with the same user or tenant.
- different tasks can be associated with different resources.
- the execution order of the tasks corresponding to each resource can be determined based on the dependency relationship or superior-subordinate relationship between each resource.
- the resources included in the API request are: virtual machines, network cards and volumes purchased by tenants, since network cards and volumes need to be created before executing the creation of virtual machines, and there is no dependency relationship between the creation of network cards and volumes, therefore, tasks can be created for the three resources of creating virtual machines, creating network cards and creating volumes, and the tasks corresponding to the creation of network cards and the creation of volumes can be set in parallel, and the tasks corresponding to the creation of virtual machines need to be executed after the tasks corresponding to the creation of network cards and the creation of volumes are completed.
- the task scheduling module 213 is mainly used to obtain tasks that need to be executed by the node to which it belongs (such as unprocessed tasks or failed tasks, etc.) from the database 220, and to allocate task queues according to the creation time of the tasks, the dependency between tasks, or the identification of the tasks (such as the identification of the tenant associated with the task, or the identification of the resource associated with the task, etc.).
- the processing order of each task in the task queue is related to the creation time of each task, wherein the earlier the creation time of the task is, the earlier the execution order of the task is, that is, the earlier it is executed.
- tasks with the same identification can be allocated to the same task queue.
- the task scheduling module 213 can allocate tasks to be processed according to the identification of the task.
- a task can be assigned to one task queue or multiple task queues, depending on the actual situation and is not limited here.
- the task processing module 214 is mainly used to execute the tasks in each task queue assigned by the task scheduling module 213.
- the task processing module 214 can assign different threads to different task queues, that is, execute the tasks in different task queues through different threads.
- the task processing module 214 can call the API of the service provided by other nodes, and wait for the execution result of the service called by it, and store the corresponding execution status in the database 220.
- the execution status stored in the database 220 by the task processing module 214 can be understood as the execution status of each task, so that the task scheduling module 213 can know which tasks in the database 220 are pending tasks and which are successfully processed tasks.
- the pending tasks may include unprocessed tasks and/or tasks that have failed to be processed. For example, when a task is successfully processed, the execution status of the service required to be called by the task obtained by the task processing module 214 is successful; when a task is failed to be processed, the execution status of the service required to be called by the task obtained by the task processing module 214 is failed.
- the task processing module 214 can also feedback the execution status corresponding to each resource to the user.
- each node in the master cluster 210 may have a thread that periodically scans failed tasks from the database 220 so that the task scheduling module 213 in the corresponding node adds the failed tasks to the task queue for retry self-healing.
- the database 220 is mainly used to store resources, tasks, and execution status of each task stored in each node in the master cluster 210 .
- the database 220 may also store the operation status of each node in the main main cluster 210, so that when a node fails, the tasks required to be executed are transferred to other nodes, thereby avoiding the situation where resource processing fails due to node failure and ensuring the reliability of resource processing.
- the main main cluster includes node 1, node 2 and node 3, and tasks 1 to 9 are stored in the database 220.
- the tasks required to be executed by node 1 are tasks 1 to 3
- the tasks required to be executed by node 2 are tasks 4 to 6
- the tasks required to be executed by node 3 are tasks 7 to 9.
- node 1 when node 2 fails, node 1 can take over the tasks required to be executed by node 2, and the tasks required to be executed by node 1 are tasks 1 to 6. As a result, when node 2 fails, the tasks required to be executed by node 2 can also be transferred to other nodes for execution, ensuring the reliability of resource processing.
- each node in the main cluster 210 can register its identity in the database 220 when it is started, and write heartbeats to the database 220 during the subsequent operation process, so as to determine whether the node is faulty through the heartbeat of the node, and determine the faulty node through the registered identity of the node.
- each node can have a thread for regularly writing heartbeats to the database 220, so as to refresh the state of the node to the database 220.
- each node can also have a thread that regularly queries the health status of other nodes from the database 220 to regularly query whether other nodes are faulty.
- a master node may be set in the master cluster 210, and the master node periodically scans the status of other nodes from the database 220, and when a node fails, takes over the tasks that have not been successfully processed by the failed node.
- each node in the master cluster 210 may periodically try to lock a row in the database 220, and at this time, the node that preferentially locks the row may be used as the master node.
- the node may give up (i.e., release) locking the row in the database 220 and not participate in the selection of the master node for a period of time.
- each node in the master cluster 210 can take over the tasks that were not successfully executed by the failed node. At this time, each node can periodically query the health status of other nodes from the database 220. If node 1 detects that node 2 is faulty, node 1 can take over some of the tasks that were not successfully executed on node 2 based on its own execution capability. The tasks that node 1 did not take over can be taken over by other nodes that detect that node 2 is faulty.
- the node can give priority to the tasks that belong to it but have not been successfully executed, so as to prevent its own tasks from being handled in time after being taken over by other nodes.
- the node that has returned to normal can first judge whether the task that it currently needs to execute is executed by the execution status of each task stored in the database 220, if it has been executed and the result of execution is success, then it skips the task and processes the next task.
- the node that takes over the task of the node that has failed can also first judge whether the task that it currently needs to execute is executed by the execution status of each task stored in the database 220, if it has been executed, then it skips the task and processes the next task.
- the node that takes over the task of the node that has failed can also judge whether the execution status is successful, if the execution fails, then it can continue to execute the task, otherwise it processes the next task.
- the state constraints of resources can be used to ensure the order of internal resource processing to prevent disorder.
- closed loop implementation can be used to make the state constraints of resources more complex, thereby ensuring the order of internal resource processing.
- the state of a resource can include whether the creation of the resource is successful. Success, whether the resource is deleted successfully, whether the resource is updated successfully, etc. Exemplarily, if the status after processing any resource is failed, the any resource can be reprocessed until the status after processing the any resource is successful, thereby constraining the status of the resources and ensuring the processing order of the resources.
- an alarm message can be output, thereby letting the user know the situation of resource processing failure and perform manual repair.
- a node in the master-master cluster when a node in the master-master cluster is creating a resource, it can write the state of the resource being created into the aforementioned database 220. At this time, the state of the resource in the database 220 can be refreshed to being created, i.e., “creating” as shown in FIG5 .
- the node When the node successfully creates a resource, it can write the state of successful creation into the aforementioned database 220. At this time, the state of the resource in the database 220 can be refreshed to an available state, i.e., “available” as shown in FIG5 .
- the node When the node fails to create a resource, it knows that the resource creation has failed, and it can retry to create the resource at intervals of a preset duration (such as 10s, 20s, etc.). Among them, when the node recreates the resource, it can also write the state of retrying to create into the aforementioned database 220. At this time, the state of the resource in the database 220 can be “retrying” as shown in FIG5 . After the node is recreated and created successfully, that is, "close-loop success" shown in Figure 5, it can write the successful creation status into the aforementioned database 220. At this time, the status of the resource in the database 220 can be refreshed to an available status, that is, "available” shown in Figure 5.
- a preset duration such as 10s, 20s, etc.
- the node can write the creation failure status into the aforementioned database 220.
- the database 220 can refresh the resource status to an unavailable state, that is, "failed” as shown in FIG5.
- the node can return the creation failure information to the user so that the user can repair it.
- the node can recreate the resource, that is, "re-enter the initial state after the task is successfully repaired” as shown in FIG5, and can write the resource creation status into the aforementioned database 220.
- the resource status in the database 220 can be refreshed to being created, that is, "creating” as shown in FIG5. .
- the node can write the state of deleting resources into the aforementioned database 220.
- the state of the resource in the database 220 can be refreshed to being deleted, that is, "deleting" shown in Figure 5.
- the node successfully deletes the resource it can write the state of successful deletion into the aforementioned database 220.
- the state of the resource in the database 220 can be refreshed to deleted, that is, "deleted” shown in Figure 5.
- the node fails to delete the resource it knows that the resource deletion has failed, and it can retry to delete the resource at intervals of a preset time (such as 10s, 20s, etc.).
- the node when the node deletes the resource again, it can also write the state of retrying deletion into the aforementioned database 220.
- the state of the resource in the database 220 can be "retrying" as shown in Figure 5, and the state of deleting resources can be written into the aforementioned database 220.
- the state of the resource in the database 220 can be refreshed to being deleted, that is, "deleting" shown in Figure 5.
- the status of successful deletion can be written into the aforementioned database 220.
- the status of the resource in the database 220 can be refreshed to deleted, that is, "deleted” shown in Figure 5.
- the node If the node still fails to delete successfully after re-deleting m times (m ⁇ 1), that is, "close-loop retry failed” as shown in Figure 5, it can write the deletion failure status into the aforementioned database 220. At this time, the status of the resource in the database 220 can be refreshed to an unavailable state, that is, "failed” as shown in Figure 5. After the node fails to delete the resource, it can return the deletion failure information to the user so that the user can repair it. When the user completes the repair, the node can delete the resource again, that is, "re-enter the initial state after the task is successfully repaired” as shown in Figure 5, and can write the status of deleting the resource into the aforementioned database 220. At this time, the status of the resource in the database 220 can be refreshed to being deleted, that is, "deleting" as shown in Figure 5.
- the node can write the status of the resource being updated into the aforementioned database 220.
- the status of the resource in the database 220 can be refreshed to being updated, that is, "modifying" shown in Figure 5.
- the node successfully updates the resource it can write the status of the successful update into the aforementioned database 220.
- the status of the resource in the database 220 can be refreshed to updated, that is, "available” shown in Figure 5.
- the node fails to update the resource it knows that the resource update has failed, and it can retry to update the resource at a preset time interval (such as 10s, 20s, etc.).
- the node when the node re-updates the resource, it can also write the status of the retrying update into the aforementioned database 220. At this time, the status of the resource in the database 220 can be "retrying" as shown in Figure 5. After the node is re-updated and the update is successful, that is, "close-loop success” shown in Figure 5, it can write the successful update status into the aforementioned database 220. At this time, the status of the resource in the database 220 can be refreshed to updated, that is, "available” shown in Figure 5.
- the node If the node still fails to update successfully after re-updating m times (m ⁇ 1), that is, "close-loop retry failed” as shown in Figure 5, it can write the update failure status to the aforementioned database 220. At this time, the database 220 can refresh the status of the resource to an unavailable state, that is, "failed” as shown in Figure 5. After the node fails to update the resource, it can return the update failure information to the user so that the user can repair it. When the user completes the repair, the node can re-update the resource, that is, "re-update after successful task repair” as shown in Figure 5. The resource state being updated can be written into the aforementioned database 220. At this time, the resource state in the database 220 can be refreshed to being updated, i.e., "modifying" as shown in FIG. 5 .
- the status of the two resources will be updated to the available state (i.e., available) only when the status of the two resources is both available (i.e., available).
- the status of any one of the two resources is unavailable (i.e., failed)
- the status of the two resources can be updated to the unavailable state (i.e., failed). In this way, the status constraint is performed.
- the operation to be performed in the retry is related to the operation that failed to be performed before the retry. For example, if the operation that failed to be performed before the retry was to create a resource, then the operation to be performed in the retry is to create a resource; if the operation that failed to be performed before the retry was to update a resource, then the operation to be performed in the retry is to update a resource.
- the state of a resource can be associated with the result of task processing corresponding to the resource.
- the state of a resource is unavailable, there is a high probability that the task corresponding to the resource cannot be processed successfully.
- the state of a resource is available, there is a high probability that the task corresponding to the resource can be processed successfully. Therefore, when the task corresponding to a resource is processed successfully, the state of the resource can be refreshed to an available state.
- the state of the resource can be refreshed to an unavailable state, and at the same time, an attempt can be made to re-execute the operations required before this operation, such as creating resources, updating resources, etc. In this way, it is ensured that when the task corresponding to the resource is re-executed, it can be executed successfully, thereby improving reliability.
- FIG6 shows a process of a task processing method.
- the method may be executed by any node in the aforementioned master-master cluster 210.
- the task processing method may include the following steps:
- S601 Obtain an application programming interface (API) request issued by a user.
- API application programming interface
- the user can issue the required request through the user interface provided by the node.
- the user can issue a request to purchase the product in the user interface provided by the node.
- the node obtains the request.
- the request issued by the user can be, but is not limited to, the API request described above.
- the API request can be used to create a resource, such as creating a virtual machine, etc., or it can be a request to purchase a product or service, such as purchasing clothes and other goods, etc., or it can be a request to pay money, such as initiating a payment transaction through a financial application (application, APP).
- application application
- S602 Create a target task according to the obtained API request, and store the task information of the target task in a database.
- the node after obtaining the request sent by the user, the node can create a task for the request through a preconfigured function, thereby obtaining a target task.
- the target task is associated with the API request.
- the target task is the task of creating the resource;
- the target task is the task of purchasing a product or service;
- the target task is the task of paying the money.
- the node can store the task information of the target task in the database to complete the persistence of the target task, so that when it is known that the target task processing fails, the task can be obtained from the database and re-executed, or, when a node fails, the task to be executed is transferred to other nodes through the database to ensure the reliability of task processing.
- the task information of the target task may include the task type and/or task content, etc.
- the task information of the target task may include the size of the hard disk in the virtual machine, the type of operating system, the type and parameters of the central processing unit, the network bandwidth, etc.; when the target task is a task to pay money, the task information of the target task may include the amount of money to be paid, etc.
- S603 Execute the target task and obtain the execution status of the target task.
- the node after persisting the target task in the database, the node can execute the target task and store the execution status of the target task in the database.
- the node can obtain the execution status of the target task from the database, such as whether the execution is successful or failed.
- the node after the node executes the target task, it can also know the execution status of the target task, and the node does not need to obtain the execution status of the target task from the database.
- the node when the API request is used to request the creation of a target resource, the node can create the target resource when executing the target task. For example, when the API request is used to request the creation of a virtual machine, the node can create the virtual machine when executing the target task.
- the node when the node learns that the execution status of the target task is failed, it can re-acquire the task information of the target task from the database and re-execute the target task. In some embodiments, when the number of times the target task is executed reaches a preset number of times and the last execution status is failed, an alarm message can be output. This allows the user to learn about the failure of resource processing and perform manual repairs.
- the node after receiving the API request, the node creates a task for the request and persists it in the database.
- the task information of the task can be retrieved from the database and re-executed until it succeeds. Therefore, by adding retry self-healing data (i.e., the task created for the API request) in the database, the node can retry self-healing when the task fails to execute, ensuring the correctness of the result returned by the node.
- the node may return the execution status of the target task obtained by executing it to the user, so that the user can be informed of the task execution status.
- each node when there are multiple nodes, each node can write its own heartbeat information into the database.
- the heartbeat information can be used to characterize whether a node fails.
- Each node can obtain the heartbeat information of other nodes from the database.
- node 1 obtains the heartbeat information of another node (hereinafter referred to as "node 2")
- node 1 can obtain the task information of M (M ⁇ 1) tasks created by node 2 and not executed or failed to execute from the database, and, according to the task information of these M tasks, execute these M tasks, and store the execution results of each task in the M tasks in the database.
- node 1 may first determine whether the execution status of any task to be executed stored in the database is failed or not executed.
- the embodiment of the present application also provides a task processing device.
- FIG7 shows a task processing device.
- the resource processing device can be but is not limited to being deployed in any node in the aforementioned master-master cluster.
- the task processing device 700 includes: a request acquisition module 701, a task creation module 702, and a task processing module 703.
- the request acquisition module 701 is used to obtain an application programming interface API request issued by a user.
- the task creation module 702 is used to create a target task according to the API request and store the task information of the target task in a database.
- the task processing module 703 is used to execute the target task and obtain the execution status of the target task; and when the execution status of the target task is failed, the target task is re-executed according to the task information of the target task stored in the database.
- the request acquisition module 701 can be but is not limited to the request acquisition module 211 in FIG2
- the task creation module 702 can be but is not limited to the task creation module 212 in FIG2
- the task processing module 703 can be but is not limited to the task processing module 214 in FIG2.
- the task processing module 703 is further used to: store the execution status of the target task in a database.
- the task processing module is specifically used to: acquire the execution status of the target task from the database.
- the task processing module 703 is also used to: obtain heartbeat information of the second node from the database, the heartbeat information is used to characterize whether the second node fails; when the second node fails, obtain task information of at least one task created by the second node and not executed or failed to execute from the database; execute at least one task according to the task information of at least one task, and store the execution status of each task in the at least one task in the database.
- the task processing module 703 is further used to: output an alarm message when the number of times the target task is executed reaches a preset number and the last execution status is failure.
- the task processing module 703 when the API request is used to request the creation of a target resource, the task processing module 703 is specifically used to create the target resource when executing the target task.
- the task processing module is further used to: return the execution status of the target task to the user.
- the request acquisition module 701, the task creation module 702 and the task processing module 703 can all be implemented by software, or can be implemented by hardware. Exemplarily, the implementation of the request acquisition module 701 is described below by taking the request acquisition module 701 as an example. Similarly, the implementation of the task creation module 702 and the task processing module 703 can refer to the implementation of the request acquisition module 701.
- the request acquisition module 701 may include code running on a computing instance.
- the computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Furthermore, the computing instance may be one or more.
- the request acquisition module 701 may include code running on multiple hosts/virtual machines/containers. It should be noted that Multiple hosts/virtual machines/containers for running the code can be distributed in the same region or in different regions. Furthermore, multiple hosts/virtual machines/containers for running the code can be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple geographically close data centers. Generally, one region can include multiple AZs.
- AZ availability zone
- VPC virtual private cloud
- multiple hosts/virtual machines/containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs.
- VPC virtual private cloud
- a VPC is set up in a region.
- a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.
- the request acquisition module 701 may include at least one computing device, such as a server, etc.
- the request acquisition module 701 may also be a device implemented by an application-specific integrated circuit (ASIC) or a programmable logic device (PLD).
- the PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.
- the multiple computing devices included in the request acquisition module 701 can be distributed in the same region or in different regions.
- the multiple computing devices included in the acquisition module 1001 can be distributed in the same AZ or in different AZs.
- the multiple computing devices included in the request acquisition module 701 can be distributed in the same VPC or in multiple VPCs.
- the multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
- the request acquisition module 701 can be used to execute any step in the aforementioned task processing method
- the task creation module 702 can be used to execute any step in the method provided by the above embodiments
- the task processing module 703 can be used to execute any step in the method provided by the above embodiments; the steps that the request acquisition module 701, the task creation module 702, and the task processing module 703 are responsible for implementing can be specified as needed, and all functions of the task processing device 700 are realized by respectively implementing different steps in the method provided by the above embodiments through the request acquisition module 701, the task creation module 702, and the task processing module 703.
- the present application also provides a computing device 800.
- the computing device 800 includes: a bus 802, a processor 804, a memory 806, and a communication interface 808.
- the processor 804, the memory 806, and the communication interface 808 communicate with each other through the bus 802.
- the computing device 800 can be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in the computing device 800.
- the bus 802 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc.
- the bus may be divided into an address bus, a data bus, a control bus, etc.
- FIG8 is represented by only one line, but does not mean that there is only one bus or one type of bus.
- the bus 804 may include a path for transmitting information between various components of the computing device 800 (e.g., the memory 806, the processor 804, and the communication interface 808).
- Processor 804 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
- CPU central processing unit
- GPU graphics processing unit
- MP microprocessor
- DSP digital signal processor
- the memory 806 may include a volatile memory, such as a random access memory (RAM).
- the processor 104 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
- ROM read-only memory
- HDD hard disk drive
- SSD solid state drive
- the memory 806 stores executable program codes, and the processor 804 executes the executable program codes to respectively implement the functions of the request acquisition module 701, the task creation module 702, and the task processing module 703, thereby implementing all or part of the steps of the method in the above embodiment. That is, the memory 806 stores instructions for executing all or part of the steps in the method in the above embodiment.
- the memory 806 stores executable codes
- the processor 804 executes the executable codes to respectively implement the functions of the task processing device 700, thereby implementing all or part of the steps in the above-mentioned embodiment method. That is, the memory 806 stores instructions for executing all or part of the steps in the above-mentioned embodiment method.
- the communication interface 803 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 800 and other devices or communication networks.
- a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 800 and other devices or communication networks.
- the present application also provides a computing device cluster.
- the computing device cluster includes at least one computing device.
- the computing device may be a server, such as a central server, an edge server, or a local server in a local data center.
- the computing device cluster includes at least one computing device.
- the computing device can also be a terminal device such as a desktop computer, a laptop computer or a smart phone.
- the computing device cluster includes at least one computing device 800.
- the memory 806 in one or more computing devices 800 in the computing device cluster may store the same instructions for executing all or part of the steps in the above embodiment method.
- the memory 806 of one or more computing devices 800 in the computing device cluster may also store partial instructions for executing all or part of the steps in the above-mentioned embodiment method.
- the combination of one or more computing devices 800 may jointly execute instructions for executing all or part of the steps in the above-mentioned embodiment method.
- the memory 806 in different computing devices 800 in the computing device cluster can store different instructions, which are respectively used to execute part of the functions of the task processing apparatus 700. That is, the instructions stored in the memory 806 in different computing devices 800 can implement the functions of one or more of the aforementioned request acquisition module 701, task creation module 702, and task processing module 703.
- one or more computing devices in the computing device cluster may be connected via a network, which may be a wide area network or a local area network.
- the embodiment of the present application provides a node.
- the node may include: at least one memory for storing a program; and at least one processor for executing the program stored in the memory.
- the processor is used to execute the method in the above embodiment.
- an embodiment of the present application provides a computer-readable storage medium, which stores a computer program.
- the computer program runs on a processor, the processor executes the method in the above embodiment.
- an embodiment of the present application provides a computer program product.
- the computer program product runs on a processor
- the processor executes the method in the above embodiment.
- processors in the embodiments of the present application may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof.
- the general-purpose processor may be a microprocessor or any conventional processor.
- the method steps in the embodiments of the present application can be implemented by hardware or by a processor executing software instructions.
- the software instructions can be composed of corresponding software modules, which can be stored in random access memory (RAM), flash memory, read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, mobile hard disks, CD-ROMs, or any other form of storage medium known in the art.
- An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium.
- the storage medium can also be a component of the processor.
- the processor and the storage medium can be located in an ASIC.
- the computer program product includes one or more computer instructions.
- the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.
- the computer instructions may be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium.
- the computer instructions may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.).
- the computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated.
- the available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state drive (SSD)), etc.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Hardware Redundancy (AREA)
Abstract
Description
本申请要求于2022年11月22日提交中国国家知识产权局、申请号为202211463984.8、申请名称为“一种任务处理方法、装置及节点”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on November 22, 2022, with application number 202211463984.8 and application name “A task processing method, device and node”, the entire contents of which are incorporated by reference in this application.
本申请涉及信息技术(information technology,IT)技术领域,尤其涉及一种任务处理方法、装置及节点。The present application relates to the field of information technology (IT) technology, and in particular to a task processing method, device and node.
随着技术的不断发展,服务架构逐渐从单体架构向分布式架构演进,服务的部署方式也从单进程模式演进到集群模式,来保证软件的弹性扩容能力和高可靠,以应对用户的变化。一般地,集群可以分为主备集群和主主集群。在主备集群中,只有主节点工作,备节点不工作。在主主集群中,每个节点都工作,且需要在前端部署一个负载均衡器,来实现集群的负载分担。主主集群和主备集群相比,主主集群的性能更高,且较为常用。但在主主集群中,当两个节点之间存在调用关系时,若两个节点之间通信失败或者被调用的节点处理失败等,则其中一个节点返回至用户的结果将和实际结果不一致,影响用户体验。With the continuous development of technology, the service architecture has gradually evolved from a monolithic architecture to a distributed architecture, and the deployment mode of services has also evolved from a single process mode to a cluster mode to ensure the elastic expansion capability and high reliability of the software to cope with changes in users. Generally, clusters can be divided into active-standby clusters and active-active clusters. In an active-standby cluster, only the primary node works, and the standby node does not work. In an active-active cluster, each node works, and a load balancer needs to be deployed at the front end to achieve load sharing of the cluster. Compared with active-standby clusters, active-active clusters have higher performance and are more commonly used. However, in an active-active cluster, when there is a call relationship between two nodes, if the communication between the two nodes fails or the called node fails to process, the result returned to the user by one of the nodes will be inconsistent with the actual result, affecting the user experience.
发明内容Summary of the invention
本申请提供了一种任务处理方法、装置、节点、计算机存储介质及计算机产品,能够在用户所请求的任务处理失败时重新处理该任务,从而保证了节点返回的结果和实际结果一致,提升了用户体验。The present application provides a task processing method, device, node, computer storage medium and computer product, which can reprocess the task requested by the user when the task processing fails, thereby ensuring that the result returned by the node is consistent with the actual result, thereby improving the user experience.
第一方面,本申请提供一种任务处理方法,可以应用于第一节点。该方法可以包括:获取用户发出的应用编程接口API请求;根据API请求创建目标任务,将目标任务的任务信息存储至数据库中;执行目标任务,并获取目标任务的执行状态;当目标任务的执行状态为失败时,根据存储在数据库中的目标任务的任务信息,重新执行目标任务。In a first aspect, the present application provides a task processing method that can be applied to a first node. The method may include: obtaining an application programming interface API request issued by a user; creating a target task according to the API request, and storing the task information of the target task in a database; executing the target task and obtaining the execution status of the target task; when the execution status of the target task is failed, re-executing the target task according to the task information of the target task stored in the database.
这样,节点在获取到API请求后,通过为该请求创建任务,并持久化到数据库中,从而在该请求对应的任务处理失败时,可以从数据库中重新获取该请求对应的任务,并重新执行。由此,通过在数据库中增加重试自愈的数据(即为API请求创建的任务),使得节点在执行任务失败时,可以重试自愈,保证了节点返回的结果的正确性。In this way, after receiving an API request, the node creates a task for the request and persists it in the database. When the task processing corresponding to the request fails, the task corresponding to the request can be retrieved from the database and re-executed. Therefore, by adding retry self-healing data (i.e., the task created for the API request) in the database, the node can retry self-healing when the task execution fails, ensuring the correctness of the result returned by the node.
在一种可能的实现方式中,在执行目标任务后,该方法还包括:将目标任务的执行状态存储至数据库中。由此以将任务的状态刷新到数据库中。此时,获取目标任务的执行状态,可以包括:从数据库中获取目标任务的执行状态。In a possible implementation, after executing the target task, the method further includes: storing the execution status of the target task in a database, thereby refreshing the status of the task in the database. At this time, obtaining the execution status of the target task may include: obtaining the execution status of the target task from the database.
在一种可能的实现方式中,该方法还可以包括:从数据库中获取第二节点的心跳信息,心跳信息用于表征第二节点是否出现故障;当第二节点出现故障时,从数据库中获取由第二节点创建且未执行或执行失败的至少一个任务的任务信息;根据至少一个任务的任务信息,执行至少一个任务,以及,将至少一个任务中各个任务的执行状态均存储至数据库中。由此,以避免出现因节点故障而导致任务处理失败的情况,保证任务处理的可靠性。In a possible implementation, the method may further include: obtaining heartbeat information of the second node from a database, the heartbeat information being used to indicate whether the second node fails; when the second node fails, obtaining task information of at least one task created by the second node and not executed or failed to execute from the database; executing at least one task according to the task information of the at least one task, and storing the execution status of each task in the at least one task in the database. In this way, the situation of task processing failure caused by node failure is avoided, and the reliability of task processing is ensured.
在一种可能的实现方式中,该方法还可以包括:当执行目标任务的次数达到预设次数,且最后一次的执行状态为失败,输出告警信息。由此以让用户获知到资源处理失败的情况,并进行人为修复。In a possible implementation, the method may further include: when the number of times the target task is executed reaches a preset number and the last execution status is failure, outputting an alarm message, so that the user can be informed of the resource processing failure and perform manual repair.
在一种可能的实现方式中,API请求用于请求创建目标资源,执行目标任务,包括:创建目标资源。In a possible implementation, the API request is used to request the creation of a target resource and the execution of a target task, including: creating a target resource.
在一种可能的实现方式中,方法还包括:向用户返回目标任务的执行状态。由此以让用户获知到任务的执行状态。In a possible implementation, the method further includes: returning the execution status of the target task to the user, so that the user can know the execution status of the task.
第二方面,本申请提供一种任务处理装置。该装置可以部署于第一节点。该装置包括:请求获取模块,用于获取用户发出的应用编程接口API请求;任务创建模块,用于根据API请求创建目标任务,将目标任务的任务信息存储至数据库中;任务处理模块,用于执行目标任务,并获取目标任务的执行状态;以及,当目标任务的执行状态为失败时,根据存储在数据库中的目标任务的任务信息,重新执行目标任务。In a second aspect, the present application provides a task processing device. The device can be deployed on a first node. The device includes: a request acquisition module, used to acquire an application programming interface API request issued by a user; a task creation module, used to create a target task according to the API request and store the task information of the target task in a database; a task processing module, used to execute the target task and acquire the execution status of the target task; and, when the execution status of the target task is failed, re-execute the target task according to the task information of the target task stored in the database.
在一种可能的实现方式中任务处理模块在执行目标任务后还用于:将目标任务的执行状态存储至数据库中;其中,任务处理模块在获取目标任务的执行状态时,具体用于:从数据库中获取目标任务的执行状 态。In a possible implementation, after executing the target task, the task processing module is further used to: store the execution status of the target task in a database; wherein, when obtaining the execution status of the target task, the task processing module is specifically used to: obtain the execution status of the target task from the database; state.
在一种可能的实现方式中任务处理模块,还用于:从数据库中获取第二节点的心跳信息,心跳信息用于表征第二节点是否出现故障;当第二节点出现故障时,从数据库中获取由第二节点创建且未执行或执行失败的至少一个任务的任务信息;In a possible implementation, the task processing module is further used to: obtain heartbeat information of the second node from a database, where the heartbeat information is used to indicate whether the second node fails; when the second node fails, obtain task information of at least one task created by the second node and not executed or failed to execute from the database;
根据至少一个任务的任务信息,执行至少一个任务,以及,将至少一个任务中各个任务的执行状态均存储至数据库中。At least one task is executed according to the task information of at least one task, and the execution status of each task in the at least one task is stored in a database.
在一种可能的实现方式中任务处理模块,还用于:当执行目标任务的次数达到预设次数,且最后一次的执行状态为失败,输出告警信息。In a possible implementation, the task processing module is further used to: output an alarm message when the number of times the target task is executed reaches a preset number and the last execution status is failure.
在一种可能的实现方式中API请求用于请求创建目标资源,任务处理模块在执行目标任务时,具体用于:创建目标资源。In a possible implementation, the API request is used to request the creation of a target resource, and the task processing module, when executing the target task, is specifically used to: create the target resource.
在一种可能的实现方式中,任务处理模块,还用于:向用户返回目标任务的执行状态。In a possible implementation, the task processing module is further configured to return the execution status of the target task to the user.
第三方面,本申请提供一种节点,包括:至少一个存储器,用于存储程序;至少一个处理器,用于执行存储器存储的程序;其中,当存储器存储的程序被执行时,处理器用于执行如第一方面或第一方面的任一种可能的实现方式所描述的方法。In a third aspect, the present application provides a node, comprising: at least one memory for storing programs; and at least one processor for executing the programs stored in the memory; wherein, when the program stored in the memory is executed, the processor is used to execute the method described in the first aspect or any possible implementation of the first aspect.
第四方面,本申请提供一种计算设备,包括:至少一个存储器,用于存储程序;至少一个处理器,用于执行存储器存储的程序;其中,当存储器存储的程序被执行时,处理器用于执行第一方面或第一方面的任一种可能的实现方式所描述的方法。示例性的,该计算设备可以为设备集群中的某个节点,比如可以为图2中所示的节点1等。In a fourth aspect, the present application provides a computing device, comprising: at least one memory for storing a program; at least one processor for executing the program stored in the memory; wherein, when the program stored in the memory is executed, the processor is used to execute the method described in the first aspect or any possible implementation of the first aspect. Exemplarily, the computing device may be a node in a device cluster, such as node 1 shown in FIG. 2 .
第五方面,本申请提供一种计算设备集群,包括至少一个计算设备,每个计算设备均包括处理器和存储器;至少一个计算设备的处理器用于执行至少一个计算设备的存储器中存储的指令,以使得计算设备集群执行第一方面或第一方面的任一种可能的实现方式所描述的方法。In a fifth aspect, the present application provides a computing device cluster, comprising at least one computing device, each computing device comprising a processor and a memory; the processor of at least one computing device is used to execute instructions stored in the memory of at least one computing device, so that the computing device cluster executes the method described in the first aspect or any possible implementation of the first aspect.
第六方面,本申请提供一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,当计算机程序在处理器上运行时,使得处理器执行第一方面或第一方面的任一种可能的实现方式所描述的方法。In a sixth aspect, the present application provides a computer-readable storage medium, which stores a computer program. When the computer program runs on a processor, the processor executes the method described in the first aspect or any possible implementation of the first aspect.
第七方面,本申请提供一种计算机程序产品,当计算机程序产品在处理器上运行时,使得处理器执行第一方面或第一方面的任一种可能的实现方式所描述的方法。In a seventh aspect, the present application provides a computer program product. When the computer program product runs on a processor, the processor executes the method described in the first aspect or any possible implementation of the first aspect.
可以理解的是,上述第二方面至第七方面的有益效果可以参见上述第一方面中的相关描述,在此不再赘述。It can be understood that the beneficial effects of the second to seventh aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here.
下面对实施例或现有技术描述中所需使用的附图作简单地介绍。The following is a brief introduction to the drawings required for describing the embodiments or prior art.
图1是本申请实施例提供的一种主主集群中一个节点的工作过程示意图;FIG1 is a schematic diagram of a working process of a node in a master-master cluster provided in an embodiment of the present application;
图2是本申请实施例提供的一种主主集群的任务处理系统的系统架构示意图;FIG2 is a schematic diagram of the system architecture of a task processing system of a master-master cluster provided in an embodiment of the present application;
图3是本申请实施例提供的一种API请求所包含的资源的示意图;FIG3 is a schematic diagram of resources included in an API request provided in an embodiment of the present application;
图4是本申请实施例提供的一种节点出现故障时的任务处理示意图;FIG4 is a schematic diagram of task processing when a node fails according to an embodiment of the present application;
图5是本申请实施例提供的一种节点处理资源时资源状态的变化示意图;5 is a schematic diagram of a change in resource state when a node processes resources provided by an embodiment of the present application;
图6是本申请实施例提供的一种任务处理方法的流程示意图;FIG6 is a flowchart of a task processing method provided in an embodiment of the present application;
图7是本申请实施例提供的一种任务处理装置的结构示意图;FIG7 is a schematic diagram of the structure of a task processing device provided in an embodiment of the present application;
图8是本申请实施例提供的一种计算设备的结构示意图;FIG8 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;
图9是本申请实施例提供的一种计算设备集群的结构示意图。FIG. 9 is a schematic diagram of the structure of a computing device cluster provided in an embodiment of the present application.
本文中术语“和/或”,是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。本文中符号“/”表示关联对象是或者的关系,例如A/B表示A或者B。The term "and/or" in this article is a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and/or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The symbol "/" in this article indicates that the associated objects are in an or relationship, for example, A/B means A or B.
本文中的说明书和权利要求书中的术语“第一”和“第二”等是用于区别不同的对象,而不是用于描述对象的特定顺序。例如,第一响应消息和第二响应消息等是用于区别不同的响应消息,而不是用于描述响应消息的特定顺序。The terms "first" and "second" in the specification and claims herein are used to distinguish different objects rather than to describe a specific order of the objects. For example, a first response message and a second response message are used to distinguish different response messages rather than to describe a specific order of the response messages.
在本申请实施例中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中 被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。In the embodiments of the present application, the words "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" should not be interpreted as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
在本申请实施例的描述中,除非另有说明,“多个”的含义是指两个或者两个以上,例如,多个处理单元是指两个或者两个以上的处理单元等;多个元件是指两个或者两个以上的元件等。In the description of the embodiments of the present application, unless otherwise specified, "multiple" means two or more than two. For example, multiple processing units refer to two or more processing units, etc.; multiple elements refer to two or more elements, etc.
示例性的,图1示出了一种主主集群中一个节点的工作过程示意图。如图1所示,为了提高资源处理性能,在节点1的内部常采用异步处理的方式。在图1中,节点1的线程池(thread pool)中一部分线程可以获取一个或多个应用程序编程接口(application programming interface,API)请求,以及将各个API请求的资源存储至数据库层(database layer,DB layer)中。当将某个API请求的资源存储至数据库中后,节点1可以通过处理该API请求的线程从数据库中读取存储结果。当存储结果为存储成功时,该线程则向用户返回用于表征处理成功的请求结果。线程池中的另一部分线程可以用于内部处理资源,比如调用其他服务的API等。此外,当某个API请求的资源存储至数据库中后,节点1中的资源处理器(resource handler)可以通过某个线程调用其他的节点所提供的服务。最后,节点1可以将其他的节点返回的结果发送给用户。示例性的,其他的节点所提供的服务也可以称之为“下游服务”,即位于节点1所提供的服务的下游的服务,或者是节点1所需调用的服务等。例如,节点1提供服务1,节点2提供服务2,若服务1在运行时,需要调用服务2,则服务2可以称之为服务1的下游服务。Exemplarily, FIG1 shows a schematic diagram of the working process of a node in a master-master cluster. As shown in FIG1 , in order to improve resource processing performance, an asynchronous processing method is often used inside node 1. In FIG1 , a part of threads in the thread pool of node 1 can obtain one or more application programming interface (API) requests, and store the resources of each API request in the database layer (DB layer). After storing the resources of a certain API request in the database, node 1 can read the storage result from the database through the thread that processes the API request. When the storage result is a successful storage, the thread returns the request result representing the successful processing to the user. Another part of the threads in the thread pool can be used for internal processing resources, such as calling APIs of other services. In addition, after the resources of a certain API request are stored in the database, the resource handler in node 1 can call the services provided by other nodes through a thread. Finally, node 1 can send the results returned by other nodes to the user. Exemplarily, the services provided by other nodes can also be called "downstream services", that is, services located downstream of the services provided by node 1, or services that node 1 needs to call. For example, node 1 provides service 1, and node 2 provides service 2. If service 1 needs to call service 2 during operation, service 2 can be called the downstream service of service 1.
但在图1中,当节点1中的资源处理器处理失败,或者下游服务对应的节点出现故障等,节点1将难以获取到其他节点返回的结果,致使节点1在将相应的资源存储至其数据库中时返回给用户的结果,与其真实的需要向用户返回的结果(即其他节点返回的结果)不一致。However, in Figure 1, when the resource processor in node 1 fails, or the node corresponding to the downstream service fails, etc., node 1 will find it difficult to obtain the results returned by other nodes, causing the result returned to the user by node 1 when storing the corresponding resource in its database to be inconsistent with the result it actually needs to return to the user (i.e., the result returned by other nodes).
有鉴于此,本申请实施例提供了一种任务处理方法,该方法可以在将API请求中的资源存储至数据库中时,为该API请求中的各个资源分别创建一个任务,以及将创建的任务存储在数据库中。接着,可以执行各个任务,当某个任务执行失败时,可以从数据库中重新获取该任务,并重新处理该任务,从而保证API请求的资源能够被处理,进而保证节点返回给用户的结果的正确性。由此,通过在数据库中增加重试自愈的数据(即为API请求中各个资源创建的任务),使得节点在执行任务失败时,可以重试自愈,保证了节点返回结果的正确性。In view of this, an embodiment of the present application provides a task processing method, which can create a task for each resource in the API request when storing the resources in the API request in the database, and store the created tasks in the database. Then, each task can be executed. When a task fails to execute, the task can be retrieved from the database and reprocessed, thereby ensuring that the resources of the API request can be processed, and then ensuring the correctness of the results returned by the node to the user. Therefore, by adding retry self-healing data to the database (i.e., tasks created for each resource in the API request), the node can retry self-healing when the task fails to execute, thereby ensuring the correctness of the results returned by the node.
示例性的,图2示出了一种主主集群的任务处理系统的架构。如图2所示,该主主集群的任务处理系统200可以包括:主主集群210和数据库220。主主集群210中包括n个节点,n≥2。Exemplarily, Fig. 2 shows an architecture of a task processing system of a master-master cluster. As shown in Fig. 2, the task processing system 200 of the master-master cluster may include: a master-master cluster 210 and a database 220. The master-master cluster 210 includes n nodes, where n≥2.
本实施例中,主主集群210中的每个节点中均包括:请求获取模块211、任务创建模块212、任务调度模块213和任务处理模块214。In this embodiment, each node in the master-master cluster 210 includes: a request acquisition module 211 , a task creation module 212 , a task scheduling module 213 and a task processing module 214 .
其中,每个节点中的请求获取模块211均主要用于获取用户下发的API请求。示例性的,用户可以通过节点所提供的用户界面下发API请求。示例性的,API请求中可以包括待处理的一个或多个资源,比如用户或租户购买或更新的产品等。在一些实施例中,请求获取模块211获取到API请求后,可以将API请求中包含的资源存储至数据库220中,以完成对资源的持久化。另外,请求获取模块211还可以将其获取到的API请求传输至任务创建模块212。Among them, the request acquisition module 211 in each node is mainly used to obtain the API request issued by the user. Exemplarily, the user can issue an API request through the user interface provided by the node. Exemplarily, the API request may include one or more resources to be processed, such as products purchased or updated by the user or tenant. In some embodiments, after the request acquisition module 211 obtains the API request, the resources contained in the API request can be stored in the database 220 to complete the persistence of the resources. In addition, the request acquisition module 211 can also transmit the API request it obtains to the task creation module 212.
任务创建模块212主要用于在获取到请求获取模块211发送的API请求后,通过预配置的函数为API请求中包含的资源创建任务,以及将其创建的任务存储至数据库220中,以完成对其创建的任务的持久化。在一些实施例中,每个任务均可以与一个用户或租户关联,和/或,与一个资源关联。在一些实施例中,不同的任务可以与同一个用户或租户关联。另外,不同的任务可以与不同的资源关联。在一些实施例中,当一个API请求中包含多个资源时,可以基于各个资源间的依赖关系或上下级关系等,确定各个资源对应的任务的执行顺序。例如,如图3所示,若API请求中包含的资源为:租户购买的虚拟机、网卡和卷,由于在执行创建虚拟机之前需要先创建网卡和卷,而创建网卡和卷间不存在依赖关系,因此,可以分别为创建虚拟机、创建网卡和创建卷这三个资源创建任务,且设定创建网卡对应的任务和创建卷对应的任务可以并行,设定创建虚拟机对应的任务需要在创建网卡对应的任务和创建卷对应的任务完成之后执行。The task creation module 212 is mainly used to create tasks for the resources contained in the API request through a preconfigured function after obtaining the API request sent by the request acquisition module 211, and store the created tasks in the database 220 to complete the persistence of the created tasks. In some embodiments, each task can be associated with a user or tenant, and/or associated with a resource. In some embodiments, different tasks can be associated with the same user or tenant. In addition, different tasks can be associated with different resources. In some embodiments, when multiple resources are included in an API request, the execution order of the tasks corresponding to each resource can be determined based on the dependency relationship or superior-subordinate relationship between each resource. For example, as shown in Figure 3, if the resources included in the API request are: virtual machines, network cards and volumes purchased by tenants, since network cards and volumes need to be created before executing the creation of virtual machines, and there is no dependency relationship between the creation of network cards and volumes, therefore, tasks can be created for the three resources of creating virtual machines, creating network cards and creating volumes, and the tasks corresponding to the creation of network cards and the creation of volumes can be set in parallel, and the tasks corresponding to the creation of virtual machines need to be executed after the tasks corresponding to the creation of network cards and the creation of volumes are completed.
任务调度模块213主要用于从数据库220中获取需要其所属的节点执行的任务(比如未处理的任务或者处理失败的任务等),以及,根据任务的创建时间、任务间的依赖关系或者任务的标识(比如任务所关联的租户的标识,或者,任务所关联的资源的标识等)等,分配任务队列。在一些实施例中,当根据任务的创建时间分配任务队列时,在任务队列中各个任务的处理顺序与各个任务的创建时间相关,其中,创建时间越早的任务的执行顺序越靠前,即越早被执行。在一些实施例中,当根据任务的标识分配任务队列时,可以将相同的标识的任务分配到同一任务队列中。在一些实施例中,任务调度模块213可以为待处理的任 务分配一个任务队列,也可以分配多个任务队列,具体可根据实际情况而定,此处不做限定。The task scheduling module 213 is mainly used to obtain tasks that need to be executed by the node to which it belongs (such as unprocessed tasks or failed tasks, etc.) from the database 220, and to allocate task queues according to the creation time of the tasks, the dependency between tasks, or the identification of the tasks (such as the identification of the tenant associated with the task, or the identification of the resource associated with the task, etc.). In some embodiments, when the task queues are allocated according to the creation time of the tasks, the processing order of each task in the task queue is related to the creation time of each task, wherein the earlier the creation time of the task is, the earlier the execution order of the task is, that is, the earlier it is executed. In some embodiments, when the task queues are allocated according to the identification of the task, tasks with the same identification can be allocated to the same task queue. In some embodiments, the task scheduling module 213 can allocate tasks to be processed according to the identification of the task. A task can be assigned to one task queue or multiple task queues, depending on the actual situation and is not limited here.
任务处理模块214主要是用于执行任务调度模块213所分配的各个任务队列中的任务。在一些实施例中,任务处理模块214可以为不同的任务队列分配不同的线程,即通过不同的线程执行不同的任务队列中的任务。在一些实施例中,任务处理模块214在执行任务时,可以调用其他的节点所提供的服务的API,以及等待其所调用的服务的执行结果,并将相应的执行状态存储至数据库220中。示例性的,任务处理模块214存储至数据库220中的执行状态,可以理解为是各个任务的执行状态,由此以使得任务调度模块213可以获知到数据库220中的任务哪些是待处理的任务,哪些是已处理成功的任务。其中,待处理的任务可以包括未处理的任务和/或处理失败的任务。例如,当一个任务处理成功时,任务处理模块214获取到的该任务所需调用的服务的执行状态为成功;当一个任务处理失败时,任务处理模块214获取到的该任务所需调用的服务的执行状态为失败。在一些实施例中,任务处理模块214还可以将各个资源对应的执行状态反馈至用户。The task processing module 214 is mainly used to execute the tasks in each task queue assigned by the task scheduling module 213. In some embodiments, the task processing module 214 can assign different threads to different task queues, that is, execute the tasks in different task queues through different threads. In some embodiments, when executing a task, the task processing module 214 can call the API of the service provided by other nodes, and wait for the execution result of the service called by it, and store the corresponding execution status in the database 220. Exemplarily, the execution status stored in the database 220 by the task processing module 214 can be understood as the execution status of each task, so that the task scheduling module 213 can know which tasks in the database 220 are pending tasks and which are successfully processed tasks. Among them, the pending tasks may include unprocessed tasks and/or tasks that have failed to be processed. For example, when a task is successfully processed, the execution status of the service required to be called by the task obtained by the task processing module 214 is successful; when a task is failed to be processed, the execution status of the service required to be called by the task obtained by the task processing module 214 is failed. In some embodiments, the task processing module 214 can also feedback the execution status corresponding to each resource to the user.
在一些实施例中,主主集群210中的每个节点中均可以存在一个线程周期性从数据库220中扫描处理失败的任务,以使相应的节点中的任务调度模块213将处理失败的任务加入到任务队列中,进行重试自愈。In some embodiments, each node in the master cluster 210 may have a thread that periodically scans failed tasks from the database 220 so that the task scheduling module 213 in the corresponding node adds the failed tasks to the task queue for retry self-healing.
本实施例中,数据库220主要是用于存储主主集群210中各个节点存储的资源、任务和各个任务的执行状态等。In this embodiment, the database 220 is mainly used to store resources, tasks, and execution status of each task stored in each node in the master cluster 210 .
在一些实施例中,数据库220中还可以存储主主集群210中各个节点的运行情况,以使得在某个节点出现故障时,将其所需执行的任务转移至其他的节点,从而避免出现因节点故障导致资源处理失败的情况,保证资源处理的可靠性。举例来说,如图4的(A)所示,主主集群包括节点1、节点2和节点3,在数据库220中存储有任务1至9。节点1所需执行的任务为任务1至3,节点2所需执行的任务为任务4至6,节点3所需执行的任务为任务7至9。如图4的(B)所示,当节点2出现故障时,节点1可以接管节点2所需执行的任务,此时节点1所需执行的任务为任务1至6。由此使得在节点2出现故障时,节点2所需执行的任务也能被转移到其他节点执行,保证了资源处理的可靠性。In some embodiments, the database 220 may also store the operation status of each node in the main main cluster 210, so that when a node fails, the tasks required to be executed are transferred to other nodes, thereby avoiding the situation where resource processing fails due to node failure and ensuring the reliability of resource processing. For example, as shown in (A) of Figure 4, the main main cluster includes node 1, node 2 and node 3, and tasks 1 to 9 are stored in the database 220. The tasks required to be executed by node 1 are tasks 1 to 3, the tasks required to be executed by node 2 are tasks 4 to 6, and the tasks required to be executed by node 3 are tasks 7 to 9. As shown in (B) of Figure 4, when node 2 fails, node 1 can take over the tasks required to be executed by node 2, and the tasks required to be executed by node 1 are tasks 1 to 6. As a result, when node 2 fails, the tasks required to be executed by node 2 can also be transferred to other nodes for execution, ensuring the reliability of resource processing.
其中,主主集群210中的各个节点在启动时,均可以在数据库220中注册身份,并在后续运行过程中向数据库220中写心跳,以通节点的心跳确定节点是否出现故障,并通过节点的注册身份确定出出现故障的节点。此时,每个节点上均可以具有一个用于向数据库220中定期写心跳的线程,由此以将节点的状态刷新到数据库220中。另外,每个节点也均可以具有一个定期从数据库220中查询其他节点的健康状态的线程,以定期查询到其他节点是否故障。Among them, each node in the main cluster 210 can register its identity in the database 220 when it is started, and write heartbeats to the database 220 during the subsequent operation process, so as to determine whether the node is faulty through the heartbeat of the node, and determine the faulty node through the registered identity of the node. At this time, each node can have a thread for regularly writing heartbeats to the database 220, so as to refresh the state of the node to the database 220. In addition, each node can also have a thread that regularly queries the health status of other nodes from the database 220 to regularly query whether other nodes are faulty.
作为一种可能的实现方式,在主主集群210中可以设置一个主节点,并由该主节点周期性从数据库220中扫描其他的各个节点的状态,并在某个节点出现故障时,接管该出现故障的节点未成功处理完的任务。示例性的,主主集群210中的各个节点均可以周期性尝试锁定数据库220中的某一行,此时可以将优先锁定该行的节点作为主节点。示例性的,为了防止主节点因长时间接管其他节点的任务而影响其自身的处理性能,当一个节点做为主节点的时长达到预设时长时,该节点可以放弃(即释放)锁定数据库220中的行,并在一段时间内不参与主节点的选取工作。As a possible implementation, a master node may be set in the master cluster 210, and the master node periodically scans the status of other nodes from the database 220, and when a node fails, takes over the tasks that have not been successfully processed by the failed node. Exemplarily, each node in the master cluster 210 may periodically try to lock a row in the database 220, and at this time, the node that preferentially locks the row may be used as the master node. Exemplarily, in order to prevent the master node from affecting its own processing performance due to taking over the tasks of other nodes for a long time, when a node serves as a master node for a preset time, the node may give up (i.e., release) locking the row in the database 220 and not participate in the selection of the master node for a period of time.
作为另一种可能的实现方式,主主集群210中的各个节点均可以接管出现故障的节点未执行成功的任务。此时,每个节点均可以定期从数据库220中查询其他节点的健康状态。如果节点1检测到节点2出现故障,那么节点1可以根据其自身的执行能力,接管节点2上一部分未执行成功的任务。而节点1未接管的任务,则可以由其他的检测到节点2出现故障的节点接管。As another possible implementation, each node in the master cluster 210 can take over the tasks that were not successfully executed by the failed node. At this time, each node can periodically query the health status of other nodes from the database 220. If node 1 detects that node 2 is faulty, node 1 can take over some of the tasks that were not successfully executed on node 2 based on its own execution capability. The tasks that node 1 did not take over can be taken over by other nodes that detect that node 2 is faulty.
进一步地,当出现故障的节点恢复正常后,该节点可以优先处理归属于其自己但没有被执行成功的任务,以防止其自己的任务被其他的节点接管后处理不及时。另外,该恢复正常的节点,在执行任务时,可以先由数据库220中存储的各个任务的执行状态判断其当前所需执行的任务是否被执行,如果已被执行且执行的结果是成功,则其跳过该任务并处理下一个任务。同时,接管出现故障的节点的任务的节点,在执行其接管的任务时,也可以先由数据库220中存储的各个任务的执行状态判断其当前所需执行的任务是否被执行,如果已执行则其跳过该任务并处理下一个任务。当然,接管出现故障的节点的任务的节点,在判断出其当前所需执行的任务已被执行时,也可以判断执行状态是否为成功,如果执行失败,则其可以继续执行该任务,否则则处理下一个任务。Further, after the node that has failed returns to normal, the node can give priority to the tasks that belong to it but have not been successfully executed, so as to prevent its own tasks from being handled in time after being taken over by other nodes. In addition, when executing a task, the node that has returned to normal can first judge whether the task that it currently needs to execute is executed by the execution status of each task stored in the database 220, if it has been executed and the result of execution is success, then it skips the task and processes the next task. At the same time, when executing the task that it takes over, the node that takes over the task of the node that has failed can also first judge whether the task that it currently needs to execute is executed by the execution status of each task stored in the database 220, if it has been executed, then it skips the task and processes the next task. Of course, when judging that the task that it currently needs to execute has been executed, the node that takes over the task of the node that has failed can also judge whether the execution status is successful, if the execution fails, then it can continue to execute the task, otherwise it processes the next task.
在一些实施例中,对于复杂的业务场景,资源的处理之间有依赖,需要保序来简化内部的实现,因此,可以通过资源的状态约束来保证资源内部处理的顺序,防止乱序问题。本实施例中,可以通过闭环实现,以让资源的状态约束变复杂,从而保证资源内部处理的顺序。其中,资源的状态可以包括创建资源是否成 功,删除资源是否成功,更新资源是否成功等。示例性的,在处理任意一个资源后的状态为失败的情况下,可以重新处理该任意一个资源,直至处理该任意一个资源后的状态为成功,由此以对资源的状态进行约束,保证资源的处理顺序。另外,在处理任意一个资源的次数达到所述预设次数,且处理该任意一个资源后的状态仍为失败的情况下,可以输出告警信息,由此以让用户获知到资源处理失败的情况,并进行人为修复。In some embodiments, for complex business scenarios, there are dependencies between resource processing, and order preservation is required to simplify internal implementation. Therefore, the state constraints of resources can be used to ensure the order of internal resource processing to prevent disorder. In this embodiment, closed loop implementation can be used to make the state constraints of resources more complex, thereby ensuring the order of internal resource processing. Among them, the state of a resource can include whether the creation of the resource is successful. Success, whether the resource is deleted successfully, whether the resource is updated successfully, etc. Exemplarily, if the status after processing any resource is failed, the any resource can be reprocessed until the status after processing the any resource is successful, thereby constraining the status of the resources and ensuring the processing order of the resources. In addition, if the number of times any resource is processed reaches the preset number of times and the status after processing the any resource is still failed, an alarm message can be output, thereby letting the user know the situation of resource processing failure and perform manual repair.
具体地,如图5所示,当主主集群中某个节点在创建资源时,其可以将正在创建资源的状态写入前述的数据库220中,此时,数据库220中可以将该资源的状态刷新为正在创建,即图5中所示的“creating”。该节点在创建资源成功时,其可以将创建成功的状态写入前述的数据库220中,此时,数据库220中可以将该资源的状态刷新为可用状态,即图5中所示的“available”。该节点在创建资源失败时,其自身知道该资源创建失败,其可以在间隔预设时长(比如10s、20s等)重试创建该资源。其中,该节点在重新创建资源时,也可以将正在重试创建的状态写入到前述的数据库220中,此时在数据库220中该资源的状态可以为图5中所示的“retrying”。该节点在重新创建,且创建成功后,即图5中所示的“close-loop成功”,其可以将创建成功的状态写入前述的数据库220中,此时,数据库220中可以将该资源的状态刷新为可用状态,即图5中所示的“available”。Specifically, as shown in FIG5 , when a node in the master-master cluster is creating a resource, it can write the state of the resource being created into the aforementioned database 220. At this time, the state of the resource in the database 220 can be refreshed to being created, i.e., “creating” as shown in FIG5 . When the node successfully creates a resource, it can write the state of successful creation into the aforementioned database 220. At this time, the state of the resource in the database 220 can be refreshed to an available state, i.e., “available” as shown in FIG5 . When the node fails to create a resource, it knows that the resource creation has failed, and it can retry to create the resource at intervals of a preset duration (such as 10s, 20s, etc.). Among them, when the node recreates the resource, it can also write the state of retrying to create into the aforementioned database 220. At this time, the state of the resource in the database 220 can be “retrying” as shown in FIG5 . After the node is recreated and created successfully, that is, "close-loop success" shown in Figure 5, it can write the successful creation status into the aforementioned database 220. At this time, the status of the resource in the database 220 can be refreshed to an available status, that is, "available" shown in Figure 5.
该节点在重新创建m次(m≥1)后,若仍未创建成功,即图5中所示的“close-loop重试失败”,其可以将创建失败的状态写入前述的数据库220中,此时,数据库220中可以将该资源的状态刷新为不可用状态,即图5中所示的“failed”。该节点在创建资源失败后,其可以向用户返回创建失败的信息,以使用户进行修复。当用户完成修复后,该节点可以重新创建该资源,即图5中所示的“任务修复成功后,重新进入初始状态”,并可以将正在创建资源的状态写入前述的数据库220中,此时,数据库220中可以将该资源的状态刷新为正在创建,即图5中所示的“creating”。。If the node still fails to create successfully after being recreated m times (m≥1), that is, "close-loop retry failed" as shown in FIG5, the node can write the creation failure status into the aforementioned database 220. At this time, the database 220 can refresh the resource status to an unavailable state, that is, "failed" as shown in FIG5. After the node fails to create a resource, it can return the creation failure information to the user so that the user can repair it. When the user completes the repair, the node can recreate the resource, that is, "re-enter the initial state after the task is successfully repaired" as shown in FIG5, and can write the resource creation status into the aforementioned database 220. At this time, the resource status in the database 220 can be refreshed to being created, that is, "creating" as shown in FIG5. .
在完成资源的创建后,当主主集群中某个节点需要删除资源时,该节点可以将正在删除资源的状态写入前述的数据库220中,此时,数据库220中可以将该资源的状态刷新为正在删除,即图5中所示的“deleting”。该节点在删除资源成功时,其可以将删除成功的状态写入前述的数据库220中,此时,数据库220中可以将该资源的状态刷新为已删除,即图5中所示的“deleted”。该节点在删除资源失败时,其自身知道该资源删除失败,其可以在间隔预设时长(比如10s、20s等)重试删除该资源。其中,该节点在重新删除资源时,也可以将正在重试删除的状态写入到前述的数据库220中,此时在数据库220中该资源的状态可以为图5中所示的“retrying”,并可以将正在删除资源的状态写入前述的数据库220中,此时,数据库220中可以将该资源的状态刷新为正在删除,即图5中所示的“deleting”。该节点在重新删除,且删除成功后,即图5中所示的“close-loop成功”,其可以将删除成功的状态写入前述的数据库220中,此时,数据库220中可以将该资源的状态刷新为已删除,即图5中所示的“deleted”。After completing the creation of resources, when a node in the master cluster needs to delete resources, the node can write the state of deleting resources into the aforementioned database 220. At this time, the state of the resource in the database 220 can be refreshed to being deleted, that is, "deleting" shown in Figure 5. When the node successfully deletes the resource, it can write the state of successful deletion into the aforementioned database 220. At this time, the state of the resource in the database 220 can be refreshed to deleted, that is, "deleted" shown in Figure 5. When the node fails to delete the resource, it knows that the resource deletion has failed, and it can retry to delete the resource at intervals of a preset time (such as 10s, 20s, etc.). Among them, when the node deletes the resource again, it can also write the state of retrying deletion into the aforementioned database 220. At this time, the state of the resource in the database 220 can be "retrying" as shown in Figure 5, and the state of deleting resources can be written into the aforementioned database 220. At this time, the state of the resource in the database 220 can be refreshed to being deleted, that is, "deleting" shown in Figure 5. After the node is deleted again and the deletion is successful, that is, "close-loop success" shown in Figure 5, the status of successful deletion can be written into the aforementioned database 220. At this time, the status of the resource in the database 220 can be refreshed to deleted, that is, "deleted" shown in Figure 5.
该节点在重新删除m次(m≥1)后,若仍未删除成功,即图5中所示的“close-loop重试失败”,其可以将删除失败的状态写入前述的数据库220中,此时,数据库220中可以将该资源的状态刷新为不可用状态,即图5中所示的“failed”。该节点在删除资源失败后,其可以向用户返回删除失败的信息,以使用户进行修复。当用户完成修复后,该节点可以重新删除该资源,即图5中所示的“任务修复成功后,重新进入初始状态”,并可以将正在删除资源的状态写入前述的数据库220中,此时,数据库220中可以将该资源的状态刷新为正在删除,即图5中所示的“deleting”。If the node still fails to delete successfully after re-deleting m times (m≥1), that is, "close-loop retry failed" as shown in Figure 5, it can write the deletion failure status into the aforementioned database 220. At this time, the status of the resource in the database 220 can be refreshed to an unavailable state, that is, "failed" as shown in Figure 5. After the node fails to delete the resource, it can return the deletion failure information to the user so that the user can repair it. When the user completes the repair, the node can delete the resource again, that is, "re-enter the initial state after the task is successfully repaired" as shown in Figure 5, and can write the status of deleting the resource into the aforementioned database 220. At this time, the status of the resource in the database 220 can be refreshed to being deleted, that is, "deleting" as shown in Figure 5.
在完成资源的创建后,当主主集群中某个节点需要更新资源时,该节点可以将正在更新资源的状态写入前述的数据库220中,此时,数据库220中可以将该资源的状态刷新为正在更新,即图5中所示的“modifying”。该节点在更新资源成功时,其可以将更新成功的状态写入前述的数据库220中,此时,数据库220中可以将该资源的状态刷新为已更新,即图5中所示的“available”。该节点在更新资源失败时,其自身知道该资源更新失败,其可以在间隔预设时长(比如10s、20s等)重试更新该资源。其中,该节点在重新更新资源时,也可以将正在重试更新的状态写入到前述的数据库220中,此时在数据库220中该资源的状态可以为图5中所示的“retrying”。该节点在重新更新,且更新成功后,即图5中所示的“close-loop成功”,其可以将更新成功的状态写入前述的数据库220中,此时,数据库220中可以将该资源的状态刷新为已更新,即图5中所示的“available”。After completing the creation of resources, when a node in the master-master cluster needs to update resources, the node can write the status of the resource being updated into the aforementioned database 220. At this time, the status of the resource in the database 220 can be refreshed to being updated, that is, "modifying" shown in Figure 5. When the node successfully updates the resource, it can write the status of the successful update into the aforementioned database 220. At this time, the status of the resource in the database 220 can be refreshed to updated, that is, "available" shown in Figure 5. When the node fails to update the resource, it knows that the resource update has failed, and it can retry to update the resource at a preset time interval (such as 10s, 20s, etc.). Among them, when the node re-updates the resource, it can also write the status of the retrying update into the aforementioned database 220. At this time, the status of the resource in the database 220 can be "retrying" as shown in Figure 5. After the node is re-updated and the update is successful, that is, "close-loop success" shown in Figure 5, it can write the successful update status into the aforementioned database 220. At this time, the status of the resource in the database 220 can be refreshed to updated, that is, "available" shown in Figure 5.
该节点在重新更新m次(m≥1)后,若仍未更新成功,即图5中所示的“close-loop重试失败”,其可以将更新失败的状态写入前述的数据库220中,此时,数据库220中可以将该资源的状态刷新为不可用状态,即图5中所示的“failed”。该节点在更新资源失败后,其可以向用户返回更新失败的信息,以使用户进行修复。当用户完成修复后,该节点可以重新更新该资源,即图5中所示的“任务修复成功后,重 新进入初始状态”,并可以将正在更新资源的状态写入前述的数据库220中,此时,数据库220中可以将该资源的状态刷新为正在更新,即图5中所示的“modifying”。If the node still fails to update successfully after re-updating m times (m≥1), that is, "close-loop retry failed" as shown in Figure 5, it can write the update failure status to the aforementioned database 220. At this time, the database 220 can refresh the status of the resource to an unavailable state, that is, "failed" as shown in Figure 5. After the node fails to update the resource, it can return the update failure information to the user so that the user can repair it. When the user completes the repair, the node can re-update the resource, that is, "re-update after successful task repair" as shown in Figure 5. The resource state being updated can be written into the aforementioned database 220. At this time, the resource state in the database 220 can be refreshed to being updated, i.e., "modifying" as shown in FIG. 5 .
在图5中,只有当某个资源的状态为可用状态(即available)时,才允许对该资源进行更新操作或者删除操作。由此以进行状态约束。In FIG5 , only when the state of a resource is available (ie, available), the update operation or the delete operation is allowed for the resource, thereby performing state constraints.
另外,若两个资源间存在依赖关系,且这两个资源位于不同的节点上,当这两个资源的状态均为可用状态(即available)时,才将这两个资源的状态均更新为可用状态(即available)。当两个资源中任意一个资源的状态为不可用状态(即failed)时,可以将这两个资源的状态均更新为不可用状态(即failed)。由此以进行状态约束。In addition, if there is a dependency between two resources and the two resources are located on different nodes, the status of the two resources will be updated to the available state (i.e., available) only when the status of the two resources is both available (i.e., available). When the status of any one of the two resources is unavailable (i.e., failed), the status of the two resources can be updated to the unavailable state (i.e., failed). In this way, the status constraint is performed.
此外,当重试所耗费的时间较长时,在这期间用户可以在该节点上执行其他的操作。在一些实施例中,重试所需执行的操作与重试前执行失败的操作相关。比如,重试前执行失败的操作为创建资源,则重试时所需执行的操作为创建资源;重试前执行失败的操作为更新资源,则重试时所需执行的操作为更新资源。In addition, when the time consumed by the retry is long, the user can perform other operations on the node during this period. In some embodiments, the operation to be performed in the retry is related to the operation that failed to be performed before the retry. For example, if the operation that failed to be performed before the retry was to create a resource, then the operation to be performed in the retry is to create a resource; if the operation that failed to be performed before the retry was to update a resource, then the operation to be performed in the retry is to update a resource.
进一步地,可以将资源的状态与资源对应的任务处理结果相关联。当一个资源的状态为不可用状态时,在处理该资源对应的任务时,大概率是不能处理成功的。当一个资源的状态为可用状态时,在处理该资源对应的任务时,大概率是能处理成功的。因此,当某个资源对应的任务处理成功时,可以将该资源的状态刷新为可用状态。当某个资源对应的任务处理识别时,可以将该资源的状态刷新为不可用状态,同时尝试重新执行此次操作之前所需执行的操作,比如创建资源、更新资源等。由此以保证在重新执行该资源对应的任务时,能够执行成功,提升可靠性。Furthermore, the state of a resource can be associated with the result of task processing corresponding to the resource. When the state of a resource is unavailable, there is a high probability that the task corresponding to the resource cannot be processed successfully. When the state of a resource is available, there is a high probability that the task corresponding to the resource can be processed successfully. Therefore, when the task corresponding to a resource is processed successfully, the state of the resource can be refreshed to an available state. When the task processing corresponding to a resource is identified, the state of the resource can be refreshed to an unavailable state, and at the same time, an attempt can be made to re-execute the operations required before this operation, such as creating resources, updating resources, etc. In this way, it is ensured that when the task corresponding to the resource is re-executed, it can be executed successfully, thereby improving reliability.
以上是对本申请实施例提供的主主集群的资源处理系统的介绍,下面基于上述内容,对本申请实施例提供的一种任务处理方法进行介绍。The above is an introduction to the resource processing system of the master-master cluster provided in an embodiment of the present application. Based on the above content, a task processing method provided in an embodiment of the present application is introduced below.
示例性的,图6示出了一种任务处理方法的流程。其中,该方法可以通过前述主主集群210中的任意一个节点执行。如图6所示,该任务处理方法可以包括以下步骤:Exemplarily, FIG6 shows a process of a task processing method. The method may be executed by any node in the aforementioned master-master cluster 210. As shown in FIG6, the task processing method may include the following steps:
S601、获取用户发出的应用编程接口API请求。S601: Obtain an application programming interface (API) request issued by a user.
本实施例中,用户可以通过节点提供的用户界面下发其所需的请求,比如当其需要购买产品时,其可以在节点所提供的用户界面上下发购买产品的请求等。用户下发请求后,节点即获取到该请求。示例性的,用户发出的请求可以但不限于为前述所描述的API请求。示例性的,API请求可以是用于创建某个资源,比如:创建虚拟机等,也可以是请求购买某个产品或服务,比如,购买衣服等商品等,也可以是请求支付款项等,比如通过金融类应用程序(application,APP)发起付款交易等。In this embodiment, the user can issue the required request through the user interface provided by the node. For example, when the user needs to purchase a product, the user can issue a request to purchase the product in the user interface provided by the node. After the user issues the request, the node obtains the request. Exemplarily, the request issued by the user can be, but is not limited to, the API request described above. Exemplarily, the API request can be used to create a resource, such as creating a virtual machine, etc., or it can be a request to purchase a product or service, such as purchasing clothes and other goods, etc., or it can be a request to pay money, such as initiating a payment transaction through a financial application (application, APP).
S602、根据获取到的API请求创建目标任务,并将目标任务的任务信息存储至数据库中。S602: Create a target task according to the obtained API request, and store the task information of the target task in a database.
本实施例中,节点在获取到用户下发的请求后,可以通过预配置的函数为该请求创建一个任务,从而得到目标任务。示例性的,目标任务是与API请求相关联的,例如,当API请求用于创建资源时,目标任务则为创建资源的任务;当API请求用于购买某个产品或服务时,目标任务则为购买某个产品或服务的任务;当API请求用于请求支付款项时,目标任务则为支付款项的任务。In this embodiment, after obtaining the request sent by the user, the node can create a task for the request through a preconfigured function, thereby obtaining a target task. Exemplarily, the target task is associated with the API request. For example, when the API request is used to create a resource, the target task is the task of creating the resource; when the API request is used to purchase a product or service, the target task is the task of purchasing a product or service; when the API request is used to request payment, the target task is the task of paying the money.
进一步地,在得到目标任务后,节点可以将该目标任务的任务信息存储至数据库中,以完成对目标任务的持久化,从而使得在获知目标任务处理失败时,可以从数据库中获取到该任务并重新执行该任务,或者是,在节点出现故障时,通过数据库将其所需执行的任务转移至其他的节点上,以保证任务处理的可靠性。示例性的,目标任务的任务信息中可以包括任务类型和/或任务内容等。比如,当目标任务为创建虚拟机的任务时,目标任务的任务信息可以包括虚拟机中硬盘的大小、操作系统的类型、中央处理器的类型和参数、网络带宽等;当目标任务为支付款项的任务时,目标任务的任务信息可以包括所需支付的金额的数量等。Furthermore, after obtaining the target task, the node can store the task information of the target task in the database to complete the persistence of the target task, so that when it is known that the target task processing fails, the task can be obtained from the database and re-executed, or, when a node fails, the task to be executed is transferred to other nodes through the database to ensure the reliability of task processing. Exemplarily, the task information of the target task may include the task type and/or task content, etc. For example, when the target task is a task to create a virtual machine, the task information of the target task may include the size of the hard disk in the virtual machine, the type of operating system, the type and parameters of the central processing unit, the network bandwidth, etc.; when the target task is a task to pay money, the task information of the target task may include the amount of money to be paid, etc.
S603、执行目标任务,并获取目标任务的执行状态。S603: Execute the target task and obtain the execution status of the target task.
本实施例中,在将目标任务持久化到数据库中后,节点可以执行该目标任务,以及将该目标任务的执行状态存储至数据库中。示例性的,节点可以从数据库中获取到目标任务的执行状态,比如是执行成功,还是执行失败。当然,节点在执行完目标任务后,其自身也可以知道目标任务的执行状态,此时节点可以不用从数据库中再获取目标任务的执行状态。In this embodiment, after persisting the target task in the database, the node can execute the target task and store the execution status of the target task in the database. Exemplarily, the node can obtain the execution status of the target task from the database, such as whether the execution is successful or failed. Of course, after the node executes the target task, it can also know the execution status of the target task, and the node does not need to obtain the execution status of the target task from the database.
在一些实施例中,当API请求用于请求创建目标资源时,节点在执行目标任务时,可以创建目标资源。例如,当API请求用于请求创建虚拟机时,节点在执行目标任务时,可以创建虚拟机。In some embodiments, when the API request is used to request the creation of a target resource, the node can create the target resource when executing the target task. For example, when the API request is used to request the creation of a virtual machine, the node can create the virtual machine when executing the target task.
S604、当目标任务的执行状态为失败时,根据存储在数据库中的目标任务的任务信息,重新执行目标 任务。S604: When the execution status of the target task is failed, re-execute the target task according to the task information of the target task stored in the database. Task.
本实施例中,节点在获知到目标任务的执行状态为失败时,可以从数据库中重新获取到目标任务的任务信息,并重新执行该目标任务。在一些实施例中,当执行目标任务的次数达到预设次数,且最后一次的执行状态为失败,可以输出告警信息。由此以让用户获知到资源处理失败的情况,并进行人为修复。In this embodiment, when the node learns that the execution status of the target task is failed, it can re-acquire the task information of the target task from the database and re-execute the target task. In some embodiments, when the number of times the target task is executed reaches a preset number of times and the last execution status is failed, an alarm message can be output. This allows the user to learn about the failure of resource processing and perform manual repairs.
这样,节点在获取到API请求后,通过为该请求创建任务,并持久化到数据库中,从而在该任务处理失败时,可以从数据库中重新获取任务的任务信息,并重新执行,直至执行成功。由此,通过在数据库中增加重试自愈的数据(即为API请求创建的任务),使得节点在执行任务失败时,可以重试自愈,保证了节点返回的结果的正确性。In this way, after receiving the API request, the node creates a task for the request and persists it in the database. When the task fails to be processed, the task information of the task can be retrieved from the database and re-executed until it succeeds. Therefore, by adding retry self-healing data (i.e., the task created for the API request) in the database, the node can retry self-healing when the task fails to execute, ensuring the correctness of the result returned by the node.
在一些实施例中,节点在执行目标任务后,可以将其执行得到的目标任务的执行状态返回给用户,以使得用户获知到任务执行情况。In some embodiments, after executing the target task, the node may return the execution status of the target task obtained by executing it to the user, so that the user can be informed of the task execution status.
在一些实施例中,当节点为多个时,每个节点均可以向数据库中写入其自身的心跳信息。该心跳信息可以用于表征节点是否出现故障。每个节点均可以从数据库中获取到其他节点的心跳信息。当一个节点(以下简称“节点1”)获取到另一个节点(以下简称“节点2”)的心跳信息时,若判断出节点2出现故障,节点1则可以从数据库中获取由节点2创建且未执行或执行失败的M(M≥1)个任务的任务信息,以及,根据这M个任务的任务信息,执行这M个任务,并将M个任务中各个任务的执行结果均存储至数据库中。由此,以避免出现因节点故障而导致任务处理失败的情况,保证任务处理的可靠性。In some embodiments, when there are multiple nodes, each node can write its own heartbeat information into the database. The heartbeat information can be used to characterize whether a node fails. Each node can obtain the heartbeat information of other nodes from the database. When a node (hereinafter referred to as "node 1") obtains the heartbeat information of another node (hereinafter referred to as "node 2"), if it is determined that node 2 fails, node 1 can obtain the task information of M (M≥1) tasks created by node 2 and not executed or failed to execute from the database, and, according to the task information of these M tasks, execute these M tasks, and store the execution results of each task in the M tasks in the database. Thus, the situation of task processing failure caused by node failure is avoided, and the reliability of task processing is guaranteed.
进一步地,为避免任务被重复处理,针对M个任务中的任意一个待执行的任务,节点1在执行该任意一个待执行的任务之前,可以先确定数据库中存储的任意一个待执行的任务的执行状态为失败或者为未执行。Furthermore, to avoid repeated processing of tasks, for any task to be executed among the M tasks, before executing the task to be executed, node 1 may first determine whether the execution status of any task to be executed stored in the database is failed or not executed.
可以理解的是,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It is understandable that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
基于上述实施例中的方法,本申请实施例还提供了一种任务处理装置。Based on the method in the above embodiment, the embodiment of the present application also provides a task processing device.
示例性的,图7示出了一种任务处理装置。该资源处理装置可以但不限于部署于前述主主集群中的任意一个节点中。如图7所示,该任务处理装置700包括:请求获取模块701、任务创建模块702和任务处理模块703。其中,请求获取模块701用于获取用户发出的应用编程接口API请求。任务创建模块702用于根据API请求创建目标任务,将目标任务的任务信息存储至数据库中。任务处理模块703用于执行目标任务,并获取目标任务的执行状态;以及,当目标任务的执行状态为失败时,根据存储在数据库中的目标任务的任务信息,重新执行目标任务。示例性的,请求获取模块701可以但不限于为前述图2中的请求获取模块211,任务创建模块702可以但不限于为前述图2中的任务创建模块212,任务处理模块703可以但不限于为前述图2中的任务处理模块214。Exemplarily, FIG7 shows a task processing device. The resource processing device can be but is not limited to being deployed in any node in the aforementioned master-master cluster. As shown in FIG7, the task processing device 700 includes: a request acquisition module 701, a task creation module 702, and a task processing module 703. Among them, the request acquisition module 701 is used to obtain an application programming interface API request issued by a user. The task creation module 702 is used to create a target task according to the API request and store the task information of the target task in a database. The task processing module 703 is used to execute the target task and obtain the execution status of the target task; and when the execution status of the target task is failed, the target task is re-executed according to the task information of the target task stored in the database. Exemplarily, the request acquisition module 701 can be but is not limited to the request acquisition module 211 in FIG2, the task creation module 702 can be but is not limited to the task creation module 212 in FIG2, and the task processing module 703 can be but is not limited to the task processing module 214 in FIG2.
在一些实施例中,任务处理模块703在执行目标任务后还用于:将目标任务的执行状态存储至数据库中。其中,任务处理模块在获取目标任务的执行状态时,具体用于:从数据库中获取目标任务的执行状态。In some embodiments, after executing the target task, the task processing module 703 is further used to: store the execution status of the target task in a database. When acquiring the execution status of the target task, the task processing module is specifically used to: acquire the execution status of the target task from the database.
在一些实施例中,任务处理模块703还用于:从数据库中获取第二节点的心跳信息,心跳信息用于表征第二节点是否出现故障;当第二节点出现故障时,从数据库中获取由第二节点创建且未执行或执行失败的至少一个任务的任务信息;根据至少一个任务的任务信息,执行至少一个任务,以及,将至少一个任务中各个任务的执行状态均存储至数据库中。In some embodiments, the task processing module 703 is also used to: obtain heartbeat information of the second node from the database, the heartbeat information is used to characterize whether the second node fails; when the second node fails, obtain task information of at least one task created by the second node and not executed or failed to execute from the database; execute at least one task according to the task information of at least one task, and store the execution status of each task in the at least one task in the database.
在一些实施例中,任务处理模块703还用于:当执行目标任务的次数达到预设次数,且最后一次的执行状态为失败,输出告警信息。In some embodiments, the task processing module 703 is further used to: output an alarm message when the number of times the target task is executed reaches a preset number and the last execution status is failure.
在一些实施例中,当API请求用于请求创建目标资源时,任务处理模块703在执行目标任务时,具体用于:创建目标资源。In some embodiments, when the API request is used to request the creation of a target resource, the task processing module 703 is specifically used to create the target resource when executing the target task.
在一些实施例中,任务处理模块,还用于:向用户返回目标任务的执行状态。In some embodiments, the task processing module is further used to: return the execution status of the target task to the user.
在一些实施例中,请求获取模块701、任务创建模块702和任务处理模块703均可以通过软件实现,或者可以通过硬件实现。示例性的,接下来以请求获取模块701为例,介绍请求获取模块701的实现方式。类似的,任务创建模块702、任务处理模块703的实现方式可以参考请求获取模块701的实现方式。In some embodiments, the request acquisition module 701, the task creation module 702 and the task processing module 703 can all be implemented by software, or can be implemented by hardware. Exemplarily, the implementation of the request acquisition module 701 is described below by taking the request acquisition module 701 as an example. Similarly, the implementation of the task creation module 702 and the task processing module 703 can refer to the implementation of the request acquisition module 701.
模块作为软件功能单元的一种举例,请求获取模块701可以包括运行在计算实例上的代码。其中,计算实例可以包括物理主机(计算设备)、虚拟机、容器中的至少一种。进一步地,上述计算实例可以是一台或者多台。例如,请求获取模块701可以包括运行在多个主机/虚拟机/容器上的代码。需要说明的是, 用于运行该代码的多个主机/虚拟机/容器可以分布在相同的区域(region)中,也可以分布在不同的region中。进一步地,用于运行该代码的多个主机/虚拟机/容器可以分布在相同的可用区(availability zone,AZ)中,也可以分布在不同的AZ中,每个AZ包括一个数据中心或多个地理位置相近的数据中心。其中,通常一个region可以包括多个AZ。As an example of a software functional unit, the request acquisition module 701 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Furthermore, the computing instance may be one or more. For example, the request acquisition module 701 may include code running on multiple hosts/virtual machines/containers. It should be noted that Multiple hosts/virtual machines/containers for running the code can be distributed in the same region or in different regions. Furthermore, multiple hosts/virtual machines/containers for running the code can be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple geographically close data centers. Generally, one region can include multiple AZs.
同样,用于运行该代码的多个主机/虚拟机/容器可以分布在同一个虚拟私有云(virtual private cloud,VPC)中,也可以分布在多个VPC中。其中,通常一个VPC设置在一个region内,同一region内两个VPC之间,以及不同region的VPC之间跨区通信需在每个VPC内设置通信网关,经通信网关实现VPC之间的互连。Similarly, multiple hosts/virtual machines/containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.
模块作为硬件功能单元的一种举例,请求获取模块701可以包括至少一个计算设备,如服务器等。或者,请求获取模块701也可以是利用专用集成电路(application-specific integrated circuit,ASIC)实现、或可编程逻辑器件(programmable logic device,PLD)实现的设备等。其中,上述PLD可以是复杂程序逻辑器件(complex programmable logical device,CPLD)、现场可编程门阵列(field-programmable gate array,FPGA)、通用阵列逻辑(generic array logic,GAL)或其任意组合实现。As an example of a hardware functional unit, the request acquisition module 701 may include at least one computing device, such as a server, etc. Alternatively, the request acquisition module 701 may also be a device implemented by an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.
请求获取模块701包括的多个计算设备可以分布在相同的region中,也可以分布在不同的region中。获取模块1001包括的多个计算设备可以分布在相同的AZ中,也可以分布在不同的AZ中。同样,请求获取模块701包括的多个计算设备可以分布在同一个VPC中,也可以分布在多个VPC中。其中,所述多个计算设备可以是服务器、ASIC、PLD、CPLD、FPGA和GAL等计算设备的任意组合。The multiple computing devices included in the request acquisition module 701 can be distributed in the same region or in different regions. The multiple computing devices included in the acquisition module 1001 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the request acquisition module 701 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
需要说明的是,在其他实施例中,请求获取模块701可以用于执行前述任务处理方法中的任意步骤,任务创建模块702可以用于执行上述实施例提供的方法中的任意步骤,任务处理模块703可以用于执行上述实施例提供的方法中的任意步骤;请求获取模块701、任务创建模块702、任务处理模块703负责实现的步骤可根据需要指定,通过请求获取模块701、任务创建模块702、任务处理模块703分别实现上述实施例提供的方法中不同的步骤来实现任务处理装置700的全部功能。It should be noted that, in other embodiments, the request acquisition module 701 can be used to execute any step in the aforementioned task processing method, the task creation module 702 can be used to execute any step in the method provided by the above embodiments, and the task processing module 703 can be used to execute any step in the method provided by the above embodiments; the steps that the request acquisition module 701, the task creation module 702, and the task processing module 703 are responsible for implementing can be specified as needed, and all functions of the task processing device 700 are realized by respectively implementing different steps in the method provided by the above embodiments through the request acquisition module 701, the task creation module 702, and the task processing module 703.
本申请还提供一种计算设备800。如图8所示,计算设备800包括:总线802、处理器804、存储器806和通信接口808。处理器804、存储器806和通信接口808之间通过总线802通信。计算设备800可以是服务器或终端设备。应理解,本申请不限定计算设备800中的处理器、存储器的个数。The present application also provides a computing device 800. As shown in FIG8 , the computing device 800 includes: a bus 802, a processor 804, a memory 806, and a communication interface 808. The processor 804, the memory 806, and the communication interface 808 communicate with each other through the bus 802. The computing device 800 can be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in the computing device 800.
总线802可以是外设部件互连标准(peripheral component interconnect,PCI)总线或扩展工业标准结构(extended industry standard architecture,EISA)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,图8中仅用一条线表示,但并不表示仅有一根总线或一种类型的总线。总线804可包括在计算设备800各个部件(例如,存储器806、处理器804、通信接口808)之间传送信息的通路。The bus 802 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, FIG8 is represented by only one line, but does not mean that there is only one bus or one type of bus. The bus 804 may include a path for transmitting information between various components of the computing device 800 (e.g., the memory 806, the processor 804, and the communication interface 808).
处理器804可以包括中央处理器(central processing unit,CPU)、图形处理器(graphics processing unit,GPU)、微处理器(micro processor,MP)或者数字信号处理器(digital signal processor,DSP)等处理器中的任意一种或多种。Processor 804 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
存储器806可以包括易失性存储器(volatile memory),例如随机存取存储器(random access memory,RAM)。处理器104还可以包括非易失性存储器(non-volatile memory),例如只读存储器(read-only memory,ROM),快闪存储器,机械硬盘(hard disk drive,HDD)或固态硬盘(solid state drive,SSD)。The memory 806 may include a volatile memory, such as a random access memory (RAM). The processor 104 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
存储器806中存储有可执行的程序代码,处理器804执行该可执行的程序代码以分别实现前述请求获取模块701、任务创建模块702、任务处理模块703的功能,从而实现上述实施例中方法的全部或部分步骤。也即,存储器806上存有用于执行上述实施例方法中全部或部分步骤的指令。The memory 806 stores executable program codes, and the processor 804 executes the executable program codes to respectively implement the functions of the request acquisition module 701, the task creation module 702, and the task processing module 703, thereby implementing all or part of the steps of the method in the above embodiment. That is, the memory 806 stores instructions for executing all or part of the steps in the method in the above embodiment.
或者,存储器806中存储有可执行的代码,处理器804执行该可执行的代码以分别实现前述任务处理装置700的功能,从而实现上述实施例方法中全部或部分步骤。也即,存储器806上存有用于执行上述实施例方法中全部或部分步骤的指令。Alternatively, the memory 806 stores executable codes, and the processor 804 executes the executable codes to respectively implement the functions of the task processing device 700, thereby implementing all or part of the steps in the above-mentioned embodiment method. That is, the memory 806 stores instructions for executing all or part of the steps in the above-mentioned embodiment method.
通信接口803使用例如但不限于网络接口卡、收发器一类的收发模块,来实现计算设备800与其他设备或通信网络之间的通信。The communication interface 803 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 800 and other devices or communication networks.
本申请实施例还提供了一种计算设备集群。该计算设备集群包括至少一台计算设备。该计算设备可以是服务器,例如是中心服务器、边缘服务器,或者是本地数据中心中的本地服务器。在一些实施例中,计 算设备也可以是台式机、笔记本电脑或者智能手机等终端设备。The present application also provides a computing device cluster. The computing device cluster includes at least one computing device. The computing device may be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device cluster includes at least one computing device. The computing device can also be a terminal device such as a desktop computer, a laptop computer or a smart phone.
如图9所示,所述计算设备集群包括至少一个计算设备800。计算设备集群中的一个或多个计算设备800中的存储器806中可以存有相同的用于执行上述实施例方法中全部或部分步骤的指令。As shown in Fig. 9, the computing device cluster includes at least one computing device 800. The memory 806 in one or more computing devices 800 in the computing device cluster may store the same instructions for executing all or part of the steps in the above embodiment method.
在一些可能的实现方式中,该计算设备集群中的一个或多个计算设备800的存储器806中也可以分别存有用于执行上述实施例方法中全部或部分步骤的部分指令。换言之,一个或多个计算设备800的组合可以共同执行用于执行上述实施例方法中全部或部分步骤的指令。In some possible implementations, the memory 806 of one or more computing devices 800 in the computing device cluster may also store partial instructions for executing all or part of the steps in the above-mentioned embodiment method. In other words, the combination of one or more computing devices 800 may jointly execute instructions for executing all or part of the steps in the above-mentioned embodiment method.
需要说明的是,计算设备集群中的不同的计算设备800中的存储器806可以存储不同的指令,分别用于执行任务处理装置700的部分功能。也即,不同的计算设备800中的存储器806存储的指令可以实现前述请求获取模块701、任务创建模块702、任务处理模块703中的一个或多个模块的功能。It should be noted that the memory 806 in different computing devices 800 in the computing device cluster can store different instructions, which are respectively used to execute part of the functions of the task processing apparatus 700. That is, the instructions stored in the memory 806 in different computing devices 800 can implement the functions of one or more of the aforementioned request acquisition module 701, task creation module 702, and task processing module 703.
在一些可能的实现方式中,计算设备集群中的一个或多个计算设备可以通过网络连接。其中,所述网络可以是广域网或局域网等等。In some possible implementations, one or more computing devices in the computing device cluster may be connected via a network, which may be a wide area network or a local area network.
基于上述实施例中的方法,本申请实施例提供了节点。该节点可以包括:至少一个存储器,用于存储程序;至少一个处理器,用于执行存储器存储的程序。其中,当存储器存储的程序被执行时,处理器用于执行上述实施例中的方法。Based on the method in the above embodiment, the embodiment of the present application provides a node. The node may include: at least one memory for storing a program; and at least one processor for executing the program stored in the memory. When the program stored in the memory is executed, the processor is used to execute the method in the above embodiment.
基于上述实施例中的方法,本申请实施例提供了一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,当计算机程序在处理器上运行时,使得处理器执行上述实施例中的方法。Based on the method in the above embodiment, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program runs on a processor, the processor executes the method in the above embodiment.
基于上述实施例中的方法,本申请实施例提供了一种计算机程序产品,当计算机程序产品在处理器上运行时,使得处理器执行上述实施例中的方法。Based on the method in the above embodiment, an embodiment of the present application provides a computer program product. When the computer program product runs on a processor, the processor executes the method in the above embodiment.
可以理解的是,本申请的实施例中的处理器可以是中央处理单元(central processing unit,CPU),还可以是其他通用处理器、数字信号处理器(digital signal processor,DSP)、专用集成电路(application specific integrated circuit,ASIC)、现场可编程门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件、晶体管逻辑器件,硬件部件或者其任意组合。通用处理器可以是微处理器,也可以是任何常规的处理器。It is understood that the processor in the embodiments of the present application may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. The general-purpose processor may be a microprocessor or any conventional processor.
本申请的实施例中的方法步骤可以通过硬件的方式来实现,也可以由处理器执行软件指令的方式来实现。软件指令可以由相应的软件模块组成,软件模块可以被存放于随机存取存储器(random access memory,RAM)、闪存、只读存储器(read-only memory,ROM)、可编程只读存储器(programmable rom,PROM)、可擦除可编程只读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)、寄存器、硬盘、移动硬盘、CD-ROM或者本领域熟知的任何其它形式的存储介质中。一种示例性的存储介质耦合至处理器,从而使处理器能够从该存储介质读取信息,且可向该存储介质写入信息。当然,存储介质也可以是处理器的组成部分。处理器和存储介质可以位于ASIC中。The method steps in the embodiments of the present application can be implemented by hardware or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, which can be stored in random access memory (RAM), flash memory, read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, mobile hard disks, CD-ROMs, or any other form of storage medium known in the art. An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者通过所述计算机可读存储介质进行传输。所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘(solid state disk,SSD))等。In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state drive (SSD)), etc.
可以理解的是,在本申请的实施例中涉及的各种数字编号仅为描述方便进行的区分,并不用来限制本申请的实施例的范围。 It should be understood that the various numerical numbers involved in the embodiments of the present application are only used for the convenience of description and are not used to limit the scope of the embodiments of the present application.
Claims (16)
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202211463984.8A CN118093104A (en) | 2022-11-22 | 2022-11-22 | A task processing method, device and node |
| CN202211463984.8 | 2022-11-22 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2024109003A1 true WO2024109003A1 (en) | 2024-05-30 |
Family
ID=91158931
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2023/101285 Ceased WO2024109003A1 (en) | 2022-11-22 | 2023-06-20 | Task processing method and apparatus, and node |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN118093104A (en) |
| WO (1) | WO2024109003A1 (en) |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN118779081A (en) * | 2024-07-18 | 2024-10-15 | 湖南快乐阳光互动娱乐传媒有限公司 | Control method for retrying of distributed system, electronic device and distributed system |
| CN119127353A (en) * | 2024-11-08 | 2024-12-13 | 北京饼干科技有限公司 | Task processing method and device |
| CN120378774A (en) * | 2025-06-25 | 2025-07-25 | 杭州海兴电力科技股份有限公司 | Meter task configuration method and system |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119718722A (en) * | 2024-12-09 | 2025-03-28 | 浙江极氪智能科技有限公司 | Delayed task execution method, device, equipment, storage medium and product |
| CN119835270A (en) * | 2024-12-11 | 2025-04-15 | 中电信智能网络科技有限公司 | Task execution method and device, electronic equipment and nonvolatile storage medium |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106156198A (en) * | 2015-04-22 | 2016-11-23 | 阿里巴巴集团控股有限公司 | Task executing method based on distributed data base and device |
| CN108304255A (en) * | 2017-12-29 | 2018-07-20 | 北京城市网邻信息技术有限公司 | Distributed task dispatching method and device, electronic equipment and readable storage medium storing program for executing |
| CN108334545A (en) * | 2017-12-27 | 2018-07-27 | 微梦创科网络科技(中国)有限公司 | A kind of method and device for realizing asynchronous service |
| US10691558B1 (en) * | 2016-09-22 | 2020-06-23 | Amazon Technologies, Inc. | Fault tolerant data export using snapshots |
| US11138033B1 (en) * | 2018-08-24 | 2021-10-05 | Amazon Technologies, Inc. | Providing an application programming interface (API) including a bulk computing task operation |
| CN113515357A (en) * | 2021-04-20 | 2021-10-19 | 建信金融科技有限责任公司 | Batch task execution method and device in cluster environment |
-
2022
- 2022-11-22 CN CN202211463984.8A patent/CN118093104A/en active Pending
-
2023
- 2023-06-20 WO PCT/CN2023/101285 patent/WO2024109003A1/en not_active Ceased
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106156198A (en) * | 2015-04-22 | 2016-11-23 | 阿里巴巴集团控股有限公司 | Task executing method based on distributed data base and device |
| US10691558B1 (en) * | 2016-09-22 | 2020-06-23 | Amazon Technologies, Inc. | Fault tolerant data export using snapshots |
| CN108334545A (en) * | 2017-12-27 | 2018-07-27 | 微梦创科网络科技(中国)有限公司 | A kind of method and device for realizing asynchronous service |
| CN108304255A (en) * | 2017-12-29 | 2018-07-20 | 北京城市网邻信息技术有限公司 | Distributed task dispatching method and device, electronic equipment and readable storage medium storing program for executing |
| US11138033B1 (en) * | 2018-08-24 | 2021-10-05 | Amazon Technologies, Inc. | Providing an application programming interface (API) including a bulk computing task operation |
| CN113515357A (en) * | 2021-04-20 | 2021-10-19 | 建信金融科技有限责任公司 | Batch task execution method and device in cluster environment |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN118779081A (en) * | 2024-07-18 | 2024-10-15 | 湖南快乐阳光互动娱乐传媒有限公司 | Control method for retrying of distributed system, electronic device and distributed system |
| CN119127353A (en) * | 2024-11-08 | 2024-12-13 | 北京饼干科技有限公司 | Task processing method and device |
| CN120378774A (en) * | 2025-06-25 | 2025-07-25 | 杭州海兴电力科技股份有限公司 | Meter task configuration method and system |
Also Published As
| Publication number | Publication date |
|---|---|
| CN118093104A (en) | 2024-05-28 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2024109003A1 (en) | Task processing method and apparatus, and node | |
| KR102510195B1 (en) | Transaction Processing Methods, Devices and Appliances, and Computer Storage Media | |
| US11321303B2 (en) | Conflict resolution for multi-master distributed databases | |
| CN107766080B (en) | Transaction message processing method, device, equipment and system | |
| KR102121157B1 (en) | Use of nonce table to solve concurrent blockchain transaction failure | |
| CN111752961A (en) | A data processing method and device | |
| US11741081B2 (en) | Method and system for data handling | |
| CN115408411A (en) | Data writing method and device, electronic equipment and storage medium | |
| CN112162988A (en) | Distributed transaction processing method and device and electronic equipment | |
| CN113077241B (en) | Approval processing method, device, equipment and storage medium | |
| US11522966B2 (en) | Methods, devices and systems for non-disruptive upgrades to a replicated state machine in a distributed computing environment | |
| CN110008225A (en) | The treating method and apparatus of distributed transaction | |
| CN112559496B (en) | Method and device for realizing transaction atomicity of distributed database | |
| EP4682734A1 (en) | Database system and data management method therefor | |
| EP4553680A1 (en) | Transaction processing method and apparatus, and node and computer-readable storage medium | |
| KR20230017329A (en) | Method of responding to operation, apparatus of responding to operation, electronic device, storage medium, and computer program | |
| CN116204291A (en) | Task processing method, device, computer equipment and storage medium | |
| US20260099485A1 (en) | Transaction Processing Method and Cloud-Native Database System | |
| CN116069789A (en) | A data query method, device and computer-readable storage medium | |
| CN120950735B (en) | Lock execution methods, devices, equipment, and media based on transactional key-value databases | |
| US20250200025A1 (en) | Systems and methods for zero downtime distributed search system updates | |
| CN114255004B (en) | Transaction processing method, device, equipment and storage medium | |
| US11442668B2 (en) | Prioritizing volume accesses in multi-volume storage device based on execution path of a service | |
| CN119621698A (en) | A metadata maintenance method, database cluster, program product and medium | |
| CN121542523A (en) | Parameter caching concurrent request management methods, systems, electronic devices, and storage media |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 23893103 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 23893103 Country of ref document: EP Kind code of ref document: A1 |