Scheduled task processing method, device, system, computer equipment and storage medium
By loading the same task templates in multiple schedulers and generating tasks to be executed, the problems of single point failure and task omissions and repetition in the scheduling system are solved, and the stable operation of the system is achieved.
Patent Information
- Application Number
- CN202010426624.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-05-19
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2040-05-19
AI Technical Summary
In the existing scheduling engine system, single-machine generation tasks are prone to single-point failures, while distributed production tasks may have problems such as task omissions and task duplication, affecting system stability.
By loading task templates with the same content in multiple schedulers of the scheduling system, the current task identification and task parameters are analyzed and generated, and the task to be executed is generated through the task generation node. When the same current task identity does not exist in the database, save the task to be executed.
It solves the problem of unsustainable output caused by single point of failure and the task omissions and repetition caused by the master and standby mechanism, and ensures the operation stability of the scheduling system.
Smart Images

Figure CN111666138B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus, system, computer equipment and storage medium for processing scheduled tasks. Background Art
[0002] The task production in the existing scheduling engine system is divided into single-machine production tasks and distributed production tasks. Among them, single-machine generation tasks are prone to single point failure problems, that is, when a single point occurs, it is difficult to ensure the continuous output of services. Distributed production tasks, by deploying multiple hosts, multiple engines can provide scheduling services at the same time, but the distribution needs to adopt a master-slave mechanism, which is prone to task omissions and task duplications. Task omissions refer to the fact that there is no backup machine to execute the task for a short period of time when a failure occurs. Task duplication refers to the fact that multiple backup machines execute the task at the same time when a failure occurs, thus affecting the stability of the system. Summary of the invention
[0003] In order to solve the above technical problems, the present application provides a scheduled task processing method, apparatus, computer equipment and storage medium.
[0004] This application provides a scheduled task processing method, including:
[0005] Using each scheduler in the scheduling system to load the task template, at least two schedulers in the scheduling system load the task template with the same content, the task template includes the execution time, the task identifier and the task parameters, and the execution time is the time for the scheduled execution of the task in the task template;
[0006] Each scheduler parses each task template and generates a current task identifier and corresponding task parameters of each task template. The current task identifier includes the execution time and the task identifier.
[0007] Each scheduler sends the current task identifier and corresponding task parameters to the task generation node in the scheduling system;
[0008] Generate tasks to be executed through the task generation node according to the current task identifier and corresponding task parameters;
[0009] When there is no current task ID identical to the task to be executed in the database, the task to be executed is saved.
[0010] The present application provides a timed task processing device, comprising:
[0011] The template loading module is used to load the task template using each scheduler in the scheduling system, and load the task template with the same content in at least two schedulers in the scheduling system, wherein the task template includes the execution time, the task identifier and the task parameters, and the execution time is the time for executing the task in the task template regularly;
[0012] The parsing module is used for each scheduler to parse each task template and generate the current task identifier and corresponding task parameters of each task template. The current task identifier includes the execution time and the task identifier.
[0013] The data sending module is used for each scheduler to send the current task identifier and the corresponding task parameters to the task generation node in the scheduling system;
[0014] A task generation module is used to generate a task to be executed according to the current task identifier and corresponding task parameters through a task generation node;
[0015] The task storage module is used to save the task to be executed when there is no current task identifier identical to the task to be executed in the database.
[0016] A scheduled task processing system, characterized in that the system includes multiple schedulers, multiple task generation nodes and multiple task consumption nodes, wherein:
[0017] Scheduler, used to load and parse task templates. There are at least two copies of each task template in the scheduling system, and each copy is located in a different scheduler;
[0018] The task generation node is used to generate tasks to be executed according to the parameters in the task template of the scheduler;
[0019] Consumption node, used to consume tasks to be executed.
[0020] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are implemented:
[0021] Using each scheduler in the scheduling system to load the task template, at least two schedulers in the scheduling system load the task template with the same content, the task template includes the execution time, the task identifier and the task parameters, and the execution time is the time for the scheduled execution of the task in the task template;
[0022] Each scheduler parses each task template and generates a current task identifier and corresponding task parameters of each task template. The current task identifier includes the execution time and the task identifier.
[0023] Each scheduler sends the current task identifier and corresponding task parameters to the task generation node in the scheduling system;
[0024] Generate tasks to be executed through the task generation node according to the current task identifier and corresponding task parameters;
[0025] When there is no current task ID identical to the task to be executed in the database, the task to be executed is saved.
[0026] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0027] Using each scheduler in the scheduling system to load the task template, at least two schedulers in the scheduling system load the task template with the same content, the task template includes the execution time, the task identifier and the task parameters, and the execution time is the time for the scheduled execution of the task in the task template;
[0028] Each scheduler parses each task template and generates a current task identifier and corresponding task parameters of each task template. The current task identifier includes the execution time and the task identifier.
[0029] Each scheduler sends the current task identifier and corresponding task parameters to the task generation node in the scheduling system;
[0030] Generate tasks to be executed through the task generation node according to the current task identifier and corresponding task parameters;
[0031] When there is no current task ID identical to the task to be executed in the database, the task to be executed is saved.
[0032] The above-mentioned scheduled task processing method, device, system, computer equipment and storage medium load and parse task templates with the same content through multiple different schedulers in the scheduling system, and send the parameters obtained by parsing to the task generation node to generate multiple identical tasks to be executed. When executing tasks, when one of the schedulers fails, the task templates loaded on other schedulers can be used to solve the problems of unsustainable output and master-slave mechanism caused by single point failure, and the problems caused by host failure, thereby ensuring the operational stability of the scheduling system. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0035] Figure 1 An application environment diagram of a scheduled task processing method in an embodiment;
[0036] Figure 2 A schematic diagram of a flow chart of a method for processing a scheduled task in an embodiment;
[0037] Figure 3 It is an architecture deployment diagram of a scheduled task processing system in one embodiment;
[0038] Figure 4 is a timing flow chart of a method for processing a scheduled task in an embodiment;
[0039] Figure 5 is a schematic diagram of a configuration interface of a task template in an embodiment;
[0040] Figure 6 A schematic diagram of a configuration interface of a cron expression in one embodiment;
[0041] Figure 7 is a structural block diagram of a timing task processing device in an embodiment;
[0042] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0044] Figure 1 FIG. 1 is an application environment diagram of a method for processing scheduled tasks in an embodiment. Figure 1 The scheduled task processing method is applied to a scheduled task processing system 100. The scheduled task processing system includes a scheduler cluster 110 (including a scheduler 111 and a scheduler 112), a task generation node cluster 120 (including a task generation node 121 and a task generation node 122), and a task consumption node cluster 130 (including a task consumption node 131 and a task consumption node 132). The scheduler cluster 110, the task generation node cluster 120, and the task consumption node cluster 130 can all be implemented using an independent server or a server cluster consisting of multiple servers.
[0045] like Figure 2As shown, in one embodiment, a method for processing a scheduled task is provided. This embodiment mainly applies the method to the above Figure 1 The scheduling system 100 in FIG. Figure 2 , the scheduled task processing method specifically includes the following steps:
[0046] Step S201, using each scheduler in the scheduling system to load the task template.
[0047] In this specific embodiment, task templates with the same content are loaded into at least two schedulers of the scheduling system, and the task templates include execution time, task identifier and task parameters.
[0048] Step S202: Each scheduler parses each task template to generate a current task identifier and corresponding task parameters of each task template.
[0049] In this specific embodiment, the current task identifier includes an execution time and a task identifier.
[0050] Step S203: Each scheduler sends the current task identifier and corresponding task parameters to the task generation node in the scheduling system.
[0051] Step S204, generating a task to be executed according to the current task identifier and corresponding task parameters through a task generation node.
[0052] Step S205: When there is no current task identifier identical to the task to be executed in the database, the task to be executed is saved.
[0053] Specifically, the scheduler is used to load and parse the task template. The task template is a data template generated according to the configured task parameters. The task template includes the execution time, the execution location, the execution content and the task identifier, etc. Different task templates define different tasks. The scheduling system includes multiple schedulers, each task template is loaded into the scheduler, and each task template exists at least two copies in the scheduling system, and each task template is located in a different scheduler. The task template loaded by each scheduler can be customized according to business needs, and it is only necessary to ensure that each task template is loaded, and no less than two schedulers load task templates with the same content. For example, more than two schedulers are used to load two identical task templates, or each scheduler loads part of the task templates in all task templates, and there are partial overlaps in the task templates of at least three schedulers. The schedulers can also be grouped, and each scheduler group loads the corresponding task template. When the scheduler inside the scheduler group loads the task template, it can also be divided into each scheduler in the scheduler to load all the task templates corresponding to the scheduler group, or each scheduler can load part of the task template corresponding to the scheduler group.
[0054] The scheduler parses the parameters in the task template, obtains the task parameters in the task template, and generates an identifier containing the task identifier and execution time, namely the current task identifier. The current task identifier and task parameters are sent to the task generation node, which generates an executable task based on the current task identifier and task parameters.
[0055] In one embodiment, the scheduling system includes at least two schedulers, and each of the schedulers is used to load all task templates. For example, if the scheduling system includes three schedulers and 1,000 task templates, all three schedulers can load the 1,000 task templates. In the case of fewer task templates, each scheduler can be used to load all task templates.
[0056] In one embodiment, each scheduler loads part of the task templates among all the task templates, and the part of the task templates among all the task templates in each scheduler are the same as the part of the task templates in at least two schedulers among the other schedulers.
[0057] In a specific embodiment, there are currently 100,000 task templates that need to be processed, and there are 10 schedulers, each of which processes 20,000 task templates. For example, scheduler 1 processes task templates with serial numbers of 10,000 to 20,000, and scheduler 2 processes task templates with serial numbers of 10,000 to 30,000. By analogy, scheduler 10 processes task templates with serial numbers of 90,000 to 100,000 and 10,000 to 110,000. Each scheduler is loaded with 20,000 task templates, and each task template is loaded by two different schedulers. This specific embodiment is used to illustrate one of the loading methods of task templates. Other loading methods can also be used according to needs to ensure that each task template is loaded by at least two different schedulers. If the number of scheduled task templates increases, each scheduler loads all the task templates, resulting in an excessively high load on the scheduler. In order to improve this problem, the task templates can be divided, and each scheduler only loads part of the task templates, thereby reducing the load on the scheduler.
[0058] In one embodiment, the scheduling system includes multiple scheduling groups, each scheduling group includes at least two schedulers, and all task templates are obtained; all task templates are divided according to groups to obtain multiple task template sets, and each scheduling group corresponds to a task template set; each scheduler in each scheduling group is used to load the task template set corresponding to the scheduling group.
[0059] Specifically, the task parsing service is divided into multiple groups in a sharding manner, that is, multiple task template groups are obtained, and each scheduling group corresponds to a task template group. The task template group corresponding to the scheduling group can adopt the method of each scheduler in the scheduling group loading all the task templates in the task template group during scheduling, or each scheduler can load part of the task templates to perform the loading of the task template. Deployment according to the scheduling group can also be carried out. The task templates can be divided, and the divided task templates are matched with the scheduling group, so that the system business deployment is clearer. And deployment according to the scheduling group is also convenient for the expansion of the scheduler, that is, the more scheduling groups are set, the more task templates can be loaded, thereby realizing the expansion of the scheduling system.
[0060] In a specific embodiment, multiple service processes are started, each process scans the same number of task templates, and multiple processes parse simultaneously. When the number of task templates is large, the task template list can be divided into multiple groups according to the slicing method to form a large cluster. Based on the consideration of load balancing and code simplicity, each thread scans the same number of task templates.
[0061] In one embodiment, the scheduler is stateless deployment. The stateless deployment can be expanded horizontally according to business needs. The expansion method is simple, that is, directly adding a corresponding scheduler without copying the state information between schedulers to the new scheduler.
[0062] In one embodiment, the last execution time of the current task template is obtained; the current execution time of the current task template is calculated according to the time expression of the current task template and the last execution time of the current task template, and the current execution time of the current task template is used as the execution time of the current task template.
[0063] Specifically, the current task template can be any template loaded in the scheduler, and the last execution time refers to the time when the task corresponding to the task template was executed. The task template contains a time expression, such as a cron expression or a custom time expression. The cron expression is used to manage the regular execution time of the parsed task. The current execution time is calculated by the time expression and the last execution time, and the time to execute the task corresponding to the task template again.
[0064] The above-mentioned scheduled task processing method loads and parses task templates with the same content through multiple different schedulers in the scheduling system, and sends the parsed parameters to the task generation node to generate multiple identical tasks to be executed. When executing tasks, when one of the schedulers fails, the task templates loaded on other schedulers can be used to solve the problems of unsustainable output and master-slave mechanism caused by single point failure, and the problems caused by host failure, thereby ensuring the operating stability of the scheduling system.
[0065] In one embodiment, the scheduling system is deployed as a stateless service, that is, the scheduler, the task generation node, and the task consumption node are all deployed in a stateless manner. The stateless deployment can horizontally expand the scheduling system.
[0066] When the task generation node receives the current task identifier and corresponding task parameters sent by the scheduler, it generates an executable task according to the task parameters and the task identifier.
[0067] Before caching the pending tasks, save the pending tasks first, that is, write the generated pending tasks into the database. Since the same task template is parsed by multiple schedulers, the same pending tasks will be generated when the pending tasks are generated. Therefore, the pending tasks are deduplicated before writing the tasks into the database. That is, the current task ID of the pending task is used as the primary key of the database. When writing each pending task, it is determined whether the same task exists in the database. If the same task exists, the task is not written. If the same task does not exist, the task is written.
[0068] In one embodiment, when saving the task to be executed, the execution status of the task to be executed is written, and the execution status is to be cached; a message queue is used to cache the first task to be executed, and the execution status of the first task to be executed is to be cached; the tasks to be executed in the message queue are monitored through the task consumption node; when the task consumption node receives the task to be executed, the task to be executed is sent through the task consumption node.
[0069] Specifically, the execution status is one of the attribute information of the task to be executed, and the attribute information is used to describe the execution status of the task to be executed. The execution status can be customized according to the needs, such as the execution status includes cached and completed, etc., and can also include at least failure. The cached tasks are cached through the message queue, and the completed tasks refer to the tasks that have been executed. The completed tasks include the execution results of the tasks, and the execution results are the results returned after the task is executed. Since the task generated by the task generation node cannot be consumed in time by the task consumption node, the generated task to be executed is cached through the message queue, that is, the first task to be executed is cached, and the execution status of the first task to be executed is to be cached. The task consumption node listens to the tasks in the message queue, and when the task consumption node receives the task to be executed, it sends the task.
[0070] In one embodiment, after a task consumption node receives a task to be executed, it also includes: requesting splicing of task parameters of the task to be executed to obtain an execution request, wherein the execution request includes a device identifier; the task consumption node sends the task to be executed according to the device identifier; and executing the task to be executed through the device corresponding to the device identifier.
[0071] Specifically, after receiving the task to be executed, the task consumption node generates a corresponding execution request according to the parameters in the task to be executed. The execution request is defined according to business requirements, such as an http request and a shell request. The execution request carries the identifier of the device that executes the request (device identifier). The request is sent according to the device identifier and executed by the execution device. After executing the request, the execution result of the request is returned.
[0072] In one embodiment, the task consumption node receives the execution result of the task to be executed, and when the execution result is failure or success; when the execution result is failure, the task to be executed is sent again; when the execution result is success, the execution result is written to the database, and the execution status of the task to be executed is updated from the cache to completed.
[0073] Specifically, the execution result refers to the execution status of the task to be executed, including success and failure. When the execution is successful, the execution success is written to the database, and the execution status of the task to be executed is changed, that is, from cache to completed. If the execution fails, the task is executed again, and the reason for the execution failure may be network reasons, or it may be a failure of the execution device, etc. The task to be executed can be sent again immediately or after a preset time period. The specific time can be defined according to the needs, such as setting it to be sent after 30 seconds.
[0074] In one embodiment, referring to Figure 3 , Figure 3 The architecture deployment diagram of the scheduled task processing system includes multiple scheduling groups 410 (n), multiple task generation nodes 420 (m), a message queue 430, multiple task consumption nodes 440 (k), a target host 450, a database 460 and a management console 470.
[0075] Among them, the task scheduling group 410 is responsible for loading and parsing task templates. The scheduler in the scheduling group 410 loads all task templates into memory and generates specific tasks to be executed based on the cron expressions on the task templates. As can be seen from the architecture diagram, schedulers can be deployed in groups. The task scheduler services in the same group parse the same task template list. The schedulers in each group are stateless. Each scheduler can generate a unique task identifier based on the task id (task identifier) and the next task execution time, and ensure that the task is not executed repeatedly based on the database unique key.
[0076] The task generation node 420 is used to generate specific executable tasks and provide an interface for the task scheduler to call. After one call, the task generation node first stores the data in the database 460, and then sends the task to the message queue (cmq) 430 for consumption by downstream nodes. The task generation node is a stateless service that can be deployed on multiple machines, and is very convenient for horizontal expansion.
[0077] The consumption task node 440 is used to consume the tasks generated by the generation task node 420, that is, it is responsible for the specific execution of the tasks. The consumption task node 440 is also a stateless service, and horizontal expansion can be easily achieved through multiple deployments.
[0078] The management console 470 implements the interaction between the user and the scheduling system. The user can configure the cron expression for task execution and the parameters required for task execution through the management console.
[0079] The design of the scheduled task processing system is based on the principle that each service performs its own duties. The scheduler is only responsible for scheduling task templates; the generating task node is only responsible for generating specific tasks; and the consuming task node is only responsible for consuming specific tasks. The system structure is clean, and the services of the producing task node can be extracted separately to provide services for other applications.
[0080] In one embodiment, referring to Figure 4 , Figure 4 This is a timing flow chart of the scheduled task processing method, which includes a scheduler, a task generation node, cmq, a task consumption node, a target host, and a database.
[0081] A1, the scheduler scans the task templates regularly. Scan the task templates to determine the task templates that need to be loaded, load and parse the task templates, and obtain the task parameters and current task identifiers corresponding to the task templates. The current task includes the task identifier and execution time. The execution time is the specific time when the task is executed. The corresponding task in the task template can be executed once or multiple times. The scheduler loads all executable task modules in real time, and calculates whether there are tasks to be run at this moment every second. If a task is found to be run, the task scheduler will calculate the next task execution time based on the cron expression of the task module and the last execution time of the template. Then, the task parameters and the unique identification ID of the task are generated based on the task template ID and the execution time.
[0082] In this specific embodiment, refer to Figure 5 , Figure 5This is a diagram of the configuration interface of the task template. The parameters of the task template include task name (task ID), product name, task description, service name, enable / disable, asynchronous synchronization, task type, cron expression, task failure retry, http access, http header, assistant and other configuration items. The configuration page of cron expression refers to Figure 6 , cron expressions are used to configure time information, such as seconds, minutes, hours, days, weeks, months, and years. The configuration page provides a cron expression control. Users can directly configure through the control. Even if they are not familiar with the syntax of cron expressions, they can still configure the correct time information and meet the expected configuration.
[0083] A2, the scheduler sends the task parameters and the current task. Finally, the task production node grpc interface is called. After sending, it monitors whether the sending is successful. When the task generation node returns a message of successful sending, the sending is successful. If the sending fails, it will be sent again.
[0084] A3, the task generation node sends the task parameters and the current task according to the task template and generates the corresponding task to be executed.
[0085] A4, write the task to be executed into the database. After the task is written into the database, a successful writing message is returned to the task generation node. Check whether the task to be executed already exists according to the task ID. If not, the task is successfully entered into the database. The task to be executed includes the execution status, which includes to be cached and completed, etc.
[0086] A5, send the pending tasks to the cmq queue. The pending tasks in the cmq queue are waiting to be executed by the task consuming node.
[0087] A6, the task consumption node actively pulls tasks from the cmq queue. After receiving the task message, it assembles the request according to the specific execution parameters of the task to obtain the request to be consumed. The task type can be either an http type task or a shell type task.
[0088] A7, sends the consumption request to the target host.
[0089] A8, the target host executes the consumption request. If there is a timeout during the execution, it can be executed multiple times.
[0090] A9 returns the execution result to the task consumption node.
[0091] A10, the task consumption node writes the execution result to the database. The database modifies the corresponding execution status according to the task execution result.
[0092] Design of task ID: Task production depends on the effective time of the task template and the cron expression parsing rules. By using these two factors, the execution sequence of tasks is fixed in the future regardless of the task situation, and the task ID is generated by module ID + task execution time, thereby ensuring that the next task ID calculated by multiple service processes at the same time point is consistent, thereby improving the stability and reliability of the system.
[0093] Deployment of stateless services: The three main roles of the scheduling system, the scheduler, the task generation node, and the task consumption node, are all deployed statelessly. This deployment method only requires adding machines to achieve horizontal expansion of services, which is simple and efficient.
[0094] Service function design with different responsibilities: the scheduling system scheduler is only responsible for scheduling tasks, the task generation node is only responsible for the generation of specific tasks, and the task consumption node is only responsible for the consumption of specific tasks. In this way, the services are divided into a more appropriate granularity according to the system functions, making the system architecture design clearer and simpler. In addition, system components can be extracted separately to provide services for other applications. For example, the task node generation service has been used in other systems within the company, greatly reducing application development costs and improving work efficiency.
[0095] Figure 2 FIG. 1 is a flow chart of a method for processing a scheduled task in an embodiment. It should be understood that although Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0096] In one embodiment, Figure 7 As shown, a timed task processing device 200 is provided, comprising:
[0097] The template loading module 201 is used to load the task template using each scheduler in the scheduling system. The task template with the same content is loaded in at least two schedulers in the scheduling system. The task template includes execution time, task identifier and task parameters. The execution time is the time for executing the task in the task template on a scheduled basis.
[0098] The parsing module 202 is used for each scheduler to parse each task template and generate a current task identifier and corresponding task parameters of each task template. The current task identifier includes an execution time and a task identifier.
[0099] The data sending module 203 is used for each scheduler to send the current task identifier and the corresponding task parameters to the task generation node in the scheduling system.
[0100] The task generation module 204 is used for the task generation node to generate a task to be executed according to the current task identifier and the corresponding task parameters.
[0101] The task storage module 205 is used to save the task to be executed when there is no current task identifier identical to the task to be executed in the database.
[0102] In one embodiment, the template loading module 201 is specifically configured to load all task templates using each scheduler, wherein the scheduling system includes at least two schedulers.
[0103] In one embodiment, the template loading module 201 is specifically used to use each scheduler to load some task templates among all task templates, and some task templates of all task templates in each scheduler are the same as some task templates in at least two of the other schedulers, and the scheduling system includes at least three schedulers.
[0104] In one embodiment, the above-mentioned scheduled task processing device 200 further includes:
[0105] The task template acquisition module is used to acquire all task templates, wherein the scheduling system includes multiple scheduling groups, and each scheduling group includes at least two schedulers.
[0106] The grouping module is used to divide all task templates into groups to obtain multiple task template sets, and each scheduling group corresponds to a task template set.
[0107] The template loading module 201 is further specifically configured to use each scheduler in each scheduling group to load a task template set corresponding to the scheduling group.
[0108] In one embodiment, the above-mentioned scheduled task processing device 200 further includes:
[0109] The status writing module is used to write the execution status of the task to be executed when saving the task to be executed, and the execution status is to be cached.
[0110] The task cache module is used to cache the first task to be executed by using a message queue, and the execution status of the first task to be executed is to be cached.
[0111] The monitoring module is used to monitor the tasks to be executed in the message queue through the task consumption node.
[0112] The task sending module is used to send the task to be executed through the task consuming node after the task consuming node receives the task to be executed.
[0113] In one embodiment, the above-mentioned scheduled task processing device 200 further includes:
[0114] A request splicing module, used for request splicing of task parameters of the task to be executed to obtain an execution request, wherein the execution request includes a device identifier;
[0115] The task sending module is specifically used for the task consumption node to send the task to be executed according to the device identification.
[0116] The task execution module is used to execute the task to be executed by the device corresponding to the device identifier.
[0117] In one embodiment, the above-mentioned scheduled task processing device 200 further includes:
[0118] The execution result receiving module is used for the task consumption node to receive the execution result of the task to be executed, and the execution result is failure or success.
[0119] The task sending module is also specifically used to send the task to be executed again when the execution result is failure.
[0120] The status writing module is also specifically used to write the execution result into the database when the execution result is successful, and update the execution status of the task to be executed from the cache to completed.
[0121] In one embodiment, the above-mentioned scheduled task processing device 200 further includes:
[0122] The execution count acquisition module is used to obtain the number of times the task to be executed is executed.
[0123] The execution stop module is used to stop executing the task to be executed when the execution result is failure and the number of times the task to be executed is equal to the preset number of times.
[0124] The task sending module is also specifically used to send the task to be executed again when the execution result is failure and the number of times the task to be executed is less than a preset number of times.
[0125] In one embodiment, the task template includes a time expression, and the scheduled task processing device 200 further includes:
[0126] The execution time acquisition module is used to obtain the last execution time of the current task template.
[0127] The execution time calculation module is used to calculate the current execution time of the current task template according to the time expression of the current task template and the last execution time of the current task template, and use the current execution time of the current task template as the execution time of the current task template.
[0128] Figure 8 The internal structure diagram of a computer device in one embodiment is shown. The computer device may specifically be Figure 1 The terminal 110 (or server 120) in FIG. Figure 8 As shown, the computer device includes a processor, a memory, a network interface, an input device and a display screen connected via a system bus. Among them, the memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program, which, when executed by the processor, enables the processor to implement a timed task processing method. The internal memory may also store a computer program, which, when executed by the processor, enables the processor to execute a timed task processing method. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device may be a touch layer covering the display screen, or a button, trackball or touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse, etc.
[0129] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0130] In one embodiment, the timing task processing device provided by the present application can be implemented in the form of a computer program. Figure 8 The computer device shown in the figure is run. The memory of the computer device can store various program modules constituting the timing task processing device, for example, Figure 7 The template loading module 201, parsing module 202, data sending module 203, task generating module 204 and task storing module 205 are shown. The computer program composed of each program module enables the processor to execute the steps of the timed task processing method of each embodiment of the present application described in this specification.
[0131] For example, Figure 8 The computer device shown can be Figure 7The template loading module 201 in the timing task processing device shown in the figure uses each scheduler in the scheduling system to load the task template. The task template with the same content is loaded in at least two schedulers in the scheduling system. The task template includes the execution time, the task identifier and the task parameter. The execution time is the time for the task in the timing execution task template. The computer device can execute each scheduler through the parsing module 202, parse each task template, and generate the current task identifier and the corresponding task parameter of each task template. The current task identifier includes the execution time and the task identifier. The computer device can execute each scheduler through the data sending module 203, and send the current task identifier and the corresponding task parameter to the task generation node in the scheduling system. The computer device can generate the task to be executed according to the current task identifier and the corresponding task parameter through the task generation node through the task generation module 204. The computer device can save the task to be executed through the task storage module 205 when there is no current task identifier identical to the task to be executed in the database.
[0132] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the above-mentioned scheduled task scheduling method when executing the computer program.
[0133] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned scheduled task scheduling method is implemented.
[0134] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0135] It should be noted that, 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 such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0136] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A method for processing a scheduled task, characterized in that: The method comprises: Using each scheduler in the scheduling system to load the task template, the task template with the same content is loaded in at least two schedulers in the scheduling system, the task template includes an execution time, a task identifier and a task parameter, and the execution time is the time for regularly executing the task in the task template; Each of the schedulers parses each of the task templates to generate a current task identifier and corresponding task parameters of each of the task templates, wherein the current task identifier includes an execution time and a task identifier; Each of the schedulers sends the current task identifier and corresponding task parameters to a task generation node in the scheduling system; Generate a task to be executed according to the current task identifier and corresponding task parameters through the task generation node; When there is no current task identifier identical to the task to be executed in the database, the task to be executed is saved.
2. The method according to claim 1, characterized in that The scheduling system includes at least two schedulers, and the method of using each scheduler in the scheduling system to load the task template includes: Each of the schedulers is used to load all task templates.
3. The method according to claim 1, characterized in that: The scheduling system includes at least three schedulers, and the method of using each scheduler in the scheduling system to load the task template includes: Each of the schedulers is used to load part of the task templates among all the task templates, and the part of the task templates among all the task templates in each of the schedulers are the same as the part of the task templates in at least two schedulers among the other schedulers.
4. The method according to claim 1, characterized in that: The dispatching system includes a plurality of dispatching groups, each dispatching group includes at least two dispatchers, and the method further includes: Get all task templates; Dividing all the task templates into groups to obtain a plurality of task template sets, each scheduling group corresponding to a task template set; The method of using each scheduler in the scheduling system to load the task template includes: using each scheduler in each scheduling group to load the task template set corresponding to the scheduling group.
5. The method according to claim 1, characterized in that The scheduling system is deployed as a stateless service.
6. The method according to claim 1, characterized in that The method further comprises: When saving the task to be executed, the execution status of the task to be executed is written, and the execution status is to be cached; A message queue is used to cache a first task to be executed, wherein the execution status of the first task to be executed is to be cached; Monitoring the tasks to be executed in the message queue through the task consumption node; After the task consumption node receives the task to be executed, the task to be executed is sent through the task consumption node.
7. The method according to claim 6, characterized in that When the task consumption node receives the task to be executed, the method further includes: Request splicing of task parameters of the task to be executed to obtain an execution request, wherein the execution request includes a device identifier; The sending of the to-be-executed task by the task consumption node comprises: the task consumption node sending the to-be-executed task according to the device identifier; The task to be executed is executed by the device corresponding to the device identifier.
8. The method according to claim 7, characterized in that The execution status includes completed, and the method further includes: The task consumption node receives the execution result of the task to be executed, where the execution result is failure or success; When the execution result is the success, the execution result is written into the database, and the execution status of the task to be executed is updated from the cache to the completed state.
9. The method according to claim 8, characterized in that The method further comprises: Obtain the number of times the task to be executed is executed; When the execution result is the failure, and the number of times the task to be executed is equal to the preset number, stopping the execution of the task to be executed; When the execution result is the failure, and the number of times the task to be executed is executed is less than the preset number, the task to be executed is sent again.
10. The method according to claim 1, characterized in that The task template includes a time expression, and the method further includes: Get the last execution time of the current task template; The current execution time of the current task template is calculated according to the time expression of the current task template and the last execution time of the current task template, and the current execution time of the current task template is used as the execution time of the current task template.
11. A timed task processing device, characterized in that: The device comprises: A template loading module, used to load a task template using each scheduler in the scheduling system, wherein the task template having the same content is loaded in at least two schedulers in the scheduling system, wherein the task template includes an execution time, a task identifier and task parameters, and the execution time is the time for regularly executing the task in the task template; A parsing module, used for each of the schedulers, to parse each of the task templates, and to generate a current task identifier and corresponding task parameters for each of the task templates, wherein the current task identifier includes an execution time and a task identifier; A data sending module, used for each of the schedulers, to send the current task identifier and the corresponding task parameters to the task generation node in the scheduling system; A task generation module, used to generate a task to be executed according to the current task identifier and corresponding task parameters through the task generation node; The task storage module is used to save the task to be executed when there is no current task identifier identical to the task to be executed in the database.
12. A scheduled task processing system, characterized in that: For running the scheduled task processing method according to any one of claims 1 to 10, the system comprises a plurality of schedulers, a plurality of task generation nodes and a plurality of task consumption nodes, wherein: The scheduler is used to load and parse a task template, wherein the task template having the same content is loaded in at least two schedulers of the scheduling system; The task generation node is used to generate a task to be executed according to the parameters in the task template of the scheduler; The consumption node is used to consume the task to be executed.
13. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 10 are implemented.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.
Citation Information
Patent Citations
Just expandable network scheduling method
CN101222422A
Cluster computing resource scheduling method, device and equipment and medium
CN109992404A