Task scheduling method and scheduling system
By introducing flexible and dynamic addition of scheduling nodes and client nodes in the cloud platform, and adopting distributed storage and dynamic load balancing technologies, the high cost and lack of scalability of existing technologies are solved, and an efficient and low-cost scheduling system is achieved.
Patent Information
- Application Number
- CN202211468893.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-22
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2042-11-22
AI Technical Summary
Existing cloud platforms require high-performance, high-cost servers for large-scale scheduled tasks, resulting in high costs and an inability to dynamically scale up the system during operation, leading to slow scheduling speeds.
By introducing flexible and dynamic addition of scheduling nodes or client nodes between the client cluster and the scheduling cluster, and by adopting distributed storage triggers and dynamic load balancing technology, the dependence on high-performance servers is reduced, and decentralized management and dynamic scaling are achieved.
It reduces reliance on high-performance servers, improves the throughput and availability of the scheduling system, reduces costs, and enables runtime scalability.
Smart Images

Figure CN115865945B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of distributed cluster, and particularly relate to a task scheduling method and a scheduling system. BACKGROUND
[0002] Cloud computing is an inevitable trend of future information technology development. Cloud service providers deploy cloud services on a cloud platform, and tenants use cloud services through the Internet. Cloud services include computing power, storage capacity, and the like.
[0003] Generally, in order to ensure the smooth running of the cloud platform, the cloud platform often has a monitoring and alarming capability. For example, when the memory occupancy rate of a business server in the cloud platform is too high, an alarm will be issued. The basis of the alarm function is a timing task. The operation and maintenance personnel pre-create some timing tasks, and the timing tasks monitor the cloud platform after being triggered.
[0004] The existing cloud platform uses a centralized scheduling manner to schedule timing tasks. For large-scale timing scheduling tasks, a high-performance and expensive server needs to be used, which is high in cost. SUMMARY
[0005] Embodiments of the present application provide a task scheduling method and a scheduling system, which add scheduling nodes or client nodes dynamically, reduce the dependence on high-performance and expensive servers, and reduce the cost.
[0006] In a first aspect, embodiments of the present application provide a task scheduling method applied to a first client node, and the method comprises:
[0007] receiving a first creation request from a user device, the first creation request being used to request to create a scheduling task, and the first client node being any one of client nodes in a client cluster;
[0008] determining a target scheduling node from a scheduling cluster according to a first root directory, a first temporary node under the first root directory being used to store basic information of scheduling nodes in the scheduling cluster;
[0009] generating the scheduling task according to the first creation request;
[0010] sending a second creation request to the target scheduling node, so that the target scheduling node generates a trigger for the scheduling task, and the trigger is used to indicate a triggering condition of the scheduling task.
[0011] In a second aspect, embodiments of the present application provide a task scheduling method applied to a target scheduling node, and the method comprises:
[0012] receiving a second creation request from a first client node, the second creation request being used to request generating a trigger for a scheduling task, the trigger being used to indicate a trigger condition of the scheduling task, the first client node being any one of client nodes in a client cluster, and the target scheduling node being a scheduling node selected by the first client node from a scheduling cluster;
[0013] generating the trigger according to the second creation request;
[0014] determining a second client node from the client cluster according to a second root directory when the trigger condition is met, a second temporary node under the second root directory being used to store basic information of client nodes in the client cluster;
[0015] sending a callback request to the second client node, so that the second client node executes the scheduling task.
[0016] In a third aspect, an embodiment of the present application provides a task scheduling method, applied to a coordination node, and the method comprises the following steps.
[0017] receiving a first online request from a first client node, the first online request carrying basic information of the first client node;
[0018] sending a first root directory to the first client node, so that the first client node determines a target scheduling node from a scheduling cluster according to the first root directory after receiving a first creation request, the first creation request being used to request creating a scheduling task, the first client node being any one of client nodes in a client cluster, and a first temporary node under the first root directory being used to store basic information of scheduling nodes in the scheduling cluster;
[0019] receiving a second online request from the target scheduling node, the second online request carrying basic information of the target scheduling node;
[0020] sending the first root directory and a second root directory to the target scheduling node, so that the target scheduling node selects a second client node from a client cluster according to the second root directory and triggers the second client node to execute a scheduling task corresponding to a trigger in a database managed by the target scheduling node when the trigger meets a trigger condition, a second temporary node under the second root directory being used to store basic information of client nodes in the client cluster.
[0021] In a fourth aspect, an embodiment of the present application provides a task scheduling system, comprising:
[0022] a client cluster comprising at least one client node configured to perform the method according to the first aspect or any of the possible implementation forms of the first aspect;
[0023] a scheduling cluster comprising at least one scheduling node configured to perform the method according to the second aspect or any of the possible implementation forms of the second aspect;
[0024] a coordination cluster comprising at least one coordination node configured to perform the method according to the third aspect or any of the possible implementation forms of the third aspect.
[0025] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to enable the electronic device to implement the method according to the first aspect or any of the possible implementation forms of the first aspect; or the processor executes the computer program to enable the electronic device to implement the method according to the second aspect or any of the possible implementation forms of the second aspect; or the processor executes the computer program to enable the electronic device to implement the method according to the third aspect or any of the possible implementation forms of the third aspect.
[0026] In a sixth aspect, an embodiment of the present application provides a computer readable storage medium, wherein the computer readable storage medium stores computer instructions, and the computer instructions are configured to implement the method according to the first aspect or any of the possible implementation forms of the first aspect when executed by a processor; or the computer instructions are configured to implement the method according to the second aspect or any of the possible implementation forms of the second aspect when executed by a processor; or the computer instructions are configured to implement the method according to the third aspect or any of the possible implementation forms of the third aspect when executed by a processor.
[0027] In a seventh aspect, an embodiment of the present application provides a computer program product comprising a computer program, wherein the computer program is configured to implement the method according to the first aspect or any of the possible implementation forms of the first aspect when executed by a processor; or the computer program is configured to implement the method according to the second aspect or any of the possible implementation forms of the second aspect when executed by a processor; or the computer program is configured to implement the method according to the third aspect or any of the possible implementation forms of the third aspect when executed by a processor.
[0028] The task scheduling method and the scheduling system provided by the embodiments of the present application, after the first client node in the client cluster receives the first creation request, the first client node generates a scheduling task and determines a target scheduling node from the scheduling cluster and sends a second creation request, the target scheduling cluster generates a trigger for the scheduling task. When the trigger meets the trigger condition, the target scheduling node determines a second client node from the client cluster, and the second client node executes the scheduling task. By using the scheme, the target scheduling node can be a newly added node in the scheduling cluster, and the second client node can be a newly added client node in the client cluster, so that the decentralized management is realized, and the runtime dynamic expansion is achieved. The throughput rate and the high availability of the scheduling system are improved by adding low-performance client nodes or scheduling nodes, the dependence on the high-cost server is reduced, the cost is low, and the runtime expansibility is high. BRIEF DESCRIPTION OF DRAWINGS
[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0030] Figure 1 is a network architecture schematic diagram of the scheduling system provided by the embodiments of the present application;
[0031] Figure 2 is a flowchart of the task scheduling method provided by the embodiments of the present application;
[0032] Figure 3A is an interface schematic diagram of managing the scheduling task in the scheduling method provided by the embodiments of the present application;
[0033] Figure 3B is another interface schematic diagram of managing the scheduling task in the scheduling method provided by the embodiments of the present application;
[0034] Figure 3C is still another interface schematic diagram of managing the scheduling task in the scheduling method provided by the embodiments of the present application
[0035] Figure 4 is another flowchart of the scheduling method provided by the embodiments of the present application;
[0036] Figure 5 is still another flowchart of the scheduling method provided by the embodiments of the present application;
[0037] Figure 6 is a schematic diagram of a task scheduling device provided by the embodiments of the present application;
[0038] Figure 7Another schematic diagram of a task scheduling device provided by an embodiment of the present application is shown in FIG. 3.
[0039] Figure 8 Another schematic diagram of a task scheduling device provided by an embodiment of the present application is shown in FIG. 3.
[0040] Figure 9 A structural schematic diagram of an electronic device provided by an embodiment of the present application is shown in FIG. 4. DETAILED DESCRIPTION
[0041] To make the objectives, technical solutions and advantages of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.
[0042] With the continuous development of cloud technology, major cloud vendors are constantly enhancing their capabilities, especially the operation and maintenance capabilities. For a cloud platform with a large variety of products, by unifying the data of each product, and then making it easier for users to operate the products they are interested in through a visual way, the operation and maintenance efficiency can be improved.
[0043] The monitoring and alarm capability is the most basic capability in the operation and maintenance capability. Most monitoring and alarm capabilities are implemented through scheduled tasks. Currently, each cloud platform often schedules scheduled tasks through a server. When there are more and more scheduled tasks, the scheduling speed becomes slower and slower.
[0044] A common solution is to replace or upgrade the server, so as to deploy the program of the scheduling center by using a server with higher performance and a higher price. This solution has a high cost. Moreover, if the server needs to be upgraded and expanded to support large-scale scheduled tasks, the server needs to be frequently shut down to be upgraded. Obviously, the existing scheduling method cannot dynamically expand the system during the system operation, and the performance of the system during the operation is poor.
[0045] Therefore, an embodiment of the present application provides a task scheduling method and a scheduling system. By dynamically adding scheduling nodes or client nodes, the dependence on high-performance servers is reduced, and the cost is reduced.
[0046] Figure 1 A network architecture schematic diagram of a scheduling system provided by an embodiment of the present application is shown in FIG. 1. The scheduling system is, for example, a monitoring and alarm system of a cloud product, a monitoring and alarm support system of an internal operation and maintenance system, etc., and can provide dynamic monitoring functions for a variety of cloud products. Please refer to Figure 1The network architecture comprises a client cluster, a scheduling cluster and a coordination cluster, the client cluster contains at least one client node 11, the scheduling cluster contains at least one scheduling node 12, the coordination cluster contains at least one coordination node 13, each scheduling node 12 has a database 14 for storing triggers created by the scheduling node 12 and the like. Network connection is established between the client cluster and the scheduling cluster, network connection is established between the client cluster and the coordination cluster, and network connection is established between the scheduling cluster and the coordination cluster.
[0047] The network architecture further comprises a service cluster containing at least one service server 15, and index data of the service server 15 is stored in a database 16. A user initiates a first creation request through a user device 17 to request creation of a scheduling task, for example, a timing task, an alarm task and the like, and embodiments of the present application are not limited. After the reverse proxy server 18 receives the first creation request, a client node 11 (hereinafter referred to as a first client node) is selected from the client cluster based on load balancing technology, the client node 11 generates a scheduling task, selects a target scheduling node from the scheduling cluster and sends a second creation request. After the target scheduling node receives the second creation request, a trigger is created for the scheduling task, and the trigger is stored in the database 14. When the trigger meets the triggering condition, the target scheduling node selects a second client node from the client cluster, and the second client node executes the scheduling task. During execution, the second client node pulls data from the database 16 and judges whether an alarm is needed or not. If an alarm is needed, the mail server 19 is triggered to send an alarm email to the relevant party, such as the user device 10.
[0048] Please refer to Figure 1 The client node 11 in the client cluster and the scheduling node 12 in the scheduling cluster are equivalent to the client and the server in the C / S architecture respectively. Hereinafter, unless otherwise specified, the client refers to the client node 11 and the server refers to the scheduling node 12.
[0049] Since the client is integrated in the business system, the system places a large amount of logic in the server to achieve the purpose of upgrading the server as much as possible when the function changes, rather than frequently upgrading the client, thereby avoiding instability of the platform caused by frequent business updates. The client and the server interact through a specific Transmission Control Protocol (TCP), and different protocols represent different commands. The protocols include a distributed alarm scheduling node management protocol, an alarm scheduling task distribution protocol, an alarm scheduling task high availability guarantee protocol, an alarm task management protocol and an alarm task scheduling protocol and the like.
[0050] The client node 11 mainly listens to the information change of each scheduling node 12, so as to better use the information of the scheduling node 12 for load balancing, that is, after receiving the first creation request, selecting which scheduling node as the target scheduling node from the scheduling cluster. The client node 11 also records the target scheduling node corresponding to the scheduling task, that is, the scheduling node generating the trigger for the scheduling task. At the same time, the client node 11 also sends its basic information, such as IP address and port number, to the coordination node 13, so that the scheduling node 12 selects the second client node from the client cluster when the trigger meets the condition.
[0051] In the embodiment of the application, each client cluster has a globally unique group name, and the client nodes 11 in the client cluster are used to generate scheduling tasks, generate and deliver alarm emails, manage alarm rules of the client cluster, etc. When a scheduling task needs to be executed, the database 16 is queried according to the alarm rule to determine whether an alarm is generated and whether an alarm email is sent, etc. The client node 11 is equivalent to the client of the scheduling node 12, and is specially responsible for processing the analysis of the scheduling task and the subsequent operation after the alarm, such as sending an email, etc.
[0052] A scheduling cluster includes multiple scheduling nodes 12, and each scheduling node 12 has a respective database 14 for storing triggers created by the scheduling node 12, etc. The scheduling node 12 is responsible for functions such as storage, triggering, forwarding, updating of its own information, cluster composition, and scheduling high availability of the trigger. In addition, the scheduling node 12 is also responsible for performing add, delete, modify, and query operations on the triggers in the database. When a scheduling node 12 is offline, such as being down, etc., other scheduling nodes 12 temporarily take over the database 14 of the offline scheduling node. That is, the takeover node not only manages its own database, but also manages the database of the offline scheduling node. The management includes modifying, deleting, and querying the trigger, etc. When the offline scheduling node recovers, that is, when it is online again, it continues to manage its own database 14.
[0053] The scheduling node 12 pushes the IP address, port number, and database connection, etc. basic information to the coordination node 13 after each online. At the same time, the scheduling cluster 12 also pulls and listens to the basic information of the client node, such as the IP address, port number, etc. An important function of the scheduling node 12 is load balancing: when the trigger in the database 14 corresponding to itself or the database 14 taken over meets the triggering condition, a second client node is selected from the client cluster, and the selected second client node can be a newly added client node in the client cluster, so that the throughput of the system can be improved by dynamically adding the client node 11.
[0054] The client node 11 and the scheduling node 12 interact by using a TCP protocol. The TCP protocol mainly includes a control protocol and a callback protocol. The control protocol is mainly used for the client node 11 to send a second creation request to the scheduling node 12 to add a trigger, or to send an editing instruction to delete, modify or query a trigger. The callback protocol is mainly used for the scheduling node 12 to inform the client node 11 of a scheduling task to be performed.
[0055] The coordination node 13 mainly performs distributed coordination. The coordination node 13 has three root directories, namely a first root directory, a second root directory and a third root directory. The first root directory stores basic information of the scheduling nodes. After the scheduling node 12 is online, the coordination node 13 establishes a temporary folder (also referred to as a first temporary node) under the first root directory. The first temporary node stores the IP address, port number, identifier of the connected database 14 and other basic information of the scheduling node 12. Different first temporary nodes correspond to different scheduling nodes 12. After each scheduling node 12 is offline, the coordination node 13 deletes the first temporary node corresponding to the offline scheduling node 12 from the first root directory.
[0056] After each client node is online, the coordination node 13 establishes a temporary folder (also referred to as a second temporary node) under the second root directory. The second temporary node stores the IP address, port number and other basic information of the client node 11. Different subdirectories correspond to different client nodes 11. After each client node 11 is offline, the coordination node deletes the second temporary node corresponding to the offline client node 11 from the second root directory.
[0057] Whenever the content of the first root directory changes, such as adding or deleting a first temporary node, a first notification is sent to each client node in the client cluster and each scheduling node in the scheduling cluster, so as to facilitate the client nodes 11 and the scheduling nodes 12 to update the first root directory in time. Similarly, whenever the content of the second root directory changes, such as adding or deleting a second temporary node, a third notification is sent to each scheduling node 12 in the scheduling cluster. In this way, the scheduling nodes 12 can know the status of the scheduling cluster in time, update the second root directory in time, and take corresponding measures in time.
[0058] After a scheduling node 12 is offline, if the database 14 of the scheduling node 12 is taken over by another scheduling node, the coordination node creates a third temporary node under the third root directory, which is used to store the identifier of the taking-over node, the identifier of the offline scheduling node, the basic information of the taking-over node, the basic information of the offline scheduling node and the like.
[0059] The business server 15 is a server providing cloud services, and the timing task is, for example, monitoring the memory occupancy of a certain business server 15. The business server 15 is responsible for generating monitoring data and storing the monitoring data in the monitoring database 16. For example, the CPU occupancy, bandwidth, etc. of the business server 15.
[0060] The reverse proxy server 18 is used to ensure the high availability of the scheduling system, and performs load balancing on the first creation request from the user device 17, such as a Hyper Text Transfer Protocol (HTTP) request. When a large number of user devices 17 send first creation requests to the reverse proxy server 18, the reverse proxy server 18 uses a load balancing technique to select a client node from the client cluster and send the first creation request to the client node.
[0061] The mail server 19 is used to send and receive alarm emails, etc. When the client node 11 executes a scheduling task, if the alarm condition is met, an alarm email is sent to the user device 10. The user device 10 is the user device of the user indicated by the scheduling task. When the user device 17 sends a first creation request to the client node 11, the client node 11 generates a scheduling task and determines the user who needs to receive the alarm email.
[0062] The scheduling system provided by the embodiments of the present application improves the disadvantage that a centralized scheduling needs to use an expensive server for scheduling by distributing the triggers in the scheduling nodes of the scheduling cluster and using a dynamic load balancing technique to more reasonably select a target scheduling node for creating a trigger from the scheduling cluster and select a client node for executing a scheduling task from the client cluster. The user can online or offline the scheduling nodes and the client nodes according to the needs, and does not have to be forced to be a certain type of scheduling node and client node. In addition, by setting the coordination node, the scheduling node can dynamically discover the online or offline client nodes or scheduling nodes, and the client node can dynamically discover the online or offline scheduling nodes, so that the client nodes or scheduling nodes can be flexibly added, thereby improving the throughput of the scheduling system.
[0063] In addition, the client node 11 and the scheduling node 12 correspond to the client and the server, respectively, so that the processing of the scheduling service and the scheduling are separated, and when the client cluster cannot handle, only the client node needs to be added, and when the scheduling cluster cannot handle, only the scheduling node needs to be added. Based on the dynamic discovery function of the coordination node, the client node or the scheduling node can be dynamically added without frequent downtime expansion. At the same time, the scheduling system also provides a visual interface for operation and maintenance analysis, so as to determine when to add the scheduling node or the client node to support the current business volume.
[0064] Below, based on the network architecture shown in Figure 1 The scheduling method described in the embodiments of the present application is described in detail below. For example, refer to the network architecture shown in Figure 2 , Figure 2 is a flowchart of the task scheduling method provided by the embodiments of the present application, and the present embodiment is described from the perspective of the interaction between the first client node and the target scheduling node. The present embodiment includes the following steps:
[0065] 201. The first client node receives a first creation request.
[0066] The first creation request is used to request the creation of a scheduling task.
[0067] For example, the user equipment sends a first creation request to the reverse proxy server, and the reverse proxy server selects a first client node from the client cluster and sends the first creation request; correspondingly, the first client node receives the first creation request.
[0068] 202. A target scheduling node is determined from the scheduling cluster according to a first root directory.
[0069] The first temporary node under the first root directory is used to store the basic information of the scheduling nodes in the scheduling cluster.
[0070] The first client node pre-pulls the first root directory from the coordination node and stores it. After receiving the first creation request, the first client node determines a target scheduling node from the scheduling cluster according to the first root directory. For example, each first temporary node under the first root directory indicates at least the number of triggers that have been created for the corresponding scheduling node. The larger the number of triggers, the heavier the load of the scheduling node. The first client node selects the scheduling node with the smallest number of triggers as the target scheduling node. Obviously, if a new scheduling node is added to the scheduling cluster, it is likely to be selected as the target scheduling node.
[0071] 203. The first client node generates the scheduling task according to the first creation request.
[0072] In the embodiments of the present application, the scheduling task is, for example, a timing task or the like, and the timing task is also called an alarm task. One scheduling task corresponds to one trigger, and after the trigger meets the triggering condition, the scheduling node determines a second client node from the client cluster, and the second client node executes the scheduling task. The second client node and the first client node can be the same client node or different client nodes.
[0073] The first client node generates a scheduling task and sends a second creation request to the target scheduling node. The scheduling task is, for example, a file in json format or the like, and embodiments of the present application are not limited thereto. The scheduling task is equivalent to a rule. For example, the scheduling task specifies which data in the database 16 is to be pulled by the second client node, under what conditions the data meets, when an alarm is to be issued, which user equipment 10 is to be notified when the alarm is issued, and the like.
[0074] 204. The first client node sends a second creation request to the target scheduling node.
[0075] Correspondingly, the target scheduling node receives the second creation request. The second creation request carries a task identifier of the scheduling task and a cluster identifier of the client cluster in which the first client node is located. The format of the second creation request is shown in Table 1, for example.
[0076] Table 1
[0077] Place description Protocol header Protocol version Instruction type Content type Content length Content Check code Length 2 bytes 4 bytes 4 bytes 4 bytes 16 bytes 2 bytes Value 0xED 0x01 0x01 - add, 0x02 - delete, 0x03 - modify 0x01 - json format Calculated according to the content area Content such as parameters in json format Use the redundancy cyclic code to check whether the content is wrong in transmission
[0078] For example, when a new scheduling task is created, the value of the instruction type of the second creation request is 0X01, indicating that a new trigger is added.
[0079] Referring to Table 1, the length of the entire protocol package is a multiple of 8, and the byte length of the entire protocol package is the sum of the lengths of the placeholder description, the protocol header, the protocol version, the instruction type, the content type, the content length, the content, and the check code. When the sum of the lengths of these areas is not a multiple of 8, a space symbol is added in the content area to make the byte length of the entire protocol package a multiple of 8.
[0080] 205. The target scheduling node generates the trigger according to the second creation request.
[0081] The trigger is used to indicate the triggering occasion of the scheduling task and the like. After the target scheduling node generates the trigger, the target scheduling node stores the trigger in a corresponding database of the target scheduling node. At the same time, the target scheduling node stores the correspondence between the trigger, the task identifier, and the cluster identifier.
[0082] 206. The target scheduling node determines a second client node from the client cluster according to a second root directory. A second temporary node under the second root directory is used to store basic information of the client nodes in the client cluster.
[0083] The target scheduling node monitors each trigger in the database of the target scheduling node. Once a trigger meets a triggering condition, the target scheduling node determines a client cluster according to the cluster identifier, and then selects a second client node from the client cluster according to a second root directory. The second client node is, for example, a client node with the smallest load.
[0084] The target cluster can dynamically add or delete a client node. A newly added client node is usually a node with the smallest load. Therefore, the second client node selected by the target scheduling node is likely to be a newly added client node in the client cluster.
[0085] 207. The target scheduling node sends a callback request to the second client node.
[0086] Correspondingly, the second client node receives the callback request from the target scheduling node. The callback request carries a task identifier.
[0087] The first client node and the second client node can be the same client node or different client nodes. The format of the callback request is shown in Table 2, for example.
[0088] Table 2
[0089] Place description Protocol header Protocol version Instruction type Content type Content length Content Check code Length 2 bytes 2 bytes 1 byte 1 byte 16 bytes 2 bytes Value 0xED 0x01 0x01 - trigger 0x01 - string Calculated according to the content Identifier of the rule Redundancy cyclic code
[0090] For example, when a scheduling task is triggered, the value of the instruction type of the callback request is 0X01, indicating that the client node needs to execute the scheduling task.
[0091] 208. The second client node executes the scheduling task.
[0092] In step 203, the first client node generates a scheduling task. Since each client node in the client cluster shares data, the second client node can obtain the scheduling task and pull data from the database 16, analyze the data, etc. according to the requirements of the scheduling task.
[0093] The scheduling method provided by the embodiment of the application, after the first client node in the client cluster receives the first creation request, generates a scheduling task, determines a target scheduling node from the scheduling cluster and sends a second creation request at the same time, and the target scheduling cluster generates a trigger for the scheduling task. When the trigger meets the triggering condition, the target scheduling node determines a second client node from the client cluster, and the second client node executes the scheduling task. With this scheme, the target scheduling node can be a newly added node in the scheduling cluster, and the second client node can be a newly added client node in the client cluster, realizing decentralized management and runtime dynamic expansion. By adding low-performance client nodes or scheduling nodes, the throughput and high availability of the scheduling system are improved, the dependence on high-cost servers is reduced, the cost is low, and the runtime expansibility is high.
[0094] Optionally, in the above embodiment, when the first client node is online, the first client node sends a first online request to the coordination node to make the coordination node update a second root directory, a second temporary node under the second root directory is used to store basic information of client nodes in the client cluster, and the first online request carries the basic information of the first client node. Then, the coordination node sends the first root directory to the first client node; correspondingly, the first client node receives the first root directory from the coordination node.
[0095] In the embodiment of the application, when the first client node is online, i.e., joins the client cluster, the first client node sends a first online request to the coordination node, the first online request carrying the IP address, port number and the like of the first client node. After receiving the first online request, the coordination node establishes a second temporary node under the second root directory, the second temporary node storing the IP address, port number and the like of the first client node 11. Then, the first client node pulls the first root directory from the coordination node, and in the pulling process, the coordination node sends the first root directory to the first client node, so that the first client node receives the first creation request and determines the target scheduling node from the scheduling cluster according to the first root directory.
[0096] In addition, whenever a new online or offline client node appears in the client cluster, the coordination node also sends a third notification to each scheduling node in the scheduling cluster, the third notification being used to indicate that a new online or offline client node appears in the client cluster. After receiving the third notification, the scheduling node updates the second root directory, so as to facilitate the scheduling node to accurately determine the second client node for executing the scheduling task from the client cluster subsequently.
[0097] With this scheme, whenever a client node is online, the newly online client node can pull the first root directory from the coordination node, and subsequently selects the target scheduling node for creating the trigger according to the first root directory, so as to achieve the purpose of accurately determining the target scheduling node.
[0098] Similarly, when any one of the scheduling nodes in the scheduling cluster is online, taking the online of a target scheduling node as an example, a second online request is sent to the coordination node, and the second online request carries basic information of the target scheduling node, such as an IP address, a port number, and an identifier of a connected database. After receiving the second online request, the coordination node establishes a first temporary node under the first root directory, and the first temporary node stores the basic information of the target scheduling node, such as the IP address and the port number. Then, the target scheduling node pulls the first root directory and the second root directory from the coordination node. During the pulling process, the coordination node sends the second root directory to the target scheduling node, so that when a trigger in a database managed by the target scheduling node meets a trigger condition, the target scheduling node determines a second client node from the client cluster according to the second root directory. In addition, after the target scheduling node is online, the coordination node also sends the first root directory to the target scheduling node, so that the target scheduling node determines an offline scheduling node in the scheduling cluster in a timely manner and preoccupies the distributed lock.
[0099] With this scheme, whenever a scheduling node is online, the newly online scheduling node can pull the first root directory and the second root directory from the coordination node, and subsequently select a second client node to execute a scheduling task according to the second root directory, thereby achieving the purpose of accurately determining the second client node, and achieving the purpose of monitoring an offline scheduling node in the scheduling cluster in a timely manner and preoccupying the distributed lock.
[0100] Optionally, in the above embodiment, the first client node also receives a first notification from the coordination node, and the first notification is used to indicate that a scheduling node is added or deleted in the scheduling cluster. When the first notification indicates that a scheduling node is added in the scheduling cluster, a first temporary node corresponding to the added scheduling node is added under the first root directory; and when the first notification indicates that a scheduling node is offline in the scheduling cluster, a first temporary node corresponding to the offline scheduling node is deleted from the first root directory.
[0101] In the embodiment of the application, after the first client node is online and pulls the first root directory, the first client node also listens to online events and offline events of the scheduling nodes. When a new online scheduling node or an offline scheduling node appears in the scheduling cluster, the coordination node sends a first notification to each client node in the client cluster and each online scheduling node in the scheduling cluster. The first client node updates the first root directory according to the first notification. For example, when a new scheduling node is added in the scheduling cluster, the first client node adds a first temporary node corresponding to the added scheduling node under the first root directory, and the first temporary node is used to store an IP address of the added scheduling node, a number of triggers, and the like. For another example, when an offline scheduling node appears in the scheduling cluster, the first client node deletes a first temporary node corresponding to the offline scheduling node from the first root directory.
[0102] With the scheme, the client nodes in the client cluster update the first root directory by listening to the online and offline events of the scheduling nodes, thereby accurately determining the target scheduling node.
[0103] Similarly, in the above embodiment, after the target scheduling node is online and pulls the first root directory and the second root directory, the target scheduling node further receives a first notification to listen to the online and offline events of the scheduling nodes, and receives a third notification to listen to the online and offline events of the client nodes. When the first notification indicates that a new scheduling node is added to the scheduling cluster, a first temporary node corresponding to the new scheduling node is added under the first root directory; when the first notification indicates that an offline scheduling node in the scheduling cluster, the first temporary node corresponding to the offline scheduling node is deleted under the first root directory.
[0104] When the third notification indicates that a new client node is added to the client cluster, a second temporary node corresponding to the new client node is added under the second root directory; when the third notification indicates that an offline client node in the client cluster, the second temporary node corresponding to the offline client node is deleted under the second root directory.
[0105] With the scheme, the scheduling nodes in the scheduling cluster update the first root directory by listening to the online and offline events of the scheduling nodes, thereby accurately determining the offline scheduling node and preempting the distributed lock; by listening to the online and offline events of the client nodes, the second client node that executes the scheduling task is accurately determined.
[0106] Optionally, in the above embodiment, each scheduling node in the scheduling cluster preempts the distributed lock of the offline scheduling node to take over the database of the offline scheduling node. Taking the target scheduling node as an example, when the first notification indicates that an offline scheduling node in the scheduling cluster, a preemption request is sent to the coordination node to preempt the distributed lock of the offline scheduling node. Then, a preemption response from the coordination node is received. When the preemption response indicates that the target scheduling node successfully preempts the distributed lock, a takeover thread is created to take over the database of the offline scheduling node; when the offline scheduling node is online again, the distributed lock is released, so that the scheduling node that is online again manages the taken-over database again.
[0107] For example, each scheduling node monitors the on-line and off-line events of the scheduling nodes in the scheduling cluster. Once it is detected that a scheduling node is off-line, a preemption request is sent to the coordination node to preempt the distributed lock of the off-line scheduling node. After receiving the preemption requests from the scheduling nodes, the coordination node creates a subdirectory with the same name under the third directory. The coordination node first creates the subdirectory for the preemption request of which scheduling node successfully, which indicates that the scheduling node successfully preempts the distributed lock of the off-line scheduling node. After the successful preemption of the distributed lock, it indicates that the scheduling node can take over the database of the off-line scheduling node.
[0108] For example, the target scheduling node successfully preempts the distributed lock. The coordination node sends a preemption response to the target scheduling node, which indicates that the target scheduling node successfully preempts the distributed lock. The preemption responses indicating the preemption failure are sent to the other scheduling nodes. Meanwhile, the coordination node sends a second notification to each client node and each scheduling node, which indicates the takeover node that takes over the off-line scheduling node.
[0109] After receiving the preemption response, the target scheduling node writes the IP address, port number, and basic information of the off-line scheduling node, and the corresponding relationship between the takeover node (the target scheduling node) and the taken-over node (the off-line scheduling node) in the subdirectory under the third directory. Then, if the off-line scheduling node is not on-line, a takeover thread is created to take over the database of the off-line scheduling node.
[0110] When the off-line scheduling node is not on-line, the target scheduling node takes over the database of the off-line scheduling node. For example, the database of the target scheduling node A is database a, and the database of the off-line scheduling node B is database b. The target scheduling node manages database a while managing database b. Once the trigger in database b meets the trigger condition, a second client node is determined from the client cluster. Alternatively, if the user modifies the scheduling task corresponding to the trigger in database b, the trigger in database b is edited, such as deleting, modifying, or querying the trigger in database b, so that the trigger in database b is adapted to the modified scheduling task.
[0111] When the off-line scheduling node is on-line again, the target scheduling node releases the distributed lock, so that the on-line scheduling node again manages the taken-over database.
[0112] Continuing with the above example, after the scheduling node B is online again, the target scheduling node A releases the distributed lock of the database b, so that the scheduling node B manages the database b again. From the perspective of the scheduling node B, after it is online, it checks whether the distributed lock has been preempted. For example, after the scheduling node B is online again, it pulls the first root directory, and at the same time, the scheduling node B can obtain the third notification. Therefore, the scheduling node can determine that the distributed lock is preempted by the scheduling node A, and then suspends the management of the database b. After the scheduling node B is online, the scheduling node A can receive the first notification and determine that the scheduling node B is online, and therefore, the scheduling node A releases the distributed lock, and then the scheduling node B takes over the database b.
[0113] With this scheme, when a scheduling node is offline, each online scheduling node preempts the distributed lock, takes over the database of the offline scheduling node after preemption, avoids the situation that the trigger cannot execute the scheduling task when the trigger meets the trigger task, and improves the high availability of the scheduling system.
[0114] Optionally, in the above embodiment, after the first client node receives the second notification, it finds that an offline scheduling node is taken over by another scheduling node, and then records the relationship between the offline scheduling node and the taking-over node. Subsequently, the first client receives a first editing request from the user device, and the first editing request is used to request editing of a scheduling task corresponding to a trigger of the offline scheduling node. Then, the first client node sends a second editing request to the taking-over node, so that the taking-over node edits the trigger in the database of the offline scheduling node.
[0115] For example, the offline scheduling node is the scheduling node B, and the taking-over node is the scheduling node A. When the user modifies the scheduling task corresponding to the trigger in the database b of the scheduling node B, an editing request is sent to the scheduling node A, so that the scheduling node A edits the database b.
[0116] With this scheme, the database of the offline scheduling node is managed by the taking-over node, the scheduling task is modified in a timely manner, and the purpose of improving the response speed is achieved.
[0117] In the above embodiment, the client node can provide a visual unified interface to manage the scheduling task, thereby simplifying the management and operation and maintenance cost. When the user wants to configure the scheduling task, the user logs in the client node. The client node sends interface data stream to the user device, so that the user device renders a creation interface according to the interface data stream. For example, please refer to Figure 3A~Figure 3C .
[0118] Figure 3A is a schematic diagram of an interface for managing a scheduling task in the scheduling method provided in the embodiments of the present application, Figure 3Bis another interface schematic diagram for managing scheduling tasks in the scheduling method provided by the embodiment of the present application, Figure 3C is still another interface schematic diagram for managing scheduling tasks in the scheduling method provided by the embodiment of the present application.
[0119] Please refer to Figure 3A After entering the creation interface, the user can select associated resources, including resource type, resource range, etc. Then, the page shown in Figure 3B sets the alarm rule, such as triggering an alarm when the bandwidth is greater than or equal to 100Mbps. After setting the alarm rule, enter the interface shown in Figure 3C , set the notification method, which users to notify, etc. in Figure 3C
[0120] After the setting is completed, the user equipment sends a first creation request to the client node, which is generated by the user equipment according to the input information of the user in the creation interface, for example, the user equipment generates the first creation request according to the input information of the user in Figure 3A , Figure 3B and Figure 3C . In the process of sending the first creation request, the user equipment sends the first creation request to the reverse proxy server, the reverse proxy server selects the first client node from the client cluster and sends the first creation request to it. After receiving the first creation request, the first client node generates a scheduling task and selects a target scheduling node, and sends a second creation request to the target scheduling node.
[0121] With this scheme, the scheduling efficiency is improved while the management and operation ability is simplified by using a visual interface to uniformly manage scheduling tasks, and the learning cost of users is reduced.
[0122] Figure 4 is another flowchart of the scheduling method provided by the embodiment of the present application. This embodiment is explained from the perspective of interaction between the scheduling node and the coordination node. This embodiment includes:
[0123] 401, the scheduling node sends a second online request to the coordination node.
[0124] The second online request carries basic information of the scheduling node, such as IP address, port number, database connection information, etc.
[0125] 402, the coordination node creates a first temporary node under the first root directory.
[0126] The first temporary node stores the basic information of the scheduling node.
[0127] 403, the scheduling node pulls the first root directory and the second root directory.
[0128] 404、The scheduling node receives the first notification and the third notification from the coordination node.
[0129] For example, the scheduling node listens to the online and offline events of other scheduling nodes in the scheduling cluster based on the first notification, and listens to the online and offline events of other client nodes in the client cluster based on the third notification.
[0130] 405、The scheduling node sends a preemption request to the coordination node.
[0131] For example, when the scheduling node listens to an offline scheduling node, the scheduling node sends a preemption request to the coordination node to preempt the distributed lock of the offline scheduling node.
[0132] 406、The scheduling node receives a preemption response.
[0133] 407、The scheduling node detects that the offline scheduling node is not online.
[0134] For example, if the scheduling node successfully preempts the distributed lock of the offline scheduling node, the scheduling node detects whether the offline scheduling node is online. If the offline scheduling node is online, the scheduling node does not perform any operation. If the offline scheduling node is not online, the scheduling node performs step 408.
[0135] 408、The scheduling node determines the database connected by the offline scheduling node.
[0136] The scheduling node pre-stores a first root directory, and a first temporary node under the first root directory is used to store the basic information of the scheduling node in the scheduling cluster. Therefore, the scheduling node can determine the database of the offline scheduling node.
[0137] 409、The scheduling node creates a takeover thread to take over the database of the offline scheduling node.
[0138] 410、The scheduling node determines that the offline scheduling node is online.
[0139] When the offline scheduling node is online again, the offline scheduling node sends a second online request to the coordination node. The coordination node sends the first notification to each online scheduling node and client node.
[0140] 411、The scheduling node interrupts the takeover thread.
[0141] 412、The scheduling node releases the distributed lock of the taken-over database.
[0142] In this embodiment, once a scheduling node is offline, other scheduling nodes take over the database of the offline scheduling node, thereby ensuring the high availability of the scheduling system.
[0143] Figure 5is another flowchart of the scheduling method provided in the embodiments of the present application. The embodiments are explained from the perspective of how to trigger an alarm. The embodiments include the following steps:
[0144] 501. The client node sends a first online request to the coordination node.
[0145] The first online request carries basic information of the client node, such as an IP address and a port number.
[0146] The coordination node creates a second temporary node under a second root directory after receiving the second online request.
[0147] 502. The client node pulls the first root directory.
[0148] 503. The client node receives a first notification from the coordination node.
[0149] When the first notification in step 503 indicates that a new scheduling node is added to the scheduling cluster, the client node performs step 504. When the first notification in step 503 indicates that a scheduling node is offline in the scheduling cluster, the client node performs step 505.
[0150] 504. The client node adds a first temporary node of the new scheduling node in the first root directory to update the first root directory.
[0151] 505. The client node receives a second notification.
[0152] The second notification indicates that the offline scheduling node is taken over by another scheduling node, which is also called a takeover node.
[0153] 506. The client node updates the first root directory according to the second notification.
[0154] The client node records the correspondence between the offline scheduling node and the takeover node in the first root directory.
[0155] 507. The scheduling node pulls the first root directory and the second root directory from the coordination node.
[0156] 508. The client node selects a target scheduling node.
[0157] When the client node receives a creation request from a user device, the target scheduling node is selected from the scheduling set according to the first root directory while the scheduling task is generated.
[0158] 509. The client node sends a second creation request to the target scheduling node.
[0159] The second creation request carries a task identifier of the scheduling task and a cluster identifier of the cluster where the client node is located.
[0160] 510、the scheduling node selects a second client node.
[0161] When there is a trigger satisfying the trigger condition in the database managed by the scheduling node, a second root directory is determined according to the cluster identifier, and a second client node is selected from the client cluster according to the second root directory, which is the same as or different from the client node in step 508. The following is an example of the same. The database managed by the scheduling node includes its own database and the takeover database.
[0162] 511、the scheduling node sends a callback request to the client node.
[0163] The callback request carries the task identifier of the scheduling task.
[0164] 512、the scheduling node generates a scheduling log.
[0165] 513、the client node executes the scheduling task.
[0166] For example, the client node queries the monitoring data and generates an alarm email according to the alarm rule.
[0167] The following is an embodiment of the device of the present application, which can be used to execute the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
[0168] Figure 6 A schematic diagram of a task scheduling device according to an embodiment of the present application is provided. The task scheduling device 600 is integrated, for example, in a first client node in a client cluster, and the task scheduling device 600 includes a receiving module 61, a processing module 62, a creating module 63, and a sending module 64.
[0169] The receiving module 61 is configured to receive a first creation request from a user device, the first creation request being used to request to create a scheduling task, and the first client node being any one of the client nodes in the client cluster.
[0170] The processing module 62 is configured to determine a target scheduling node from a scheduling cluster according to a first root directory, a first temporary node under the first root directory being used to store basic information of the scheduling nodes in the scheduling cluster.
[0171] The creating module 63 is configured to generate the scheduling task according to the first creation request.
[0172] The sending module 64 is configured to send a second creation request to the target scheduling node, so that the target scheduling node generates a trigger for the scheduling task, and the trigger is used to indicate a trigger condition of the scheduling task.
[0173] In an implementation, the sending module 64 is further configured to send a first online request to the coordination node to make the coordination node update a second root directory when the first client node is online, the second temporary nodes under the second root directory being used to store basic information of the client nodes in the client cluster, the first online request carrying the basic information of the first client node.
[0174] The processing module 62 is further configured to pull each first temporary node under the first root directory from the coordination node.
[0175] In an implementation, the receiving module 61 is further configured to receive a first notification from the coordination node, the first notification being used to indicate that a scheduling node is added or deleted in the scheduling cluster.
[0176] The processing module 62 is further configured to add a first temporary node corresponding to the added scheduling node under the first root directory when the first notification indicates that the scheduling node is added in the scheduling cluster, and delete the first temporary node corresponding to the offline scheduling node from the first root directory when the first notification indicates that the scheduling node is offline.
[0177] In an implementation, the receiving module 61 is further configured to receive a second notification from the coordination node after the processing module 62 deletes the first temporary node corresponding to the offline scheduling node from the first root directory, the second notification being used to indicate a takeover node that takes over the offline scheduling node, and receive a first edit request from the user device, the first edit request being used to request to edit a scheduling task corresponding to a trigger of the offline scheduling node.
[0178] The sending module 64 is further configured to send a second edit request to the takeover node to make the takeover node edit the trigger in the database of the offline scheduling node.
[0179] In an implementation, the sending module 64 is further configured to send interface data stream to the user device to make the user device render a creation interface according to the interface data stream.
[0180] The receiving module 61 is configured to receive a first creation request from the user device, the first creation request being generated by the user device according to input information of the user in the creation interface.
[0181] In a feasible implementation, the receiving module 61 is further configured to receive a callback request from the target scheduling node after the sending module 64 sends the second creation request to the target scheduling node, and the callback request carries a task identifier of the scheduling task.
[0182] The processing module 62 is further configured to determine the scheduling task according to the task identifier, and execute the scheduling task.
[0183] The task scheduling apparatus provided in the embodiments of the present application can perform the actions of the first client node in the above embodiments, and has similar implementation principles and technical effects, which will not be described here again.
[0184] Figure 7 Another schematic diagram of a task scheduling apparatus is provided in the embodiments of the present application. The task scheduling apparatus 700 is integrated in, for example, a target scheduling node in a scheduling cluster, and the task scheduling apparatus 700 includes a receiving module 71, a processing module 72, and a sending module 74.
[0185] The receiving module 71 is configured to receive a second creation request from a first client node, and the second creation request is used to request generation of a trigger for a scheduling task, and the trigger is used to indicate a trigger condition of the scheduling task. The first client node is any one of client nodes in a client cluster, and the target scheduling node is a scheduling node selected by the first client node from a scheduling cluster.
[0186] The processing module 72 is configured to generate the trigger according to the second creation request, and when the trigger condition is met, determine a second client node from the client cluster according to a second root directory, and a second temporary node under the second root directory is used to store basic information of client nodes in the client cluster.
[0187] The sending module 73 is configured to send a callback request to the second client node, so that the second client node executes the scheduling task.
[0188] In a feasible implementation, the sending module 73 is further configured to send a second online request to a coordination node when the target scheduling node is online, and the second online request carries basic information of the target scheduling node, and the coordination node is any one of nodes in a coordination cluster, before the receiving module 71 receives the second creation request from the first client node.
[0189] The processing module 72 is further configured to pull each first temporary node under a first root directory and each second temporary node under a second root directory from the coordination node, and the first temporary node under the first root directory is used to store basic information of scheduling nodes in the scheduling cluster.
[0190] In a possible implementation, the receiving module 71 is further configured to receive a first notification from the coordination node, where the first notification is used to indicate that a scheduling node is added or deleted in the scheduling cluster; and the processing module 72 is further configured to add a first temporary node corresponding to the added scheduling node under the first root directory when the first notification indicates that the scheduling node is added in the scheduling cluster; and delete the first temporary node corresponding to the offline scheduling node under the first root directory when the first notification indicates that the scheduling node is offline in the scheduling cluster.
[0191] In a possible implementation, the receiving module 71 is further configured to receive a third notification from the coordination node, where the third notification is used to indicate that a client node is added or deleted in the client cluster; and the processing module 72 is further configured to add a second temporary node corresponding to the added client node under the second root directory when the third notification indicates that the client node is added in the client cluster; and delete the second temporary node corresponding to the offline client node under the second root directory when the third notification indicates that the client node is offline in the client cluster.
[0192] In a possible implementation, the sending module 73 is further configured to send a preemption request to the coordination node to preempt the distributed lock of the offline scheduling node when the first notification indicates that the scheduling node is offline in the scheduling cluster.
[0193] The receiving module 71 is further configured to receive a preemption response from the coordination node.
[0194] The processing module 72 is further configured to create a takeover thread to take over the database of the offline scheduling node when the preemption response indicates that the target scheduling node successfully preempts the distributed lock; and release the distributed lock when the offline scheduling node is online again, so that the online scheduling node manages the taken-over database again.
[0195] The task scheduling apparatus provided in the embodiments of the present application can perform the actions of the target scheduling node in the above embodiments, and has similar implementation principles and technical effects, which will not be described here again.
[0196] Figure 8 FIG. 8 is a schematic diagram of another task scheduling apparatus provided in the embodiments of the present application. The task scheduling apparatus 800 is integrated, for example, in a coordination node in a scheduling cluster, and the task scheduling apparatus 800 includes a receiving module 81 and a sending module 82.
[0197] The receiving module 81 is configured to receive a first online request from a first client node, where the first online request carries basic information of the first client node.
[0198] The sending module 82 is configured to send a first root directory to the first client node, so that the first client node determines a target scheduling node from the scheduling cluster according to the first root directory after receiving a first creation request, the first creation request being used to request to create a scheduling task, the first client node being any one of the client nodes in the client cluster, and a first temporary node under the first root directory being used to store basic information of the scheduling nodes in the scheduling cluster.
[0199] The receiving module 81 is further configured to receive a second online request from the target scheduling node, the second online request carrying the basic information of the target scheduling node.
[0200] The sending module 82 is further configured to send the first root directory and a second root directory to the target scheduling node, so that the target scheduling node selects a second client node from the client cluster according to the second root directory and triggers the second client node to execute a scheduling task corresponding to a trigger when a trigger in a database managed by the target scheduling node satisfies a trigger condition, and a second temporary node under the second root directory being used to store basic information of the client nodes in the client cluster.
[0201] In a feasible implementation, the sending module 82 is further configured to send a first notification to each of the client nodes in the client cluster and each of the scheduling nodes in the scheduling cluster when a scheduling node is added or deleted in the scheduling cluster.
[0202] In a feasible implementation, the sending module 82 is further configured to send a third notification to each of the scheduling nodes in the scheduling cluster when a client node is added or deleted in the client cluster.
[0203] In a feasible implementation, the receiving module 81 is further configured to receive a preemption request of an online scheduling node in the scheduling cluster when an offline scheduling node appears in the scheduling cluster.
[0204] The sending module 82 is further configured to send a preemption response to the scheduling node that succeeds in preemption, so that the scheduling node that succeeds in preemption creates a takeover thread and takes over a database of the offline scheduling node.
[0205] The task scheduling apparatus provided by the embodiments of the present application can perform the actions of the coordination node in the above embodiments, and has similar implementation principles and technical effects, which will not be described here again.
[0206] Figure 9 A structural schematic diagram of an electronic device provided by the embodiments of the present application is shown in FIG. 1. As shown in FIG. 1, the electronic device includes a processor 10, a memory 20 and a bus 30. Figure 9As shown, the electronic device 900, for example, is a client node in the client cluster, a scheduling node in the scheduling cluster or a coordination node in the coordination cluster as described above, and the electronic device 900 comprises:
[0207] a processor 91 and a memory 92;
[0208] The memory 92 stores computer instructions.
[0209] The processor 91 executes the computer instructions stored in the memory 92, so that the processor 91 performs the task scheduling method implemented by the client node, the scheduling node or the coordination node as described above.
[0210] The specific implementation process of the processor 91 can refer to the method embodiments described above, which have similar implementation principles and technical effects, and will not be described here in detail.
[0211] Optionally, the electronic device 900 further comprises a communication component 93. The processor 91, the memory 92 and the communication component 93 can be connected through a bus 94.
[0212] The embodiments of the present application also provide a computer readable storage medium, the computer readable storage medium stores computer instructions, and the computer instructions are executed by a processor to implement the task scheduling method implemented by the client node, the scheduling node or the coordination node as described above.
[0213] The embodiments of the present application also provide a computer program product, the computer program product contains a computer program, and the computer program is executed by a processor to implement the task scheduling method implemented by the client node, the scheduling node or the coordination node as described above.
[0214] Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. The specification and examples given are exemplary only and the true scope and spirit of the application is indicated by the following claims. The true scope and spirit of the application are indicated by the following claims.
[0215] It should be understood that the application is not limited to the precise construction that has been described above and shown in the accompanying drawings, and that various modifications and changes can be made by those skilled in the art without departing from the scope of the application. The scope of the application is indicated only by the appended claims.
Claims
1. A task scheduling method, characterized by, The method applied to a first client node comprises: receiving a first creation request from a user device, the first creation request being used to request creation of a scheduling task, the first client node being any one of client nodes in a client cluster; determining a target scheduling node from a scheduling cluster according to a first root directory, a first temporary node under the first root directory being used to store basic information of the scheduling nodes in the scheduling cluster, the scheduling cluster being used to store triggers on the scheduling nodes in a distributed storage manner, the basic information of the scheduling nodes including IP addresses, port numbers of the scheduling nodes, and identities of databases connected to the scheduling nodes; generating the scheduling task according to the first creation request; sending a second creation request to the target scheduling node, so that the target scheduling node generates a trigger for the scheduling task and selects a second client node from the client cluster, the second client node being a newly added client node in the client cluster, the second client node being used to execute the scheduling task, the trigger being used to indicate a triggering condition of the scheduling task, the client nodes in the client cluster being online or offline according to needs, and the scheduling nodes in the scheduling cluster being online or offline according to needs; before the receiving the first creation request from the user device, the method further comprises: when the first client node is online, sending a first online request to a coordination node to make the coordination node update a second root directory, a second temporary node under the second root directory being used to store basic information of the client nodes in the client cluster, the first online request carrying the basic information of the first client node, the basic information of the first client including IP addresses and port numbers of the first client; pulling each first temporary node under the first root directory from the coordination node.
2. The method of claim 1, wherein, the method further comprises: receiving a first notification from a coordination node, the first notification being used to indicate that a scheduling node is added or deleted in the scheduling cluster; when the first notification indicates that a scheduling node is added in the scheduling cluster, adding a first temporary node corresponding to the added scheduling node under the first root directory; when the first notification indicates that a scheduling node is offline in the scheduling cluster, deleting a first temporary node corresponding to the offline scheduling node from the first root directory.
3. The method of claim 2, wherein, after the deleting the first temporary node corresponding to the offline scheduling node from the first root directory, the method further comprises: receiving a second notification from the coordination node, the second notification being used to indicate a takeover node taking over the offline scheduling node; receiving a first edit request from the user device, the first edit request being used to request editing of a scheduling task corresponding to a trigger of the offline scheduling node; sending a second edit request to the takeover node, so that the takeover node edits the trigger in a database of the offline scheduling node.
4. The method according to any one of claims 1 to 3, characterized in that, the receiving the first creation request from the user device comprises: sending an interface data stream to the user equipment, so that the user equipment renders a creation interface according to the interface data stream; receiving a first creation request from the user equipment, the first creation request being generated by the user equipment according to input information of the user in the creation interface.
5. The method of claim 4 wherein, after the sending of the second creation request to the target scheduling node, the method further comprises: receiving a callback request from the target scheduling node, the callback request carrying a task identifier of the scheduling task; determining the scheduling task according to the task identifier; executing the scheduling task.
6. A task scheduling method characterized by comprising: applied to a target scheduling node, the method comprises: receiving a second creation request from a first client node, the second creation request being used to request generation of a trigger for a scheduling task, the trigger being used to indicate a trigger condition of the scheduling task, the first client node being any one of client nodes in a client cluster, the target scheduling node being a scheduling node selected by the first client node from a scheduling cluster, the scheduling cluster being used to store triggers on scheduling nodes in a distributed storage manner; generating the trigger according to the second creation request; when the trigger condition is met, determining a second client node from the client cluster according to a second root directory, a second temporary node under the second root directory being used to store basic information of client nodes in the client cluster, the second client node being a newly added client node in the client cluster, the client nodes in the client cluster being online or offline according to requirements, the scheduling nodes in the scheduling cluster being online or offline according to requirements, the basic information of the client including an IP address and a port number of the client; sending a callback request to the second client node, so that the second client node executes the scheduling task; before the receiving of the second creation request from the first client node, the method further comprises: when the target scheduling node is online, sending a second online request to a coordination node, the second online request carrying basic information of the target scheduling node, the coordination node being any one of nodes in a coordination cluster; pulling each first temporary node under a first root directory and each second temporary node under a second root directory from the coordination node, the first temporary node under the first root directory being used to store basic information of scheduling nodes in the scheduling cluster, the basic information of the scheduling nodes including an IP address, a port number and an identifier of a database connected to the scheduling node.
7. The method of claim 6, wherein, the method further comprises: receiving a first notification from the coordination node, the first notification being used to indicate that a scheduling node is added or deleted in the scheduling cluster; when the first notification indicates that a scheduling node is added in the scheduling cluster, adding a first temporary node corresponding to the added scheduling node under the first root directory; when the first notification indicates that a scheduling node is offline in the scheduling cluster, deleting a first temporary node corresponding to the offline scheduling node under the first root directory; receiving a third notification from the coordination node, the third notification being used to indicate that a client node is added or deleted in the client cluster; when the third notification indicates that a new client node is added to the client cluster, adding a second temporary node corresponding to the new client node under the second root directory; when the third notification indicates that an offline client node is added to the client cluster, deleting the second temporary node corresponding to the offline client node under the second root directory.
8. The method of claim 7, wherein, Further comprising: when the first notification indicates that an offline scheduling node is added to the scheduling cluster, sending a preemption request to the coordination node to preempt the distributed lock of the offline scheduling node; receiving a preemption response from the coordination node; when the preemption response indicates that the target scheduling node successfully preempts the distributed lock, creating a takeover thread to take over the database of the offline scheduling node; when the offline scheduling node is online again, releasing the distributed lock to enable the online scheduling node to manage the taken-over database again.
9. A task scheduling method characterized by comprising: Applied to a coordination node, the method comprises: receiving a first online request from a first client node, the first online request carrying basic information of the first client node, the basic information of the first client including an IP address and a port number of the client; sending a first root directory to the first client node, so that the first client node determines a target scheduling node from the scheduling cluster according to the first root directory after receiving a first creation request, the first creation request being used to request to create a scheduling task, the first client node being any one of the client nodes in a client cluster, a first temporary node under the first root directory being used to store basic information of the scheduling nodes in the scheduling cluster, the scheduling cluster being used to store triggers on each scheduling node in a distributed storage manner, the basic information of the scheduling node including an IP address, a port number of the scheduling node, and an identifier of a database connected to the scheduling node; receiving a second online request from the target scheduling node, the second online request carrying basic information of the target scheduling node; sending the first root directory and a second root directory to the target scheduling node, so that when triggers in the database managed by the target scheduling node meet a triggering condition, a second client node is selected from the client cluster according to the second root directory and the second client node is triggered to execute a scheduling task corresponding to the triggers, a second temporary node under the second root directory being used to store basic information of the client nodes in the client cluster, the second client node being a new client node in the client cluster, the client nodes in the client cluster being online or offline according to needs, and the scheduling nodes in the scheduling cluster being online or offline according to needs.
10. A dispatch system characterized by, Further comprising: a client cluster comprising at least one client node, used to execute the method according to any one of claims 1-5; a scheduling cluster comprising at least one scheduling node, used to execute the method according to any one of claims 6-8; a coordination cluster comprising at least one coordination node, used to execute the method according to claim 9.
Citation Information
Patent Citations
Distributed task scheduling method and device, computer equipment and storage medium
CN110290180A