Task Scheduling Method, Device, Electronic Device and Computer-Readable Storage Medium

By selecting a target scheduling node in the task scheduling system and using the planned synchronization and backup node mechanism, the duplicate scheduling and wrong data problems caused by multiple task scheduling nodes are solved, and the stability and reliability of task scheduling are improved.

CN114253690BActive Publication Date: 2025-07-22CHONGQING COMM CONSTR CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111563927.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-20
Publication Date
2025-07-22
Estimated Expiration
2041-12-20

AI Technical Summary

Technical Problem

In traditional task scheduling systems, when multiple task scheduling nodes run at the same time, resulting in duplicate scheduling and error data generation.

Method used

By monitoring the startup of the task scheduling node, select a target scheduling node for task execution, avoid repeated scheduling, and improve the stability and availability of the system through planning synchronization nodes and backup nodes.

Benefits of technology

It realizes the efficiency and reliability of task scheduling, avoids duplicate scheduling and the generation of wrong data, and reduces the risks and losses caused by downtime.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114253690B_ABST
    Figure CN114253690B_ABST
Patent Text Reader

Abstract

The present application provides a task scheduling method, apparatus, electronic device and computer-readable storage medium. By determining a target scheduling node from the started task scheduling nodes, and having the target scheduling node select a target task execution node, since only one target scheduling node will perform actual task execution triggering at the same time, the generation of repeated scheduling and incorrect data is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of task scheduling, and more particularly, to a task scheduling method, apparatus, electronic device, and computer-readable storage medium. Background Art

[0002] In a traditional task scheduling system, when multiple task scheduling nodes are started in the system, for a task plan execution instruction, when these multiple started task scheduling nodes are all in the running state, each task scheduling node will select a task execution node. Therefore, for the same task plan execution request, multiple task scheduling nodes will select task execution nodes at the same time, resulting in repeated scheduling and prone to generating incorrect data. Summary of the Invention

[0003] The purpose of the embodiments of this application is to provide a task scheduling method, apparatus, electronic device, and computer-readable storage medium to solve the problem of repeated scheduling and generation of incorrect data caused by multiple task scheduling nodes working simultaneously in the existing task scheduling process.

[0004] The embodiments of this application provide a task scheduling method, including:

[0005] Monitoring the startup status of task scheduling nodes;

[0006] When the number of currently started task scheduling nodes is greater than 1, determining a target scheduling node from the currently started task scheduling nodes;

[0007] Wherein, when receiving a task plan execution instruction, the target scheduling node is used to select a target task execution node for task scheduling to implement the corresponding task plan after obtaining the task plan corresponding to the task plan execution instruction.

[0008] In the above implementation process, a target scheduling node is determined from the started task scheduling nodes, and the target task execution node is selected by this target scheduling node. Since only one target scheduling node will actually trigger task execution at the same time, repeated scheduling and generation of incorrect data are avoided.

[0009] Further, the determining a target scheduling node from the currently started task scheduling nodes includes:

[0010] Selecting the target scheduling node according to the startup order of the currently started task scheduling nodes.

[0011] In the above implementation process, a target scheduling node is selected from the started task scheduling nodes based on the startup order of the task scheduling nodes, which can ensure the rationality and availability of the target scheduling node as much as possible.

[0012] Further, the selecting of the target scheduling node according to the starting order of the currently started task scheduling nodes includes:

[0013] Selecting the task scheduling node with the latest starting time from the currently started task scheduling nodes as the target scheduling node;

[0014] Or,

[0015] When the number of currently started task scheduling nodes is greater than 1, taking the second started task scheduling node as the target scheduling node.

[0016] In the above implementation process, since the task scheduling node with the latest starting time is selected from the currently started task scheduling nodes as the target scheduling node, the target task scheduling node is refreshed in real time, further ensuring the rationality and availability of the target scheduling node. Or taking the second started task scheduling node as the target scheduling node can avoid frequent switching of the target scheduling node.

[0017] Further, the method further includes: a task plan is registered on each of the task scheduling nodes, and the method further includes:

[0018] Determining a plan synchronization node from the currently started task scheduling nodes;

[0019] The plan synchronization node is used to communicate with the task scheduling nodes other than itself, obtain synchronization information, and send the synchronization information to the task scheduling nodes other than itself. The synchronization information includes information on the task plans registered on each of the task scheduling nodes.

[0020] In the above implementation process, by communicating with the started task scheduling nodes other than itself through the plan synchronization node and sending synchronization information, it is ensured that when other task scheduling nodes are selected as the target scheduling node, they can obtain the task plan corresponding to the task plan execution instruction on time and accurately.

[0021] Further, the determining of the plan synchronization node from the currently started task scheduling nodes includes:

[0022] Selecting the task scheduling node with the earliest starting time from the started task scheduling nodes as the plan synchronization node.

[0023] In the above implementation process, selecting the task scheduling node with the earliest starting time as the plan synchronization node can minimize the switching frequency of the plan synchronization node.

[0024] Further, the method further includes:

[0025] When there is a first standby node of the target scheduling node among the started task scheduling nodes, if the target scheduling node fails, select the node that started the latest from the first standby nodes as the new target scheduling node.

[0026] In the above implementation process, when the target scheduling node fails, determine a new target scheduling node from the first standby nodes, which improves the stability of task scheduling and reduces the risks and losses brought by the failure.

[0027] Further, the method further includes:

[0028] When there is a second standby node of the planned synchronization node among the started task scheduling nodes, if the planned synchronization node fails, select the task scheduling node that started the earliest from the second standby nodes as the new planned synchronization node.

[0029] In the above implementation process, when the planned synchronization node fails, determine a new planned synchronization node from the second standby nodes, which improves the stability of task scheduling and reduces the risks and losses brought by the failure.

[0030] The embodiment of the present application further provides a task scheduling device, including:

[0031] A monitoring unit, configured to monitor the startup status of task scheduling nodes;

[0032] A determination unit, configured to determine a target scheduling node from the currently started task scheduling nodes when the number of currently started task scheduling nodes is greater than 1; wherein, when receiving a task plan execution instruction, the target scheduling node is configured to, after obtaining a task plan corresponding to the task plan execution instruction, select a target task execution node for task scheduling to implement the corresponding task plan.

[0033] The embodiment of the present application further provides an electronic device, including a processor and a memory, where a computer program is stored in the memory, and the processor executes the computer program to implement any one of the above task scheduling methods.

[0034] The embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by at least one processor, any one of the above task scheduling methods is implemented. Description of the Drawings

[0035] To more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the accompanying drawings required for the embodiments of the present application. It should be understood that the following drawings only show some embodiments of the present application, and thus should not be regarded as limiting the scope. For those of ordinary skill in the art, without creative efforts, other related drawings can also be obtained based on these drawings.

[0036] Figure 1 It is a schematic flowchart of the task scheduling method provided in the first embodiment of the present application;

[0037] Figure 2 It is a schematic flowchart of the task scheduling method provided in the second embodiment of the present application;

[0038] Figure 3 It is a schematic structural diagram of the task scheduling device provided in the third embodiment of the present application;

[0039] Figure 4 It is a schematic structural diagram of the electronic device provided in the fourth embodiment of the present application. Detailed implementation manners

[0040] The following will describe the technical solutions in the embodiments of the present application in combination with the accompanying drawings in the embodiments of the present application.

[0041] Embodiment 1:

[0042] To solve the problem that multiple task scheduling nodes work simultaneously during the existing task scheduling process, resulting in duplicate scheduling and generating incorrect data, a task scheduling method is provided in this embodiment. For the specific process, please refer to Figure 1 as shown, including:

[0043] S101: Monitor the startup status of the task scheduling nodes.

[0044] S102: When the number of currently started task scheduling nodes is greater than 1, determine a target scheduling node from the currently started task scheduling nodes.

[0045] When receiving a task plan execution instruction, the target scheduling node in step S102 is used to select a target task execution node for task scheduling to implement the corresponding task plan after obtaining the task plan corresponding to the task plan execution instruction. For example, the target scheduling node can select an idle target task execution node for task scheduling to implement the corresponding task plan. It can be understood that the task scheduling node can register the task plan in the database after being confirmed as the target scheduling node, or can register the task plan as soon as it starts, or the target scheduling node can also obtain the corresponding task plan from the plan synchronization node below.

[0046] It should be noted that if the number of currently started task scheduling nodes is 1, the task scheduling node can be directly used as the target scheduling node.

[0047] In step S102, the target scheduling node can be selected according to the startup order of the currently started task scheduling nodes. For example, the task scheduling node with the latest startup time can be selected from the currently started task scheduling nodes as the target scheduling node, so as to refresh the target task scheduling node in real time and ensure the reliability of the selected target task scheduling node. Of course, in other embodiments, the task scheduling node with the earliest startup time can also be selected as the target scheduling node, or the second-started or third-started task scheduling node can be selected as the target scheduling node. The specific selection rule here can be flexibly set by the developer in advance. Of course, in other embodiments, a target scheduling node can also be randomly selected from the started task scheduling nodes, or other rules can be followed for selection, as long as one target scheduling node is ensured to be selected.

[0048] In this embodiment, a task plan can be registered on each started task scheduling node. At this time, a plan synchronization node can be determined from the currently started task scheduling nodes; among them, the plan synchronization node is used to communicate with task scheduling nodes other than itself, obtain synchronization information, and send the synchronization information to task scheduling nodes other than itself. The synchronization information includes information on the task plans registered on each task scheduling node.

[0049] In some other embodiments, the synchronization information can also include the node information of each task scheduling node. The node information of each scheduling node can include the startup time of the node and / or the current role identity information of the node. Here, the role identity information refers to whether the node is currently an ordinary task scheduling node identity, a target scheduling node identity, or a plan synchronization node identity. In this way, each task scheduling node in the scheduling system can obtain the information of task scheduling nodes other than itself through the plan synchronization node.

[0050] Similarly, in this embodiment, the plan synchronization node can be determined according to the startup order of the started task scheduling nodes. For example, the task scheduling node with the earliest startup time can be selected as the plan synchronization node, so as to reduce the switching frequency of the plan synchronization node. In other embodiments, other selection rules can be used to select the plan synchronization node. For example, it can be randomly selected from the task scheduling nodes excluding the target scheduling node. Of course, if there is only one started task scheduling node, then this task scheduling node can act as both the target scheduling node and the plan synchronization node.

[0051] It should be noted that the electronic device that executes the above steps S101 and S102 can first determine a planned synchronization node from the already started task scheduling nodes. For example, it can directly determine a planned synchronization node according to the startup order of the already started task scheduling nodes, and then select a target scheduling node from the already started task scheduling nodes through this planned synchronization node. That is, the planned synchronization node implements the above steps S101 and S102. The selection of subsequent new planned synchronization nodes and new target scheduling nodes can all be implemented by the electronic device through this planned synchronization node, that is, the planned synchronization node specifically implements the above steps. Of course, in other embodiments, after the electronic device determines the target scheduling node by executing the above steps S101 and S102, it can also use this target scheduling node to implement the selection of subsequent new planned synchronization nodes and new target scheduling nodes. In some other embodiments, the functions corresponding to the above method steps can also be implemented by other program nodes of the electronic device.

[0052] Preferably in this embodiment, a planned synchronization node can be selected from the started task scheduling nodes. However, in other embodiments, the number of planned synchronization nodes can also be multiple. When a certain task scheduling node updates its task plan, this task scheduling node can send the updated task plan to the planned synchronization node, and then the planned synchronization node notifies other task scheduling nodes of this updated task plan as synchronization information. If the node that updates the task plan is the planned synchronization node, this node can directly synchronize the updated task plan to other task scheduling nodes.

[0053] In this embodiment, when there is a first standby node of the current target scheduling node among the already started task scheduling nodes, if it is detected that the target scheduling node fails, a node can be selected from the first standby nodes as the new target scheduling node. Here, the selection principle for the new target scheduling node can be the same as or different from the principle for selecting the target scheduling node before. For example, the node that started the latest can be selected from the first standby nodes as the new target scheduling node. The first standby nodes here can be the nodes among the currently started task scheduling nodes excluding the current target scheduling node, or the nodes among the currently started task scheduling nodes excluding the current target scheduling node and the planned synchronization node.

[0054] Similarly, in this embodiment, when there is a second standby node of the planned synchronization node among the started task scheduling nodes, if it is detected that the planned synchronization node fails, the task scheduling node that started earliest can be selected from the second standby nodes as the new planned synchronization node. Here, the selection principle for the new planned synchronization node can be the same as or different from the principle for selecting the planned synchronization node before. For example, the node that started earliest can be selected from the second standby nodes as the new target scheduling node. The second standby node here can be the nodes among the currently started task scheduling nodes excluding the current planned synchronization node, or the nodes among the currently started task scheduling nodes excluding the current target scheduling node and the planned synchronization node.

[0055] It should be noted that, in another embodiment, the task plan, the node identification information of the determined target scheduling node, the planned synchronization node, or the standby node can all be stored in a common database. In this way, the other task scheduling nodes can also directly obtain the current specific situation of the scheduling system through this common database, without the need for the planned synchronization node to synchronize information among the task scheduling nodes.

[0056] Finally, it should be noted that the above task scheduling nodes can be deployed on one electronic device or on multiple electronic devices.

[0057] The task scheduling method provided in this embodiment selects target task execution nodes through a target scheduling node for task scheduling to implement the corresponding task plan. Each task scheduling node no longer preempts task execution in a table-locking manner, avoiding a large number of threads waiting for resources. At the same time, it can avoid duplicate scheduling and the generation of incorrect data. In addition, the stability of task scheduling is improved through standby nodes, reducing the risks and losses brought by downtime, and having the characteristics of high efficiency and high availability.

[0058] Embodiment 2:

[0059] To better understand the solution provided by the present invention, this embodiment details the process of determining the role of a task scheduling node when it is started. For the specific process, please refer to Figure 2 As shown, it includes:

[0060] S201: Start task scheduling node A.

[0061] S202: Determine whether there is a planned synchronization node among the started task scheduling nodes. If so, go to S204; if not, go to S203.

[0062] It should be noted that the information of each task scheduling node in this embodiment can be stored in the node information database. The node information database can store the node identification information of the target scheduling node, the planned synchronization node, and the standby node. The planned synchronization node can maintain the information in the node information database, update it in real time, and clean up the invalid node information.

[0063] In another embodiment, step S202 can be replaced by determining whether the number of started task scheduling nodes is greater than 1. If so, go to S204; if not, go to S203.

[0064] S203: Use task scheduling node A as the target scheduling node and the planned synchronization node.

[0065] The target scheduling node in this embodiment can select an available target task execution node from the execution program clients registered with this service for task scheduling to implement the corresponding task plan. When the next task is triggered, similarly, an available target task execution node will be selected for task scheduling. The planned synchronization node is used to synchronize the updated task plan to the remaining task scheduling nodes. At the same time, the planned synchronization node can notify the task execution node to switch to the specified target scheduling node for service. The corresponding target task execution node can register according to the socket service to the corresponding target scheduling node, and at the same time provide a normal web api access method. When the target task execution node receives the task execution instruction sent by the target scheduling node, it immediately writes the task into the execution queue and starts execution.

[0066] Of course, in other embodiments, the target scheduling node can directly notify the corresponding target task execution node for task scheduling service.

[0067] It should be noted that when the target scheduling node in this embodiment receives the task return request of the current target task execution node, it can re-select a new target task execution node for task execution for the tasks not executed in the execution program queue. Specifically, the target task execution node can send a task return request to the target scheduling node when the current task is heavy or blocked.

[0068] S204: Determine whether the current planned synchronization node and the target scheduling node are the same node. If so, go to S205; if not, go to S206.

[0069] The planned synchronization node and the target task scheduling node being the same node indicates that only one task scheduling node has been started currently.

[0070] In another embodiment, step S204 can be replaced by determining whether the number of started task scheduling nodes is equal to 2. If so, go to S205; if not, go to S206.

[0071] S205: Mark the task scheduling node A as the target scheduling node, cancel the identity of the previous target scheduling node as the target scheduling node, and use the previous target scheduling node as the planned synchronization node and the standby node.

[0072] S206: Mark the task scheduling node A as the standby node.

[0073] The standby node in this embodiment can be subsequently activated as the target scheduling node or the planned synchronization node. Specifically, the standby node with the earliest start time can be activated as the planned synchronization node, and the standby node with the latest start time can be activated as the target scheduling node. It should be noted that in the method provided in this embodiment, the planned synchronization node will be determined first. It can be understood that in other embodiments, the planned synchronization node may not be determined, or the planned synchronization node may be determined after the target scheduling node is determined. The specific process can be flexibly set by developers.

[0074] It should also be noted that the task scheduling nodes in this embodiment can communicate based on the socket service. Specifically: the planned synchronization node is registered as the socket server, the standby node and the target scheduling node are registered as the socket clients, and the planned synchronization node broadcasts and sends the task plan for planned synchronization.

[0075] In this embodiment, the first started task scheduling node is first used as the target scheduling node and the planned synchronization node; when the second started task scheduling node is available, the first started task scheduling node is changed to the planned synchronization node and the standby node. At the same time, the second started task scheduling node is designated as the target scheduling node; the third to nth started task scheduling nodes can connect to the planned synchronization node through the database information after startup, and these nodes are used as standby nodes. The planned synchronization node can maintain all task scheduling nodes to enter the database and set the node weights according to the start time or registration time of the nodes, which are used as the alternative targets for the next target scheduling node or the planned synchronization node.

[0076] When the target scheduling node fails, the planned synchronization node can randomly or according to the weight value select a new target scheduling node from the standby nodes, broadcast the message, and can send a switching instruction to the task execution node through the http protocol to perform the scheduling server switching. The weight value here can be a value determined according to the start time.

[0077] When the planned synchronization node fails, the second weighted task scheduling node changes from a standby node to a synchronization plus standby role. For example, among the currently started task scheduling nodes, the task scheduling node with the earliest start time other than the planned synchronization node is selected as the new planned synchronization node. At the same time, other task scheduling nodes can find and connect to the current planned synchronization node through the node information database.

[0078] Simply put, in a specific implementation, multiple task scheduling nodes can be deployed on one or more electronic devices. The first started node will be registered as the planned synchronization node and the target scheduling node, and the task plan will be registered. After other nodes are started, except for the task scheduling node that is the second to start and complete, they can obtain the information of the planned synchronization node through the node database and establish a two-way communication connection with the planned synchronization node. Then, they will be set as standby nodes weighted by the start time sequence by the planned synchronization node. The node that is the second to start will be set as the target scheduling node by the planned synchronization node, and the weight value will be automatically updated to the minimum value (to avoid becoming the next planned synchronization node). All started nodes have registered the task plan. If a task plan execution instruction is received at this time, the node with the target scheduling node role among all nodes, that is, the target scheduling node, will select the target task execution node for task scheduling to implement the corresponding task plan. After other nodes determine that they are not in the target scheduling node role, they will remain silent (ignore the triggered task).

[0079] The planned synchronization node in this embodiment is implemented based on the real-time nature of two-way communication, ensuring the high availability and reliability of task scheduling.

[0080] When a certain task scheduling node in the cluster modifies the task plan, the task scheduling node can actively notify the planned synchronization node of the task plan change. The planned synchronization node will immediately synchronize the latest task plan to all task scheduling nodes, ensuring the effectiveness and accuracy of the scheduling node plan trigger.

[0081] In addition, when a standby node in the cluster fails, it can be broadcast to each node in a timely manner through the planned synchronization node, and the weight values of each node are updated and the highest mark is set. When a scheduling node fails, the next node (determined by the weight value generated by the start time sequence, and by default, the one with the lowest start time is the lowest) is immediately activated as the new target scheduling node, and it can ensure that the task is triggered normally.

[0082] When the synchronization node also unfortunately fails, all task scheduling nodes in the cluster can immediately sense it, and the node with the highest weight value among the remaining cluster nodes (the node with the earliest start time among the surviving nodes except the scheduling nodes) can be immediately and automatically activated as the new planned synchronization node, and notify all other nodes through the node database to establish a two-way communication connection with it (all nodes with non-highest weight values will automatically start the method of searching for the planned synchronization node in the database to obtain the connection method of the new planned synchronization node). This achieves the high availability of the scheduler. At the same time, since the roles of the planned synchronization node and the target scheduling node may not be on the same program in the cluster mode, the reliability of the program can be effectively improved.

[0083] As the node actually having the task triggering permission, the target scheduling node can find a target task execution node with sufficient resources and good status from the execution nodes to actually execute the task. It can also establish a real-time connection with the task execution node through two-way communication, and receive the status information and performance monitoring information of the task execution node, and use this as a reference basis for the selection of the target task execution node. When a target task execution node fails, the target scheduler will ignore this node and allocate the task to other available execution nodes. At the same time, when the target task execution node fails or the task rolls back, the unexecuted or unsuccessful tasks can be allocated to other task execution nodes.

[0084] When the target scheduling node changes, after the new target scheduling node is activated, it can be actively pushed to the target task execution node in a certain form (such as a web interface) to update its connection with the new target scheduling node, ensuring that the new target scheduling node can smoothly access all task execution nodes.

[0085] The task scheduling method provided in this embodiment divides each started task scheduler into 3 roles through the socket service, which can be any role among the target scheduling node, the planned synchronization node, and the standby node. Based on the characteristics of socket communication, the connected nodes will maintain a long connection. When a node has a problem, the planned synchronization node can notify other nodes, and other nodes can immediately sense it. When the planned synchronization node has an exception, the standby node can immediately sense and implement the switch. The task scheduling node communicates with the task execution node in real time, enabling the target scheduling node to flexibly select the target task execution node for task scheduling to achieve the task plan.

[0086] Embodiment 3:

[0087] Based on the same inventive concept, this embodiment provides a task scheduling device, please refer to Figure 3As shown, it should be understood that the specific functions of the task scheduling device can refer to the description above. In order to avoid repetition, the detailed description is appropriately omitted here. The task scheduling device includes at least one software function unit that can be stored in the memory in the form of software or firmware or solidified in the operating system of the device. Specifically, the task scheduling device includes a monitoring unit 301 and a determination unit 302, wherein the monitoring unit 301 is used to monitor the startup status of the task scheduling node, and the determination unit 302 is used to determine a target scheduling node from the currently started task scheduling nodes when the number of currently started task scheduling nodes is greater than 1; wherein the target scheduling node is used to select a target task execution node for task scheduling to implement the corresponding task plan.

[0088] When receiving the task plan execution instruction, the target scheduling node in this embodiment is used to select the target task execution node to perform task scheduling to implement the corresponding task plan after obtaining the task plan corresponding to the task plan execution instruction. For example, the target scheduling node can select an idle target task execution node to perform task scheduling to implement the corresponding task plan. It is understandable that the task scheduling node can register the task plan in the database after being confirmed as the target scheduling node, or it can register the task plan after it is started.

[0089] It should be noted that if the number of currently started task scheduling nodes is 1, the determining unit 302 may directly use the task scheduling node as the target scheduling node.

[0090] The determination unit 302 can select the target scheduling node according to the startup sequence of the currently started task scheduling nodes. For example, the task scheduling node with the latest startup time can be selected from the currently started task scheduling nodes as the target scheduling node. In this way, the target task scheduling node can be refreshed in real time to ensure the reliability of the selected target task scheduling node. Of course, in other embodiments, the task scheduling node with the earliest startup time can also be selected as the target scheduling node, or the second or third started task scheduling node can be selected as the target scheduling node. The specific selection rules here can be flexibly set in advance by the developer. Of course, in other embodiments, a target scheduling node can also be randomly selected from the started task scheduling nodes, or it can also be selected according to other rules, as long as a target scheduling node is selected.

[0091] In this embodiment, a task plan can be registered on each started task scheduling node. At this time, a plan synchronization node can be determined from the currently started task scheduling nodes; wherein the plan synchronization node is used to communicate with task scheduling nodes other than itself, obtain synchronization information, and send the synchronization information to task scheduling nodes other than itself, and the synchronization information includes information on the task plan registered on each task scheduling node.

[0092] In some other embodiments, the synchronization information may further include the node information of each task scheduling node. The node information of each scheduling node may include the start time of the node and / or the current role identity information of the node. Here, the role identity information refers to whether the node is currently an ordinary task scheduling node identity, a target scheduling node identity, or a planned synchronization node identity. In this way, each task scheduling node in the scheduling system can obtain the information of task scheduling nodes other than itself through the planned synchronization node.

[0093] Similarly, in this embodiment, the determining unit 302 may determine the planned synchronization node according to the start order of the started task scheduling nodes. For example, the task scheduling node with the earliest start time may be selected as the planned synchronization node, which can reduce the switching frequency of the planned synchronization node. In other embodiments, other selection rules may be used to select the planned synchronization node. For example, it may be randomly selected from the task scheduling nodes excluding the target scheduling node. Of course, if there is only one started task scheduling node, then this task scheduling node can act as the roles of both the target scheduling node and the planned synchronization node at the same time.

[0094] It should be noted that, in another example, the task scheduling device may first determine the planned synchronization node from the started task scheduling nodes through the determining unit 302. For example, a planned synchronization node may be directly determined according to the start order of the started task scheduling nodes, and then the target scheduling node may be selected from the started task scheduling nodes through this planned synchronization node. The selection of subsequent new planned synchronization nodes and new target scheduling nodes can be implemented by the planned synchronization node, and of course, it can also be implemented by the target scheduling node.

[0095] Preferably, in this embodiment, a planned synchronization node may be selected from the started task scheduling nodes. However, in other embodiments, the number of planned synchronization nodes may also be multiple. When a certain task scheduling node updates the task plan, the task scheduling node may send the updated task plan to the planned synchronization node, and then the planned synchronization node notifies other task scheduling nodes of the updated task plan as synchronization information. If the node that updates the task plan is the planned synchronization node, this node can directly synchronize the updated task plan to other task scheduling nodes.

[0096] The task scheduling device provided in this embodiment may further include a first selection unit. When there is a first standby node of the current target scheduling node among the started task scheduling nodes, if it is detected that the target scheduling node fails, the first selection unit is used to select a node from the first standby nodes as the new target scheduling node. Here, the selection principle for selecting the new target scheduling node may be the same as or different from the principle for selecting the target scheduling node before. For example, the node that started the latest may be selected from the first standby nodes as the new target scheduling node. The first standby nodes here may be the nodes among the currently started task scheduling nodes excluding the current target scheduling node, or the nodes among the currently started task scheduling nodes excluding the current target scheduling node and the planned synchronization node.

[0097] The task scheduling device provided in this embodiment may further include a second selection unit. When there is a second standby node of the planned synchronization node among the started task scheduling nodes, if it is detected that the planned synchronization node fails, the second selection unit is used to select the task scheduling node that started the earliest from the second standby nodes as the new planned synchronization node. Here, the selection principle for selecting the new planned synchronization node may be the same as or different from the principle for selecting the planned synchronization node before. For example, the node that started the earliest may be selected from the second standby nodes as the new target scheduling node. The second standby nodes here may be the nodes among the currently started task scheduling nodes excluding the current planned synchronization node, or the nodes among the currently started task scheduling nodes excluding the current target scheduling node and the planned synchronization node.

[0098] It should be understood that, for the sake of concise description, the content described in some embodiments will not be repeated in this embodiment.

[0099] The task scheduling device provided in this embodiment determines a target scheduling node through a determination unit, and the target scheduling node selects a target task execution node for task scheduling to implement the corresponding task plan. Each task scheduling node no longer preempts task execution in a table-locking manner, avoiding a large number of threads waiting for resources, and at the same time can avoid repeated scheduling and the generation of incorrect data. In addition, the stability of task scheduling is improved through standby nodes, reducing the risks and losses brought by downtime, and having the characteristics of high efficiency and high availability.

[0100] Embodiment 4:

[0101] This embodiment provides an electronic device. Please refer to Figure 4As shown, the electronic device includes a processor 401 and a memory 402. A computer program is stored in the memory 402. The processor 401 and the memory 402 communicate through a communication bus. The processor 401 executes the computer program to implement the steps of the task scheduling method in the above-mentioned First Embodiment and / or Second Embodiment, which will not be elaborated here. It can be understood that Figure 4 The structure shown is only schematic. The electronic device may also include more or fewer components than those Figure 4 shown therein, or have a different configuration from that Figure 4 shown.

[0102] The processor 401 can be an integrated circuit chip with signal processing capabilities. The above-mentioned processor 401 can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.

[0103] The memory 402 can include, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Programmable Read-Only Memory (EPROM), an Electrically Erasable Programmable Read-Only Memory (EEPROM), etc.

[0104] This embodiment also provides a computer-readable storage medium, such as a floppy disk, an optical disc, a hard disk, a flash memory, a USB flash drive, an SD (Secure Digital Memory Card) card, an MMC (Multimedia Card) card, etc. One or more programs for implementing the above-mentioned steps are stored in the computer storage medium. These one or more programs can be executed by one or more processors 401 to implement the steps of the task scheduling method in the above-mentioned First Embodiment and / or Second Embodiment, which will not be elaborated here.

[0105] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For another example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some communication interfaces. The indirect coupling or communication connection of the devices or units can be in electrical, mechanical or other forms.

[0106] In addition, the units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0107] In this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations.

[0108] The above are only the embodiments of the present application and are not used to limit the protection scope of the present application. For those skilled in the art, the present application can have various changes and modifications. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A task scheduling method, characterized in that, Including: Monitoring the startup status of task scheduling nodes; When the number of currently started task scheduling nodes is greater than 1, determining a planned synchronization node from the currently started task scheduling nodes; and determining a target scheduling node from the currently started task scheduling nodes through the planned synchronization node; a task plan is registered on each of the task scheduling nodes; Wherein, the planned synchronization node is used to communicate with the task scheduling nodes other than itself, obtain synchronization information, and send the synchronization information to the task scheduling nodes other than itself, and the synchronization information includes information of the task plans registered on each of the task scheduling nodes and node information of each of the task scheduling nodes; the node information of each of the task scheduling nodes includes the startup time of the node and / or the current role identity information of the node; The role identity information includes the identity of an ordinary task scheduling node, the identity of a target scheduling node, and the identity of a planned synchronization node; Wherein, when receiving a task plan execution instruction, the target scheduling node is used to select a target task execution node for task scheduling to implement the corresponding task plan after obtaining the task plan corresponding to the task plan execution instruction; Wherein, the determining a planned synchronization node from the currently started task scheduling nodes includes: Selecting the task scheduling node with the earliest startup time from the started task scheduling nodes as the planned synchronization node.

2. The task scheduling method according to claim 1, characterized in that The from the current Determining a target scheduling node from the currently Started task scheduling nodes includes:

3. The task scheduling method according to claim 2, wherein Selecting the target scheduling node according to the startup order of the currently started task scheduling nodes. The selecting the target scheduling node according to the startup order of the currently Started task scheduling nodes includes: Selecting the task scheduling node with the latest startup time from the currently started task scheduling nodes as the target scheduling node; Or, when the number of currently started task scheduling nodes is greater than 1, taking the second started task scheduling node as the target scheduling node.

4. The task scheduling method according to any one of claims 1-3, characterized in that, The method further includes: When there is a first standby node of the target scheduling node among the started task scheduling nodes, if the target scheduling node fails, selecting the node with the latest startup time from the first standby nodes as the new target scheduling node.

5. The task scheduling method according to claim 1, wherein The method further includes: When there is a second standby node of the planned synchronization node among the started task scheduling nodes, if the planned synchronization node fails, selecting the task scheduling node with the earliest startup time from the second standby nodes as the new planned synchronization node.

6. A task scheduling device, characterized in that, Including: A monitoring unit for monitoring the startup status of task scheduling nodes; A determining unit for determining a planned synchronization node from the currently started task scheduling nodes when the number of currently started task scheduling nodes is greater than 1; and determining a target scheduling node from the currently started task scheduling nodes through the planned synchronization node; a task plan is registered on each of the task scheduling nodes; Among them, the planned synchronization node is used to communicate with the task scheduling nodes other than itself, obtain synchronization information, and send the synchronization information to the task scheduling nodes other than itself. The synchronization information includes the information of the task plans registered on each task scheduling node and the node information of each task scheduling node; the node information of each task scheduling node includes the startup time of the node and / or the current role identity information of the node; The role identity information includes the identity of an ordinary task scheduling node, the identity of a target scheduling node, and the identity of a planned synchronization node; Among them, when receiving a task plan execution instruction, the target scheduling node is used to select a target task execution node for task scheduling to implement the corresponding task plan after obtaining the task plan corresponding to the task plan execution instruction; The determining unit is specifically configured to select the task scheduling node with the earliest startup time from the started task scheduling nodes as the planned synchronization node.

7. An electronic device, characterized in that, Comprising a processor and a memory, the memory stores a computer program, and the processor executes the computer program to implement the method according to any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by at least one processor, the method according to any one of claims 1-5 is implemented.

Citation Information

Patent Citations

  • Distributed task scheduling method and system based on ZooKeeper and storage medium

    CN112433830A