Cluster framework task management method and related devices
By selecting low-load node backup tasks in the cluster framework and maintaining heartbeat connections with them, the problem of task interruption caused by management node failures is solved, ensuring continuous task execution and system stability.
Patent Information
- Application Number
- CN202111477304.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-06
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2041-12-06
AI Technical Summary
When the management node of the existing big data distributed task execution framework fails, all tasks cannot be submitted for execution, which brings significant impact and losses to enterprise organizations.
In the cluster framework, by receiving the client's task execution request, low-load nodes are selected as alternative nodes, the tasks to be executed are backed up to these nodes, and the connection with the alternative nodes is maintained through heartbeat packet instructions. When the management node fails, according to Preset rules determine execution nodes from candidate nodes to continue task execution.
It avoids task execution interruption caused by management node failure, improves the stability and reliability of the cluster framework, reduces the probability of alternative node failure, and ensures the continuous execution of tasks.
Smart Images

Figure CN114116178B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of data processing technology, and in particular, relates to a cluster framework task management method and related devices. Background Art
[0002] As computer technology enters the era of big data, enterprises and organizations need to submit massive amounts of tasks to asynchronous task systems every day for unified management and scheduling, in order to achieve a variety of computing functions.
[0003] The existing mainstream big data distributed task execution framework mainly adopts unequal functional division, mainly including management nodes and task execution nodes, and centrally deploys in the form of management nodes or management node clusters. Task execution nodes are deployed in a distributed manner, and each task execution node waits for the management node to dispatch tasks. When the management node fails, the system service is interrupted, which will cause all tasks to fail to be submitted for execution, causing significant impact and losses to enterprises and organizations. Summary of the invention
[0004] The purpose of this application is to provide a cluster framework task management method and related devices, aiming to ensure that when a node in the cluster framework fails and the system service is interrupted, all tasks will not be unable to be submitted for execution, thereby avoiding major impacts and losses to the enterprise organization.
[0005] This application is implemented as follows:
[0006] In a first aspect, the present application provides a cluster framework task management method, which is applied to a first node of a cluster framework composed of X nodes, where X is a positive integer greater than 0, and includes:
[0007] Receive a task execution request sent by a client, wherein the task execution request includes a task to be executed;
[0008] Select Y nodes from a low-load node list as candidate nodes, wherein the low-load node list records nodes in the cluster framework that have a load lower than the average, and Y is a positive integer greater than 1 and less than X;
[0009] Backing up the tasks to be executed to the candidate nodes to obtain corresponding backup tasks to be executed;
[0010] Execute the task to be executed, and maintain connection with the alternative node of the cluster framework through heartbeat packet instructions, so that when the alternative node determines through the heartbeat packet instructions that the first node is in a faulty state, one of the Y alternative nodes is determined as the execution node according to preset rules, and the backup task to be executed is executed by the execution node.
[0011] Optionally, before selecting Y nodes from the low-load node list as candidate nodes, the method includes:
[0012] Periodically collecting and updating the operation status information broadcast by the other nodes;
[0013] Determine the load of each node in the cluster framework from the running status information;
[0014] determining a low-load node having a load lower than an average load from the load conditions;
[0015] The low-load node list is formed by sorting the IP addresses of the low-load nodes in numerical order.
[0016] Optionally, after forming the low-load node list and before executing the to-be-performed task, the method further includes:
[0017] Sending the low-load node list to the client;
[0018] The first node selected by the client from the low-load node list is received.
[0019] Optionally, determining one of the Y candidate nodes as the execution node according to a preset rule includes:
[0020] The candidate node that is the frontmost or the backmost in the low-load node list is used as the execution node.
[0021] Optionally, before receiving the task execution request sent by the client, the method further includes:
[0022] Periodically broadcasting its own running status information to other nodes, where the other nodes are the remaining nodes among the X nodes except the first node;
[0023] Maintaining connection with the other nodes of the cluster framework through heartbeat packet instructions.
[0024] Optionally, after receiving the task execution request sent by the client and before executing the task to be executed, the method further includes:
[0025] Configure a task identification ID for the task to be executed;
[0026] Backing up the task identification ID to the candidate node to obtain the corresponding backup task identification ID;
[0027] Sending the task identification ID to the client, so that the client can use the task identification ID to request a task execution result from any node in the cluster framework;
[0028] After executing the task to be executed, the method further includes:
[0029] Receive a task execution result request sent by the client, wherein the task execution result request includes the task identification ID;
[0030] The task execution result corresponding to the task identification ID is sent to the client.
[0031] Optionally, the task execution result includes: task execution status information obtained when the task is being executed, a task execution completion result obtained after the task is successfully executed, or a task execution exception result obtained after the task fails to execute;
[0032] The executing of the task to be executed comprises:
[0033] Determine whether the number of candidate nodes is greater than 1;
[0034] If the number of candidate nodes is less than 1, the backup task to be executed is stopped, the backup task to be executed is determined as a task execution failure, and the task execution abnormality result is obtained;
[0035] If the number of the candidate nodes is greater than or equal to 1, the task to be executed is executed to obtain the task execution completion result after the task is successfully executed, or when the candidate node determines that the first node is a faulty node through the heartbeat packet instruction, the execution is triggered to determine one of the Y candidate nodes as the execution node according to the preset rules, and the execution node executes the backup task to be executed.
[0036] A second aspect of the present application provides a cluster framework task management system, which is applied to a first node of a cluster framework consisting of X nodes, where X is a positive integer greater than 0, including:
[0037] A receiving unit, configured to receive a task execution request sent by a client, wherein the task execution request includes a task to be executed;
[0038] A selection unit, configured to select Y nodes from a low-load node list as candidate nodes, wherein the low-load node list records nodes in the cluster framework with a load lower than the average load, and Y is a positive integer greater than 1 and less than X;
[0039] A backup unit, used to back up the task to be executed to the candidate node to obtain a corresponding backup task to be executed;
[0040] An execution unit is used to execute the task to be executed and maintain connection with the alternative node of the cluster framework through a heartbeat packet instruction, so that when the alternative node determines through the heartbeat packet instruction that the first node is in a faulty state, one of the Y alternative nodes is determined as an execution node according to a preset rule, and the backup task to be executed is executed by the execution node.
[0041] Optionally, the system comprises:
[0042] A synchronization unit, used for periodically collecting and updating the operation status information broadcast by the other nodes;
[0043] A determination unit, configured to determine the load condition of each node in the cluster framework from the operation status information;
[0044] The determining unit is further used to determine a low-load node with a load lower than the average load from the load situation;
[0045] A forming unit is used to form the low-load node list by sorting the IP address values of the low-load nodes.
[0046] Optionally, the system further includes:
[0047] A sending unit, configured to send the low-load node list to the client;
[0048] The receiving unit is further configured to receive the first node selected by the client from the low-load node list.
[0049] Optionally, when the execution unit determines one of the Y candidate nodes as the execution node according to a preset rule, it is specifically configured to:
[0050] The candidate node that is the frontmost or the backmost in the low-load node list is used as the execution node.
[0051] Optionally, the system further includes:
[0052] The sending unit is further used to periodically broadcast its own running status information to other nodes, where the other nodes are the remaining nodes among the X nodes except the first node;
[0053] A maintaining unit is used to maintain connection with the other nodes of the cluster framework through a heartbeat packet instruction.
[0054] Optionally, the system further includes:
[0055] A configuration unit, used to configure a task identification ID for the task to be executed;
[0056] The backup unit is further used to back up the task identification ID to the candidate node to obtain a corresponding backup task identification ID;
[0057] The sending unit is further used to send the task identification ID to the client, so that the client can use the task identification ID to request a task execution result from any node in the cluster framework;
[0058] The receiving unit is further used to receive a task execution result request sent by the client, wherein the task execution result request includes the task identification ID;
[0059] The sending unit is further used to feed back the task execution result corresponding to the task identification ID to the client.
[0060] Optionally, the task execution result includes: task execution status information obtained when the task is being executed, a task execution completion result obtained after the task is successfully executed, or a task execution exception result obtained after the task fails to execute;
[0061] When executing the task to be executed, the execution unit is specifically used to:
[0062] Determine whether the number of candidate nodes is greater than 1;
[0063] If the number of candidate nodes is less than 1, the backup task to be executed is stopped, the backup task to be executed is determined as a task execution failure, and the task execution abnormality result is obtained;
[0064] If the number of the candidate nodes is greater than or equal to 1, the task to be executed is executed to obtain the task execution completion result after the task is successfully executed, or when the candidate node determines that the first node is a faulty node through the heartbeat packet instruction, the execution is triggered to determine one of the Y candidate nodes as the execution node according to the preset rules, and the execution node executes the backup task to be executed.
[0065] A third aspect of the present application provides a computer device, including:
[0066] Processor, memory, bus, input and output interface, wireless network interface;
[0067] The processor is connected to the memory, the input / output interface, and the wireless network interface via a bus;
[0068] The memory stores a program;
[0069] When the processor executes the program stored in the memory, the cluster framework task management method described in the first aspect is implemented.
[0070] A fourth aspect of the present application provides a computer-readable storage medium, wherein the computer storage medium stores instructions, and when the instructions are executed on a computer, the computer executes the cluster framework task management method as described in the first aspect above.
[0071] A fifth aspect of the present application provides a computer program product. When the computer program product is executed on a computer, the computer executes the cluster framework task management method as described in the first aspect.
[0072] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0073] The cluster framework task management method of the present application can be applied to the first node of a cluster framework composed of X nodes, where X is a positive integer greater than 0, and the first node is any node in the cluster framework; the first node receives a task execution request including a task to be executed sent by a client, and then selects Y nodes from a low-load node list as candidate nodes, backs up the task to be executed to the candidate nodes, and obtains a corresponding backup task to be executed, where the low-load node list records the nodes in the cluster framework with a load lower than the average, and Y is a positive integer greater than 1 and less than X; then executes the task to be executed, and maintains a connection with the candidate node of the cluster framework through a heartbeat packet instruction, so that when the candidate node determines that the first node is in a faulty state through the heartbeat packet instruction, one of the Y candidate nodes is determined as an execution node according to a preset rule, and the execution node executes the backup task to be executed. It can be seen that in the cluster framework task management method of the present application, the first node maintains connection with the backup node of the cluster framework through heartbeat packet instructions. When the first node in the cluster framework is in a faulty state, the backup node can quickly know that the first node is in a faulty state. At this time, the backup node can determine one of the Y backup nodes as the execution node according to the preset rules, and the execution node executes the backup task to be executed, which will not cause all tasks to be unable to be submitted for execution. Moreover, since the backup node is a low-load node with a load lower than the average load, the probability of failure of the backup node is smaller, thereby avoiding major impacts and losses to the enterprise organization. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] Figure 1 A schematic diagram of the connection topology between various nodes and clients of the cluster framework of the present application;
[0075] Figure 2 A flowchart of an embodiment of the cluster framework task management method of the present application;
[0076] Figure 3 A schematic diagram of an interaction flow between a client, a first node and other nodes in a cluster framework task management method of the present application;
[0077] Figure 4 This is a schematic diagram of the structure of an embodiment of the cluster framework task management framework of this application;
[0078] Figure 5 This is a schematic diagram of the structure of an embodiment of a computer device of the present application. DETAILED DESCRIPTION
[0079] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0080] It should be noted that when an element is referred to as being "fixed to" or "disposed on" another element, it may be directly on the other element or there may be an intermediate element at the same time. When an element is referred to as being "connected to" another element, it may be directly connected to the other element or there may be an intermediate element at the same time.
[0081] It should also be noted that the directional terms such as left, right, up, and down in this embodiment are merely relative concepts or are based on the normal use status of the product and should not be considered as restrictive.
[0082] See also Figure 1 The cluster framework task management method of this application is applied to a cluster framework composed of several nodes. Figure 1 Only a scene in which six nodes are interconnected is shown, and there are at least two communication links between every two nodes in the cluster framework, preferably, each node is connected by an independent communication link, and the communication link can be a wired network or a wireless network. In the embodiment of the present application, each node of the cluster framework has the same program function, the relationship between each node is equal, each node can independently receive the task execution request of the client, the client can connect to any node in the cluster framework through a wired network or a wireless network, and each node will broadcast the operation status information of its own node to the outside at a regular interval, and each node will collect and update the operation status information sent by other nodes, and the operation status information includes but is not limited to: message version, timestamp, node information, system operation load, current full task information, task identification ID of each task, etc.
[0083] See also Figure 2An embodiment of the cluster framework task management method of the present application is applied to the first node of a cluster framework composed of X nodes, where X is a positive integer greater than 0; it can be understood that since each node in the cluster framework has the same program function, the following embodiment only takes the first node of the cluster framework as an example for explanation, and the first node can be any node of the cluster framework. The method of this embodiment mainly includes:
[0084] 201. Receive a task execution request sent by a client, where the task execution request includes a task to be executed.
[0085] The first node in the cluster framework integrates the task execution function and the task management function, and can be used to receive the task execution request sent by the client in this step. The task execution request at least includes the task to be executed.
[0086] 202. Select Y nodes from a low-load node list as candidate nodes. The low-load node list records nodes in the cluster framework that have a load lower than the average.
[0087] The first node of this embodiment needs to generate and maintain a low-load node list in advance, and the low-load node list records the nodes in the entire cluster framework that are below the average load. That is, the first node can know the relatively idle nodes (nodes below the average load) in the entire cluster framework through the low-load node list, so that this step can select Y nodes from these nodes below the average load as candidate nodes, where Y is a positive integer greater than 1 and less than X, for example, Y is equal to 2.
[0088] 203. Back up the tasks to be executed to the candidate node to obtain the corresponding backup tasks to be executed.
[0089] In order to avoid the failure of the first node to cause the task to be unable to be completed, this step first backs up the task to be executed to the alternative node, and obtains the corresponding backup task to be executed in the alternative node.
[0090] 204. Execute the task to be executed, and maintain connection with the standby node of the cluster framework through the heartbeat packet instruction, so that when the standby node determines through the heartbeat packet instruction that the first node is in a faulty state, one of the Y standby nodes is determined as the execution node according to the preset rules, and the execution node executes the backup task to be executed.
[0091] After the first node backs up the task to be executed to the alternative node in step 203, it executes the task to be executed in this step and maintains connection with the alternative node of the cluster framework through the heartbeat packet instruction. If the first node can successfully execute the task to be executed and obtain the task execution completion result, it indicates that the first node is in a normal state, and the first node in the normal state can maintain connection with the alternative node of the cluster framework through the heartbeat packet instruction; but when the first node fails in the process of executing the task to be executed, the first node cannot maintain connection with the alternative node of the cluster framework through the heartbeat packet instruction, then the alternative node The node can determine whether the first node is in a faulty state through the heartbeat packet instruction. For example, if the standby node sends a heartbeat packet instruction to the first node for more than a certain number of rounds and still does not receive a reply from the first node, or the standby node does not receive a heartbeat packet instruction from the first node for more than a preset time, it can be determined that the first node is in a faulty state. When the standby node determines that the first node is in a faulty state, one of the Y standby nodes is determined as the execution node according to the preset rules, and the execution node executes the backup task to be executed. The preset rules can be set according to actual needs and are not limited here.
[0092] It can be seen that in the cluster framework task management method of the present application, the first node maintains connection with the backup node of the cluster framework through heartbeat packet instructions. When the first node in the cluster framework is in a faulty state, the backup node can quickly know that the first node is in a faulty state. At this time, the backup node can determine one of the Y backup nodes as the execution node according to the preset rules, and the execution node executes the backup task to be executed, which will not cause all tasks to be unable to be submitted for execution. Moreover, since the backup node is a low-load node with a load lower than the average load, the probability of failure of the backup node is smaller, thereby avoiding major impacts and losses to the enterprise organization.
[0093] See also Figure 3 , an interactive embodiment between a client, a first node, and other nodes in the cluster framework task management method of the present application, wherein the client is used to issue a task execution request to the first node in the cluster framework, the first node is any node in the cluster framework, and the other nodes refer to the remaining nodes in the cluster framework except the first node (its own node), and the other nodes in this embodiment also refer to candidate nodes, wherein the candidate nodes are some of the other nodes, including:
[0094] 301. The first node periodically broadcasts its own operation status information to other nodes, and maintains connection with other nodes through heartbeat packet instructions.
[0095] The first node of the cluster framework of the embodiment of the present application actively and periodically broadcasts its own operating status information to other nodes, and maintains connection with other nodes through heartbeat packet instructions, wherein the operating status information includes but is not limited to: message version, timestamp, node information, system operating load, current full task information, task identification ID of each task, etc.
[0096] 302. The first node collects and updates the running status information broadcast by other nodes.
[0097] Similarly, as a node in the cluster framework, the first node also collects and updates the running status information broadcast by other nodes so as to know the running status of other nodes.
[0098] 303. The first node determines the load status of each node in the cluster framework from the running status information.
[0099] Since the running status information broadcast by each node to other nodes includes timestamp, node information, system running load, current full task information, task identification ID of each task, IP address, etc., this step can calculate the load status of the corresponding node based on the above running status information.
[0100] 304. The first node determines a low-load node with a load lower than the average load from the load status.
[0101] After knowing the load status of each node in the cluster framework in step 303, the first node can further calculate the average load of the entire cluster framework in this step, and then calculate the difference between the load of each node in the entire cluster framework and the average load, so as to screen out low-load nodes in the entire cluster framework that are lower than the average load.
[0102] 305. The first node sorts the low-load nodes according to the numerical values of the IP addresses of the low-load nodes to form a low-load node list.
[0103] After determining the low-load nodes with a load lower than the average load in step 304, this step can sort the low-load nodes according to certain rules to form a low-load node list. For example, the low-load node list is formed by sorting the IP address values of the low-load nodes (sorting from small to large or from large to small according to the IP address values).
[0104] 306. The first node receives a task execution request sent by the client, where the task execution request includes a task to be executed.
[0105] The execution of this step is Figure 2 Step 201 in the embodiment is similar, and the repeated parts are not repeated here.
[0106] It should be noted that the client can communicate with any node of the cluster framework in the embodiment of the present application (for example Figure 1 The second node, the third node, the fourth node, the fifth node, the sixth node, etc. shown in the figure send a task execution request. This step is described with the first node as representing any node of the cluster framework. In another embodiment, the client can also arbitrarily specify multiple nodes or node domain names to send task execution requests.
[0107] 307. The first node sends a low-load node list to the client.
[0108] After the first node receives the task execution request sent by the client in step 306, the first node sends a low-load node list to the client so that the client can learn the node that can currently be selected to execute its task through the low-load node list.
[0109] 308. The client selects a first node in the low-load node list.
[0110] The client needs to select a node from the low-load node list received in step 307 to execute the to-be-executed task required by its task execution request. This step is described by taking the client specifying to select the first node as an example.
[0111] 309. The first node receives confirmation information from the client selecting the first node.
[0112] After the client selects the first node to execute its to-be-executed task in step 308, the first node will receive confirmation information sent by the client.
[0113] 310. The first node configures a task identification ID for the task to be executed.
[0114] Since the first node acts as a peer node in the cluster framework, it not only executes the pending task sent by a certain client, but may also execute tasks of other clients at the same time. In order to distinguish different tasks, before executing the pending task, the first node configures a task identification ID for the pending task in this step, and the task identification ID is unique.
[0115] 311. The first node sends a task identification ID to the client.
[0116] The task identification ID configured in step 310 for the task to be executed is sent to the client, so that the client can use the task identification ID to request the task execution result from any node in the cluster framework in subsequent steps.
[0117] 312. The first node selects Y nodes from the low-load node list as candidate nodes.
[0118] The execution of this step is Figure 2 Step 202 in the embodiment is similar, and the repeated parts are not repeated here.
[0119] 313. The first node backs up the task identification ID to the candidate node to obtain the corresponding backup task identification ID; the first node backs up the task to be executed to the candidate node to obtain the corresponding backup task to be executed.
[0120] In order to avoid the failure of the first node to cause the task to be unable to be completed, this step first backs up the task to be executed and the task identification ID to the alternative node, and obtains the corresponding backup task to be executed and the backup task identification ID in the alternative node.
[0121] 314. The first node executes the task to be executed.
[0122] After completing the backup work in step 313, the first node starts to execute the task to be executed, which may be big data analysis, audio and video decoding, etc., and the task to be executed is not further limited here. During the process of executing the task to be executed, the first node maintains connection with other nodes (including candidate nodes) in the cluster framework through heartbeat packet instructions.
[0123] 315. The first node execution failed.
[0124] When the first node fails in the process of executing the task to be executed in step 314, the first node cannot maintain connection with the alternative node of the group framework through the heartbeat packet instruction, then the alternative node can determine whether the first node is in a faulty state through the heartbeat packet instruction. For example, if the alternative node sends a heartbeat packet instruction to the first node for more than a certain number of rounds and still does not receive a reply from the first node, or the alternative node does not receive a heartbeat packet instruction from the first node for more than a preset period of time, the alternative node can determine that the first node is in a faulty state, indicating that the execution of the first node has failed.
[0125] 316. The first node task is executed successfully, and the task execution completion result is obtained.
[0126] When the first node can successfully complete the task to be executed in step 314, this step can obtain the task execution completion result, indicating that the first node is in a normal state, and the first node in the normal state can maintain connection with the alternative node of the cluster framework through heartbeat packet instructions.
[0127] 317. When the backup node determines that the first node is in a faulty state through a heartbeat packet instruction, one of the backup nodes is determined as an execution node according to a preset rule, and the execution node executes the backup task to be executed.
[0128] It is understandable that when the candidate node determines that the first node is in a faulty state through the heartbeat packet instruction, that is, in step 315, the candidate node determines that the first node is in a faulty state, and when the first node fails to execute, the candidate nodes will automatically negotiate and determine one of the candidate nodes as the execution node according to the preset rules, and the execution node executes the backup task to be executed. For example, the execution node is determined according to the numerical value of the IP address of the candidate node in the low-load node list (the first or the last).
[0129] Specifically, before executing the backup task to be executed, the execution node also needs to determine whether the number of candidate nodes is greater than 1. If the number of candidate nodes is less than 1, it indicates that there is no node in the cluster framework that supervises and replaces the execution node. At this time, the task should not be executed. The current execution node is the last node to process the task, so the execution of the backup task to be executed is stopped, and the backup task to be executed is deemed to be a task execution failure, and an abnormal task execution result is obtained; if the number of candidate nodes is greater than or equal to 1, it indicates that there is a node in the cluster framework that supervises and replaces the execution node. At this time, the task can be executed, so the task to be executed is executed, and the task execution completion result after the task execution is successful is obtained.
[0130] 318. The alternative node determines that the task execution fails and obtains an abnormal task execution result.
[0131] It is understandable that the execution node may fail to execute the backup task to be executed in step 317. Specifically, before executing the backup task to be executed, the execution node needs to determine whether the number of candidate nodes is greater than 1. If the number of candidate nodes is less than 1, it indicates that there is no node in the cluster framework that supervises and replaces the execution node. At this time, the task should not be executed. The current execution node is the last node to process the task, so the execution of the backup task to be executed is stopped, and the backup task to be executed is determined to be a task execution failure, and an abnormal task execution result is obtained.
[0132] 319. The alternative node task is executed successfully, and the task execution completion result is obtained.
[0133] It is understandable that in step 317, the execution node may successfully execute the backup pending task and obtain the task execution completion result.
[0134] 320. Each node of the cluster framework synchronizes the task execution completion results between the nodes.
[0135] After the task to be executed is successfully executed in step 316 or step 319, the first node or the execution node will synchronize the task execution completion result in the cluster framework so that each node in the cluster framework stores the task execution completion result corresponding to the task identification ID.
[0136] 321. The client sends a task execution result request to the first node, where the task execution result request includes a task identification ID.
[0137] After step 316, the first node may receive the task execution result request sent by the client, and the first node may feedback the corresponding task execution completion result to the client according to the task identification ID carried in the task execution result request.
[0138] 322. The first node sends the task execution status information corresponding to the task ID or the task execution completion result to the client.
[0139] When the first node receives the task execution result request from the client in step 321, it may be executing the task corresponding to the task identification ID, and at this time, sends the task execution status information corresponding to the task ID to the client, and the task execution status information includes the current task execution progress percentage, the current task execution duration, etc. When the first node receives the task execution result request from the client in step 321, it may have completed the task corresponding to the task identification ID, and at this time, sends the task execution completion result corresponding to the task ID to the client.
[0140] 323. The client sends a task execution result request to other nodes, where the task execution result request includes a task ID.
[0141] After step 315, step 318 or step 319, since the first node is in a faulty state, the client can only request the task execution result through other nodes (except the first node).
[0142] 324. Other nodes send to the client the task execution status information obtained when the task corresponding to the task ID is being executed, the task execution completion result obtained after the task is successfully executed, or the task execution exception result obtained after the task fails.
[0143] It can be seen that in the cluster framework task management method of the present application, the first node and the backup node of the cluster framework maintain connection through heartbeat packet instructions. When the first node in the cluster framework is in a faulty state, the backup node can quickly know that the first node is in a faulty state. At this time, the backup node can determine one of the Y backup nodes as the execution node according to the preset rules, and the execution node executes the backup task to be executed, which will not cause all tasks to be unable to be submitted for execution. Moreover, since the backup node is a low-load node with a load lower than the average load, the probability of failure of the backup node is smaller, thereby avoiding major impacts and losses on the enterprise organization, and avoiding the overall system paralysis due to problems with a node in the cluster framework, thereby improving the stability, reliability, scalability and maintainability of the cluster framework service, and even if there is only one node left in the cluster framework, it can continue to provide services.
[0144] The above embodiment describes the cluster framework task management method of the present application. The following describes the cluster framework task management system of the present application. Figure 4 , a cluster framework task management system, applied to the first node of a cluster framework consisting of X nodes, where X is a positive integer greater than 0, including:
[0145] A receiving unit 401 is used to receive a task execution request sent by a client, wherein the task execution request includes a task to be executed;
[0146] A selection unit 402 is used to select Y nodes from a low-load node list as candidate nodes, wherein the low-load node list records nodes in the cluster framework with a load lower than the average load, and Y is a positive integer greater than 1 and less than X;
[0147] A backup unit 403 is used to back up the task to be executed to the candidate node to obtain a corresponding backup task to be executed;
[0148] The execution unit 404 is used to execute the task to be executed and maintain connection with the backup node of the cluster framework through a heartbeat packet instruction, so that when the backup node determines through the heartbeat packet instruction that the first node is in a faulty state, one of the Y backup nodes is determined as the execution node according to a preset rule, and the backup task to be executed is executed by the execution node.
[0149] Optionally, the system comprises:
[0150] A synchronization unit 405, configured to periodically collect and update the operation status information broadcast by the other nodes;
[0151] A determination unit 406, configured to determine the load status of each node in the cluster framework from the operation status information;
[0152] The determining unit 406 is further configured to determine a low-load node having a load lower than an average load from the load condition;
[0153] The forming unit 407 is used to form the low-load node list by sorting the IP address values of the low-load nodes.
[0154] Optionally, the system further includes:
[0155] A sending unit 408, configured to send the low-load node list to the client;
[0156] The receiving unit 401 is further configured to receive the first node selected by the client from the low-load node list.
[0157] Optionally, when the execution unit 404 determines one of the Y candidate nodes as the execution node according to a preset rule, it is specifically configured to:
[0158] The candidate node that is the frontmost or the backmost in the low-load node list is used as the execution node.
[0159] Optionally, the system further includes:
[0160] The sending unit 408 is further configured to periodically broadcast its own running status information to other nodes, where the other nodes are the remaining nodes among the X nodes except the first node;
[0161] The maintaining unit 409 is used to maintain the connection with the other nodes of the cluster framework through the heartbeat packet instruction.
[0162] Optionally, the system further includes:
[0163] The configuration unit 4110 is used to configure a task identification ID for the task to be executed;
[0164] The backup unit 403 is further used to back up the task identification ID to the candidate node to obtain a corresponding backup task identification ID;
[0165] The sending unit 408 is further configured to send the task identification ID to the client, so that the client can use the task identification ID to request a task execution result from any node in the cluster framework;
[0166] The receiving unit 401 is further configured to receive a task execution result request sent by the client, wherein the task execution result request includes the task identification ID;
[0167] The sending unit 408 is further configured to feed back the task execution result corresponding to the task identification ID to the client.
[0168] Optionally, the task execution result includes: task execution status information obtained when the task is being executed, a task execution completion result obtained after the task is successfully executed, or a task execution exception result obtained after the task fails to execute;
[0169] When executing the task to be executed, the execution unit 404 is specifically used to:
[0170] Determine whether the number of candidate nodes is greater than 1;
[0171] If the number of candidate nodes is less than 1, the backup task to be executed is stopped, the backup task to be executed is determined as a task execution failure, and the task execution abnormality result is obtained;
[0172] If the number of the candidate nodes is greater than or equal to 1, the task to be executed is executed to obtain the task execution completion result after the task is successfully executed, or when the candidate node determines that the first node is a faulty node through the heartbeat packet instruction, the execution is triggered to determine one of the Y candidate nodes as the execution node according to the preset rules, and the execution node executes the backup task to be executed.
[0173] The cluster framework task management system of the embodiment of the present application performs the same operations as the aforementioned Figure 1 , Figure 2 The operations performed by the first node and the candidate node in the embodiment are similar and will not be described in detail here.
[0174] It can be seen that the cluster framework task management system of the present application maintains a connection between the first node and the backup node of the cluster framework through heartbeat packet instructions. When the first node in the cluster framework is in a faulty state, the backup node can quickly know that the first node is in a faulty state. At this time, the backup node can determine one of the Y backup nodes as the execution node according to the preset rules, and the execution node executes the backup task to be executed, which will not cause all tasks to be unable to be submitted for execution. Moreover, since the backup node is a low-load node with a load lower than the average load, the probability of failure of the backup node is smaller, thereby avoiding major impacts and losses to the enterprise organization.
[0175] The following describes the computer device of the embodiment of the present application. Figure 5 , an embodiment of the computer device in the embodiment of the present application includes:
[0176] The computer device 500 may include one or more processors (central processing units, CPU) 501 and a memory 502, in which one or more application programs or data are stored. The memory 502 is a volatile storage or a persistent storage. The program stored in the memory 502 may include one or more modules, and each module may include a series of instruction operations in the computer device. Furthermore, the processor 501 may be configured to communicate with the memory 502 to execute a series of instruction operations in the memory 502 on the computer device 500. The computer device 500 may also include one or more wireless network interfaces 503, one or more input and output interfaces 504, and / or one or more operating systems, such as Windows Server, Mac OS, Unix, Linux, FreeBSD, etc. The processor 501 may execute the aforementioned Figure 1 to Figure 2 The operations performed by the first node in the illustrated embodiment will not be described in detail here.
[0177] In several embodiments provided in the embodiments of the present application, those skilled in the art should understand that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the unit is only a logical function division. There may be other division methods in actual implementation, such as 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 mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0178] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.
[0179] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions or improvements made within the spirit and principles of the present application should be included in the protection scope of the present application.
Claims
1. A cluster framework task management method, characterized in that: Applied to the first node of a cluster framework consisting of X nodes, where X is a positive integer greater than 0, including: Receive a task execution request sent by a client, wherein the task execution request includes a task to be executed; Select Y nodes from a low-load node list as candidate nodes, wherein the low-load node list records nodes in the cluster framework that have a load lower than the average, and Y is a positive integer greater than 1 and less than X; Backing up the tasks to be executed to the candidate nodes to obtain corresponding backup tasks to be executed; Execute the task to be executed, and maintain connection with the alternative node of the cluster framework through heartbeat packet instructions, so that when the alternative node determines through the heartbeat packet instructions that the first node is in a faulty state, one of the Y alternative nodes is determined as the execution node according to preset rules, and the backup task to be executed is executed by the execution node.
2. The cluster framework task management method according to claim 1, characterized in that: Before selecting Y nodes from the low-load node list as candidate nodes, the method includes: Periodically collect and update the operating status information broadcast by other nodes; Determine the load of each node in the cluster framework from the running status information; determining a low-load node having a load lower than an average load from the load conditions; The low-load node list is formed by sorting the IP addresses of the low-load nodes in numerical order.
3. The cluster framework task management method according to claim 2 is characterized in that: After forming the low-load node list and before executing the to-be-performed task, the method further includes: Sending the low-load node list to the client; The first node selected by the client from the low-load node list is received.
4. The cluster framework task management method according to claim 2 is characterized in that: Determining one of the Y candidate nodes as the execution node according to a preset rule includes: The candidate node that is the frontmost or the backmost in the low-load node list is used as the execution node.
5. The cluster framework task management method according to claim 1, characterized in that: Before receiving the task execution request sent by the client, the method further includes: Periodically broadcasting its own running status information to other nodes, where the other nodes are the remaining nodes among the X nodes except the first node; Maintaining connection with the other nodes of the cluster framework through heartbeat packet instructions.
6. The cluster framework task management method according to claim 1, characterized in that: After receiving the task execution request sent by the client and before executing the task to be executed, the method further includes: Configure a task identification ID for the task to be executed; Backing up the task identification ID to the candidate node to obtain the corresponding backup task identification ID; Sending the task identification ID to the client, so that the client can use the task identification ID to request a task execution result from any node in the cluster framework; After executing the task to be executed, the method further includes: Receive a task execution result request sent by the client, wherein the task execution result request includes the task identification ID; The task execution result corresponding to the task identification ID is sent to the client.
7. The cluster framework task management method according to claim 6, characterized in that: The task execution result includes: task execution status information obtained when the task is being executed, task execution completion result obtained after successful task execution, or task execution exception result obtained after failed task execution; The executing of the task to be executed comprises: Determine whether the number of candidate nodes is greater than 1; If the number of candidate nodes is less than 1, the backup task to be executed is stopped, the backup task to be executed is determined as a task execution failure, and the task execution abnormality result is obtained; If the number of the candidate nodes is greater than or equal to 1, the task to be executed is executed to obtain the task execution completion result after the task is successfully executed, or when the candidate node determines that the first node is a faulty node through the heartbeat packet instruction, the execution is triggered to determine one of the Y candidate nodes as the execution node according to the preset rules, and the execution node executes the backup task to be executed.
8. A cluster framework task management system, characterized in that: Applied to the first node of a cluster framework consisting of X nodes, where X is a positive integer greater than 0, including: A receiving unit, configured to receive a task execution request sent by a client, wherein the task execution request includes a task to be executed; A selection unit, configured to select Y nodes from a low-load node list as candidate nodes, wherein the low-load node list records nodes in the cluster framework with a load lower than the average load, and Y is a positive integer greater than 1 and less than X; A backup unit, used to back up the task to be executed to the candidate node to obtain a corresponding backup task to be executed; An execution unit is used to execute the task to be executed and maintain connection with the alternative node of the cluster framework through a heartbeat packet instruction, so that when the alternative node determines through the heartbeat packet instruction that the first node is in a faulty state, one of the Y alternative nodes is determined as an execution node according to a preset rule, and the backup task to be executed is executed by the execution node.
9. A computer device, characterized in that: include: Processor, memory, bus, input and output interface, wireless network interface; The processor is connected to the memory, the input / output interface, and the wireless network interface via a bus; The memory stores a program; When the processor executes the program stored in the memory, the cluster framework task management method described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: The computer storage medium stores instructions, and when the instructions are executed on a computer, the computer executes the cluster framework task management method according to any one of claims 1 to 7.
