Timed task scheduling method and system
By integrating executors and services between the timing task management platform and the executor, the problem of large task execution overhead in the existing distributed task scheduling scheme is solved, and an efficient and easy-to-use timing task scheduling system is realized, supporting task scheduling, Elastic scaling and distributed task execution.
Patent Information
- Application Number
- CN202410862467.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-12-03
AI Technical Summary
Existing distributed task scheduling schemes such as quartz and elastic-job have problems such as high overhead, complex configuration, poor performance and lack of a good management console during the execution of tasks.
By integrating executors and services between the timing task management platform and the executor, pre-starting the executor, and starting the corresponding executor when the target service is started, the need to start the executor separately is reduced, thereby reducing the overhead of task execution.
Simplifies the execution process of timed tasks, reduces overhead, improves execution efficiency, and provides an easy-to-use architecture and visual interface, supports task scheduling, elastic capacity expansion and distributed broadcast tasks, dynamic sharding, and improves system availability and stability.
Smart Images

Figure CN119065803A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a timed task scheduling method and system. Background Art
[0002] Distributed task scheduling is the management and execution of scheduled tasks in a distributed environment. Scheduled tasks refer to tasks that are executed at a certain time or at regular intervals. Task scheduling generally involves task status management, sending and receiving task scheduling requests, specific task allocation, and specific execution of tasks.
[0003] There are many open source projects and solutions in the related technologies of distributed task scheduling, such as the Quartz distributed scheduling solution, whose scheduling logic mainly involves task management, task scheduling and task execution. Quartz has three core components: Job: the specific business logic to be executed; Trigger: used to define the trigger conditions, trigger time, trigger interval, end time, etc. of the Job; Scheduler: starts the Trigger to execute the Job.
[0004] However, the above Quartz distributed task scheduling solution has a problem of high overhead in the process of executing tasks. Summary of the invention
[0005] The present invention provides a timed task scheduling method and system, which are used to solve the defect of large overhead in the process of executing tasks in the quartz distributed task scheduling scheme in the prior art, and achieve the technical effect of reducing the overhead in the process of executing timed tasks.
[0006] The present invention provides a timed task scheduling method, which is applied to a timed task scheduling system. The timed task scheduling system includes a timed task management platform and an executor. The method includes: Obtain the scheduling configuration input by the user through the scheduled task management platform; Determine the corresponding target service according to the scheduling configuration, and send a scheduling request to the executor corresponding to the target service; the above scheduling request includes the identifier of the target scheduled task, which is used to instruct the executor corresponding to the target service to execute the target scheduled task through the target service; The executor corresponding to the target service is pre-integrated into the target service, and the executor corresponding to the target service is started accordingly when the target service is started.
[0007] According to a timed task scheduling method provided by the present invention, the method further includes: The executor and the service managed by the executor are integrated to obtain an integrated service; the integrated service includes the sub-service corresponding to the executor.
[0008] According to a timed task scheduling method provided by the present invention, the executor and the service managed by the executor are integrated to obtain an integrated service, including: Get the core data package corresponding to the executor and the preset project public data package; Add the core data package to the project public data package to obtain the configured target public data package; Add the target public data package to the configuration file corresponding to the service to obtain the integrated service.
[0009] According to a timed task scheduling method provided by the present invention, the core data package is added to the project public data package to obtain the configured target public data package, including: Obtain relevant information of the scheduled task management platform; the relevant information includes at least one of the platform address of the scheduled task management platform, the log storage path, and the log retention time; Add the core data package to the project public data package, and configure the relevant information in the project public data package to obtain the target public data package.
[0010] According to a scheduled task scheduling method provided by the present invention, the above scheduling configuration includes the name and port information of the service, and the identifier of the target scheduled task; The above determines the corresponding target service according to the scheduling configuration, including: Determine the target IP address corresponding to the identifier in the database according to the identifier of the target scheduled task; the above database stores the correspondence between the identifier of the scheduled task and the IP address of the executor; Determine the target service based on the target IP address, service name, and port information.
[0011] According to a timed task scheduling method provided by the present invention, the target service is determined according to the target IP address, the name of the service and the port information, including: According to the identifier of the target timed task, determine the target annotation content corresponding to the identifier in the database; Determine the target service based on the target annotation content, target IP address, service name and port information.
[0012] According to a timed task scheduling method provided by the present invention, the method further includes: Get the heartbeat information between the executor corresponding to the target service and the scheduled task management platform; The status of the executor corresponding to the target service is determined based on the heartbeat information, and the status is displayed in the scheduled task management platform; the above status includes the executor being online or the executor being offline.
[0013] The present invention also provides a timed task scheduling system, including a timed task management platform and an executor; The scheduled task management platform is used to obtain the scheduling configuration input by the user, determine the corresponding target service according to the scheduling configuration, and send a scheduling request to the executor corresponding to the target service; the above scheduling request includes the identifier of the target scheduled task; The executor is used to execute the target scheduled task through the target service; wherein the executor corresponding to the above target service is pre-integrated into the target service, and the executor corresponding to the target service is started accordingly when the target service is started.
[0014] According to a scheduled task scheduling system provided by the present invention, the scheduled task management platform includes controls for operating scheduled tasks, and the operations include at least one of adding, deleting, modifying and searching.
[0015] According to a scheduled task scheduling system provided by the present invention, the scheduled task management platform is connected to a database, and the database is used to store data generated in the scheduled task management platform.
[0016] The timed task scheduling method and system provided by the present invention include a timed task scheduling system including a timed task management platform and an executor, wherein the scheduling configuration input by the user is obtained through the timed task management platform, and after the corresponding target service is determined according to the scheduling configuration, a scheduling request is sent to the executor corresponding to the target service, and the scheduling request includes the identifier of the target timed task and is used to instruct the executor corresponding to the target service to execute the target timed task through the target service, and the executor corresponding to the target service is pre-integrated into the target service and starts the executor corresponding to the target service accordingly when the target service is started. In this method, since the executor and the service can be integrated, it is not necessary to start the executor service separately when the executor executes the timed task, thereby reducing the overhead when executing the timed task. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 It is a system block diagram of the quartz task scheduling solution in the prior art; Figure 2 This is one of the flow charts of the timed task scheduling method provided by the present invention; Figure 3This is the second flow chart of the timed task scheduling method provided by the present invention; Figure 4 This is the third flow chart of the timed task scheduling method provided by the present invention; Figure 5 It is a structural diagram of the timed task scheduling system provided by the present invention; Figure 6 It is a detailed structural diagram of the timed task scheduling system provided by the present invention. DETAILED DESCRIPTION
[0019] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0020] In the field of distributed task scheduling, there are many open source projects and solutions, such as quartz, saturn, elastic-job, etc. The concepts of task scheduling business are flying and the business is complex. Among them, the quartz solution supports clustering and distribution, but there is no good management console, and the functions are relatively simple, which makes it difficult to manage and schedule tasks. This solution uses database locks and pessimistic locks to lock triggers to ensure the accuracy of task synchronization. Once a node obtains the lock, the task runs here, and the other machine that wants to use the triggered task can only wait. Without distribution, high availability cannot be achieved, and the problem of task sharding has not been solved, there will be a limit to single-machine processing. Elastic-job is also a distributed scheduling solution. The core includes 2 sub-projects, positioned as a centerless solution, and provides distributed coordination services in the form of packages, which can meet the business needs of most enterprises. However, the deployment of this solution is cumbersome.
[0021] The following describes the quartz scheduling scheme and the elastic-job scheduling scheme in detail.
[0022] 1. The distributed scheduling logic of Quartz mainly involves task management, task scheduling and task execution.
[0023] 1. Task Management
[0024] See also Figure 1As shown in the system box, Quartz uses Job (job item) and Trigger (trigger) to manage tasks. Job defines the specific task logic to be executed, while Trigger is used to define the triggering conditions and execution frequency of the task. In a distributed environment, task management is usually concentrated on a scheduler master node (i.e. Scheduler in the figure, obtained from Scheduler Factory), which is responsible for managing all tasks. Other scheduler nodes can synchronize task information with this master node through cluster communication to achieve unified scheduling of tasks.
[0025] 2. Task Scheduling
[0026] Quartz provides a variety of flexible scheduling strategies that can be configured according to specific needs. These include simple scheduling, Cron scheduling, calendar scheduling, and loop scheduling. These scheduling strategies can be configured according to the triggering conditions, execution frequency, priority, etc. of the task. In a distributed environment, Quartz can use various cluster communication technologies to implement task scheduling. For example, JDBCStore is used to store task information, and tasks are synchronized and scheduled through the database; Terracotta is used for memory sharing to implement distributed scheduling of tasks.
[0027] 3. Task Execution
[0028] Quartz uses JobDetail and JobExecutionContext to execute tasks. JobDetail defines the specific task logic to be executed, while JobExecutionContext provides the context information required to execute the task. In a distributed environment, tasks can be executed on different nodes. Quartz provides load balancing and fault recovery mechanisms for tasks to ensure that tasks can be accurately assigned to available nodes for execution, and can automatically switch to other available nodes for execution when a node fails.
[0029] However, the above-mentioned quartz task scheduling solution has the following problems: 1. The configuration is relatively complex and requires a certain learning cost; 2. Since its implementation technology core library relies on jdbc (Java DataBase Connectivity), it will generate additional overhead; 3. This distributed technology only solves the high availability problem, but does not solve the task sharding problem; 4. The distributed scheduling performance of this technology is poor, especially when the task volume increases and there are second-level tasks; 5. There is no built-in management interface, the scheduling logic and execution tasks are coupled together, and maintenance requires restarting the service.
[0030] 2. Elastic-Job adopts a decentralized design, which is mainly divided into modules such as registration center, data sharding, distributed coordination, scheduled task processing and customized process tasks.
[0031] Decentralization means that elastic-job does not have the concept of a scheduling center. Each job server running in the cluster is equal, and nodes are coordinated in a distributed manner through the registration center. However, elastic-job has the concept of a master node, which is used to handle some centralized tasks, such as sharding, cleaning runtime information, etc. It has no scheduling function, and scheduled scheduling is triggered by the job server itself.
[0032] Registration Center: The registration center module currently uses Zookeeper (distributed application coordination service) to record job configuration, server information, and job running status. Although Zookeeper is very mature, its principles are complex and difficult to use. It also has performance and network issues when supporting massive data.
[0033] Data sharding: Data sharding is an important concept for implementing distribution in elastic-job. It matches real data with logical shards and is used to decouple the relationship between the job framework and data. The job framework is only responsible for reasonably allocating shards to relevant job servers, and the job servers need to match data according to the allocated shards for processing. Server shards are currently stored in the registration center, and each server pulls shards according to its own IP (Internet Protocol) address.
[0034] Distributed coordination: The distributed coordination module is used to handle the dynamic expansion and contraction of job servers. Once a server in the cluster changes, the distributed coordination will automatically monitor and notify the surviving job servers of the change results. Coordination will involve operations such as master node election and resharding. Currently, the temporary nodes and listeners of Zookeeper are used to implement active inspection and notification functions.
[0035] Scheduled task processing: Scheduled task processing triggers tasks according to cron expressions. Currently, it has functions such as preventing tasks from being triggered at the same time and re-triggering missed tasks. It mainly uses the scheduled scheduling function of Quartz itself. For easy control, each task uses an independent thread pool.
[0036] Customized process tasks: Customized process tasks divide scheduled tasks into multiple processes, including simple tasks without any modification; data flow tasks such as fetchData / processData for processing data; and message flow tasks, file tasks, workflow tasks, etc. will be added in the future. Users can extend and contribute code in the form of plug-ins.
[0037] However, the above elastic-job task scheduling solution has the following problems: 1. elastic-job provides fewer functions and does not support persistence mechanism and cluster (if the corresponding functions are to be implemented, additional implementation is required); 2. Central scheduling requires the introduction of Zookeeper, which adds additional complexity and maintenance costs; 3. The use and configuration are complex, and the task control is not flexible.
[0038] Based on the above problems, an embodiment of the present invention provides a scheduled task scheduling method and system. The scheduled task scheduling system has simple logic, easy-to-use architecture, and can be written by everyone. It can fully support task scheduling, and can elastically expand capacity and distributed broadcast tasks, dynamically partition, and has good consistency, which can solve the above problems.
[0039] Combine the following Figure 2-Figure 4 The timed task scheduling method of the present invention is described.
[0040] First of all, it should be explained that the scheduled task scheduling method of this embodiment can be applied to a scheduled task scheduling system. The above-mentioned scheduled task scheduling system includes a scheduled task management platform and an executor. The scheduled task management platform can provide users with a visual interface for users to operate on the visual interface, such as modifying scheduled tasks. At the same time, the scheduled task management platform can also display information related to scheduled tasks and executors for users to view and modify; of course, the scheduled task management platform can also provide more other functions, which can be further explained in subsequent embodiments. The above-mentioned executor is mainly used to execute scheduled tasks or services corresponding to scheduled tasks, etc., to achieve corresponding timing functions.
[0041] It should be noted that the execution subject of the following embodiments may be a scheduled task scheduling system or a scheduled task management platform. The following embodiments describe the scheduled task scheduling method by taking the scheduled task scheduling system as the execution subject.
[0042] The following is an explanation of the scheduled task scheduling method applied to the scheduled task scheduling system.
[0043] Figure 2 This is one of the flow charts of the timed task scheduling method provided by the present invention, see Figure 2 As shown, the method may include the following steps: S202, obtaining the scheduling configuration input by the user through the scheduled task management platform.
[0044] Among them, the scheduled task management platform can be a distributed scheduled task management platform or a distributed scheduled display platform based on xxl-job. The scheduled task management platform can provide a visual interface. In this step, the user can enter the scheduling configuration on the visual interface, so that the scheduled task management platform can obtain the scheduling configuration. The scheduling configuration may include the identification ID (Identity) and remarks of the target scheduled task, and the target scheduled task is the scheduled task that the user needs to execute. The ID is used to distinguish different scheduled tasks, and the remarks are a description of the scheduled task, mainly noting what timing function this scheduled task implements. The input method for the user to enter the scheduling configuration can be voice input, manual keyboard input, etc.
[0045] Generally, a scheduled task can be used to implement a certain positioning function in a service. In this embodiment, the service can be one or more services, and the scheduled task can also be one or more. In addition, the scheduled task in each service can also be one or more. The service here can be, for example, an alarm service, a service for obtaining data at a fixed time, a scheduled service, etc.
[0046] In this embodiment, a scheduled task management platform based on xxl-job is used, which has the following advantages: 1. Users can easily edit scheduled tasks on the scheduled task management platform, lowering the technical threshold; 2. The development process can be simplified, making scheduled execution and management simple; 3. The architecture is lightweight and provides good scalability, which can adapt to application scenarios of different scales; 4. It provides pages to manage and monitor tasks, supports container deployment, and provides cross-platform task scheduling services through HTTP (Hypertext Transfer Protocol).
[0047] S204, determine the corresponding target service according to the scheduling configuration, and send a scheduling request to the executor corresponding to the target service; the above scheduling request includes the identifier of the target scheduled task, which is used to instruct the executor corresponding to the target service to execute the target scheduled task through the target service.
[0048] Among them, the executor corresponding to the above-mentioned target service is pre-integrated into the target service, and the executor corresponding to the target service is started accordingly when the target service is started. Generally, an executor can also correspond to a service, that is, the executor itself can also be a service. Usually, when starting the service, it is necessary to start its corresponding executor separately, which is relatively costly. In this embodiment, the service corresponding to the executor can be pre-integrated into its corresponding service, that is, the service includes the executor, so that when the service is started, its corresponding executor will also be started synchronously, so there is no need to start the executor separately, so the cost can be reduced or reduced, and the execution time of the scheduled task can also be saved, and the execution efficiency of the scheduled task can be improved.
[0049] In addition, for the above services and executors, general services and their corresponding executors can be pre-registered in the scheduled task management platform. Specifically, the address of the scheduled task management platform can be configured in the executor, and then the executor can access the scheduled task management platform through the address, and register the executor and its corresponding service to the scheduled task management platform, so that the scheduled task management platform can subsequently manage the executor and service. Specific management, for example, can be to display the status of each executor and service in detail, so that users can view the corresponding problems of services and executors in time, and display the execution results of each executor and service in detail, so that users can adjust the problems between the scheduled task management platform, executors and services in time.
[0050] Specifically, after obtaining the scheduling configuration, the scheduled task management platform can find the executor and service corresponding to the ID of the scheduled task in the database according to the ID of the target scheduled task in the scheduling configuration, and the corresponding service is recorded as the target service. Then, the scheduling request can be determined based on the information related to the target service and the executor, and the scheduling request can be sent to the executor corresponding to the target service. The executor can execute the corresponding target scheduled task through the target service and realize the corresponding timing function, such as obtaining alarm data regularly in the alarm service.
[0051] In addition, the database may pre-store the corresponding relationships between the identifiers of different scheduled tasks and the relevant information of the executors or services, and of course other corresponding relationships may also be stored.
[0052] The above-mentioned scheduled task scheduling method is applied to a scheduled task scheduling system, which includes a scheduled task management platform and an executor, wherein the scheduled task management platform obtains the scheduling configuration input by the user, and after determining the corresponding target service according to the scheduling configuration, sends a scheduling request to the executor corresponding to the target service, the scheduling request includes the identifier of the target scheduled task and is used to instruct the executor corresponding to the target service to execute the target scheduled task through the target service, and the executor corresponding to the target service is pre-integrated into the target service and starts the executor corresponding to the target service when the target service is started. In this method, since the executor and the service can be integrated, it is not necessary to start the executor service separately when the executor executes the scheduled task, thereby reducing the overhead when executing the scheduled task.
[0053] The following embodiments illustrate the process of integrating the above-mentioned services and executors.
[0054] In an exemplary embodiment, the method further comprises the following steps: Step A: Integrate the executor and the service managed by the executor to obtain an integrated service; the integrated service includes the sub-service corresponding to the executor.
[0055] In this step, each service may have a corresponding executor, or multiple services may correspond to one executor. The executor is usually also a service, recorded as a sub-service. Here, the sub-service corresponding to the executor may be integrated into the actual service to obtain an integrated service.
[0056] After the executor is integrated into the actual service, the executor becomes a part of the actual service. Then the integrated service has the functions of the executor, and the integrated service can directly execute the corresponding functions later.
[0057] In this embodiment, by integrating the sub-service corresponding to the executor into the actual service, the actual service itself has the function of the executor. This lightweight coupling method allows the service to directly execute the corresponding timing function without having to start the executor again to execute it. Therefore, the overhead of timing task execution can be greatly reduced and the efficiency of timing task execution can be improved.
[0058] The following example illustrates a possible implementation method for specifically integrating the actuator into an actual service.
[0059] Figure 3 This is the second flow chart of the timed task scheduling method provided by the present invention, see Figure 3 As shown, the above step A may include the following steps: S302, obtaining a core data package corresponding to the executor and a preset project common data package.
[0060] Among them, the project can be, for example, a cloud operation and maintenance project, and the specific project is not limited here. Generally, after building a project, you will get the data package corresponding to the project, which will include the public data package and private data package of the project. The public data package is a common data package, that is, a data package that can also be used by other projects, and can also be called a public parent package. The private data package is owned by the project alone and is generally not available to other projects.
[0061] In addition, the core data packet of the actuator refers to the data packet that realizes the core functions of the actuator, and its corresponding core data packet can be obtained when designing the actuator.
[0062] S304, adding the core data package to the project public data package to obtain the configured target public data package.
[0063] In this step, after obtaining the core data package of the executor and the public data package of the project, the core data package of the executor can be added to the public data package, specifically, it can be added to a specific position in the public data package to form a new data package with the public data package, which is recorded as the target public data package. The specific position here can be set according to actual conditions, such as the end position of the public data package.
[0064] In addition, in order to integrate the information of the scheduled task management platform in the project, when configuring the public data package of the project, the data of the scheduled task management platform can also be configured in the public data package of the project. The following is an explanation of the process. As an optional embodiment, it can be to obtain relevant information of the scheduled task management platform; the above relevant information includes at least one of the platform address, log storage path and log retention time of the scheduled task management platform; add the core data package to the project public data package, and configure the relevant information in the project public data package to obtain the target public data package.
[0065] The address of the scheduled task management platform can be an IP address, the log storage path can be the log path where the data generated in the scheduled management platform is stored in the database, and the log retention time can be the retention time when the data generated in the scheduled management platform is stored as logs in the database. After adding the core data package of the executor to the public data package of the project, the relevant information of the scheduled task management platform can be continued to be configured in the public data package. After the configuration is completed, the configured public data package can be obtained and recorded as the target public data package. In this way, the target public data package is configured with both the executor information and the scheduled task management platform information. When the entire project is running, the executor and the scheduled task management platform can be used for task scheduling.
[0066] In addition, the above configuration of the executor information and the information of the scheduled task management platform in the public data package of the project can facilitate other projects to reuse the configured public data package without repeated configuration, thereby improving the project operation efficiency.
[0067] S306, adding the target public data package to the configuration file corresponding to the service to obtain the integrated service.
[0068] In this step, a configuration file can generally be set for each service, which can include configuration information for the service settings. After obtaining the configured target public data package, the target public data package can be added to the service configuration file, so that the corresponding executor and the relevant information of the scheduled task management platform are integrated into the service. Subsequently, the scheduling request sent by the scheduled task management platform in the service execution project can be directly executed through the service.
[0069] It should be noted that after the executor is integrated into the service, the listening port information of the executor integrated with each service can be different, so that different services can be distinguished.
[0070] In this embodiment, the core data package of the executor is added to the public data package of the project and then the configured public data package is added to the configuration file of the service to realize the integration of the project, the executor and the service, so that other projects can reuse the data packages of the integrated executor and service without repeated configuration, thereby improving the efficiency of project operation. In addition, when configuring the public data package of the project, the relevant information of the scheduled task management platform can also be configured, so that the scheduling request sent by the scheduled task management platform in the project can be directly executed through the service in the future, simplifying the complexity of project operation and further improving the efficiency of project operation.
[0071] The above embodiment mentioned that the scheduled task scheduling system can determine the corresponding target service based on the scheduling configuration input by the user. When the scheduling configuration input by the user includes information such as the name and port information of the service and the identifier of the target scheduled task, how to determine the target service specifically is described in the following embodiment.
[0072] Figure 4 This is the third flow chart of the timed task scheduling method provided by the present invention, see Figure 4 As shown, the above scheduling configuration includes the above S204 and may include the following steps: S402, determining a target IP address corresponding to the identifier in a database according to the identifier of the target scheduled task; the database stores a correspondence between the identifier of the scheduled task and the IP address of the executor.
[0073] In this step, the database may pre-store the correspondence between the identifier of the scheduled task and the IP address of the executor, wherein the IP address of the executor refers to the IP address for accessing the executor. Since the executor is integrated with the service, the corresponding service can also be obtained through the IP address of the executor.
[0074] After obtaining the identifier of the target scheduled task through the scheduling configuration, the IP address of the corresponding executor can be found in the database through the corresponding relationship and recorded as the target IP address.
[0075] Of course, other information can also be stored in the above database, such as the annotation content corresponding to the scheduled task. The annotation content of the scheduled task is mainly to distinguish different scheduled tasks or services. The annotation content can be different suffixes, such as .1, .2, etc., or suffixes such as .com, .cn, etc.
[0076] S404, determining the target service according to the target IP address, the name of the service and the port information.
[0077] In this step, after obtaining the access IP address of the executor corresponding to the target scheduled task, as an optional embodiment, the target annotation content corresponding to the identifier can also be determined in the database according to the identifier of the target scheduled task, that is, the annotation content corresponding to the target scheduled task can also be found in the database and recorded as the target annotation content, and then the target service can be determined according to the target annotation content, target IP address, service name and port information in combination with the name and port information of the service configured by the above user. Here, for example, the target IP address, target annotation content, service name and port information can be spliced in a certain order to obtain a unique splicing address, through which the corresponding service or executor can be accessed, that is, the target service can be determined.
[0078] In addition, the above port information may be information such as the port number and port name of the service.
[0079] When you need to use the timing function of a service in the future, you can configure the service name and port in the introduced service. The usage process is: when a function needs to be executed on a scheduled basis, add a timing annotation, add a timing method, and put the function that needs to be executed on a scheduled basis into the method.
[0080] In this embodiment, the target IP address of the executor is determined in the database through the identification of the target scheduled task, and the target service is determined in combination with the port information and name of the service, so that the target service can be found and executed accurately and quickly, improving the execution efficiency of the scheduled task. Furthermore, when determining the target service, the annotation content corresponding to the target scheduled task can be combined, so that different services can be better distinguished, thereby improving the accuracy of the target service found.
[0081] As mentioned above, the scheduled task management platform may also display relevant information of the executor. The following embodiment will illustrate the process of displaying the information of the status of the executor in the scheduled task management platform.
[0082] In an exemplary embodiment, the method further comprises the following steps: Obtain heartbeat information between the executor corresponding to the target service and the scheduled task management platform; determine the status of the executor corresponding to the target service according to the heartbeat information, and display the status in the scheduled task management platform; the above status includes the executor being online or the executor being offline.
[0083] In this step, the scheduled task scheduling system can monitor the heartbeat information between the executor corresponding to the target service and the scheduled task management platform regularly or periodically, and determine the current state of the executor based on the monitored heartbeat information. If the monitored heartbeat information is abnormal, it is determined that there may be a disconnection problem between the executor corresponding to the target service and the scheduled task management platform, and the state of the executor can be determined to be offline / offline; if the monitored heartbeat information is normal, it is determined that the executor corresponding to the target service and the scheduled task management platform are communicating normally, and the state of the executor can be determined to be online.
[0084] The status of the executor can then be displayed in real time on the scheduled task management platform so that the user can view it in time and take corresponding actions. For example, when the executor is offline, the user can check whether the communication link between the two is faulty and repair it.
[0085] In this embodiment, the heartbeat information between the executor corresponding to the target service and the scheduled task management platform is monitored to obtain the status of the executor, so that the user can adjust the problems between the executor and the scheduled task management platform in a timely manner.
[0086] Next, the timing task scheduling system of the present invention is introduced. Figure 5 The system structure block diagram shown and Figure 6 As shown in the figure, a detailed structural diagram is obtained, wherein the scheduled task scheduling system includes a scheduled task management platform and an executor; The scheduled task management platform is used to obtain the scheduling configuration input by the user, determine the corresponding target service according to the scheduling configuration, and send a scheduling request to the executor corresponding to the target service; the above scheduling request includes the identifier of the target scheduled task; The executor is used to execute the target scheduled task through the target service; wherein the executor corresponding to the above target service is pre-integrated into the target service, and the executor corresponding to the target service is started accordingly when the target service is started.
[0087] In this embodiment, the scheduled task management platform is a scheduled task management platform based on xxl-job, which is responsible for managing scheduling information and issuing scheduling requests according to scheduling configuration (specifically, it can be a scheduled task sent to the executor for service execution), and does not bear business code itself. In this way, the scheduling system can be decoupled from the scheduled task, thereby improving the availability and stability of the scheduling system, and the scheduling system performance is no longer limited by the task module.
[0088] In addition, the above-mentioned scheduled task management platform supports visual, simple and dynamic management of scheduling information, including task creation, update, deletion, GLUE development (i.e., Java extension package) and task alarm, etc. All the above operations will take effect in real time. It also supports monitoring scheduling results and execution logs, and supports executor failover.
[0089] The above executor can automatically register the listening ports of multiple services it manages (such as service 1-service n, where n is an integer greater than or equal to 1) to the scheduled task management platform, and is responsible for receiving scheduling requests from the scheduled task management platform and executing task logic, specifically by listening to ports in the service. The task module focuses on operations such as task execution, making development and maintenance simpler and more efficient. In addition, the executor can also receive execution requests, termination requests, and log requests from the "scheduling center".
[0090] For other related explanations of the scheduled task management platform and the executor, please refer to the related explanations in the above-mentioned scheduled task scheduling method embodiment, which will not be repeated here.
[0091] In this embodiment, the scheduled task scheduling system includes a scheduled task management platform and an executor, wherein the scheduled task management platform obtains the scheduling configuration input by the user, and after determining the corresponding target service according to the scheduling configuration, sends a scheduling request to the executor corresponding to the target service, the scheduling request includes the identifier of the target scheduled task and is used to instruct the executor corresponding to the target service to execute the target scheduled task through the target service, and the executor corresponding to the target service is pre-integrated into the target service and starts the executor corresponding to the target service when the target service is started. In this method, since the executor and the service can be integrated, it is not necessary to start the executor service separately when the executor executes the scheduled task, thereby reducing the overhead when executing the scheduled task.
[0092] In an exemplary embodiment, the scheduled task management platform includes controls for operating scheduled tasks, and the operations include at least one of adding, deleting, modifying and searching.
[0093] In this embodiment, a control for operating the scheduled task may be provided on the visual interface (or user page) of the scheduled task management platform, and the control may be, for example, a button. The user may add, delete, modify, and search the scheduled task through different controls, and for example, the addition operation may be that the user writes a scheduled task on the visual interface.
[0094] In addition, the visual interface of the scheduled task management platform can also provide controls for batch operations on scheduled tasks, which can improve operational efficiency.
[0095] At the same time, the above-mentioned scheduled task management platform can display all the configuration information of the scheduled tasks, and users can modify and pause the configured scheduled tasks at any time.
[0096] In this embodiment, the scheduled task management platform includes controls for operating scheduled tasks, which makes it easier for users to operate scheduled tasks.
[0097] In an exemplary embodiment, the scheduled task management platform is connected to a database, and the database is used to store data generated in the scheduled task management platform.
[0098] In this embodiment, the database can be pre-integrated or connected with the scheduled task management platform, and then when the user configures or operates the scheduled task on the scheduled task management platform, the generated configuration and data can be stored in the database (that is, the database can store the corresponding configuration and data of the scheduled task), which is convenient for subsequent search and use.
[0099] In an exemplary embodiment, the scheduled task management platform can display in detail the execution volume of scheduled tasks in each date time period, and can appropriately adjust the frequency of each scheduled task according to the execution volume, so as to avoid the problem of too dense scheduled tasks affecting the operating efficiency of the device.
[0100] In an exemplary embodiment, the scheduled task management platform supports viewing the executor status and monitoring the execution of tasks, that is, provides real-time monitoring and analysis of task execution data, which can facilitate monitoring and management of scheduled tasks and executors.
[0101] In an exemplary embodiment, the multiple scheduled tasks in the above-mentioned scheduled task management platform can use multi-threaded thread pool technology to realize the isolated scheduling of fast tasks and slow tasks, thereby improving the performance and stability of the system. At the same time, the task scheduling process can be completely asynchronous, which helps to cope with dense traffic.
[0102] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A timed task scheduling method, It is characterized in that Applied to a scheduled task scheduling system, the scheduled task scheduling system includes a scheduled task management platform and an executor, and the method includes: Obtain the scheduling configuration input by the user through the scheduled task management platform; Determine the corresponding target service according to the scheduling configuration, and send a scheduling request to the executor corresponding to the target service; the scheduling request includes an identifier of the target scheduled task, which is used to instruct the executor corresponding to the target service to execute the target scheduled task through the target service; The executor corresponding to the target service is pre-integrated into the target service, and the executor corresponding to the target service is started accordingly when the target service is started.
2. The timed task scheduling method according to claim 1, It is characterized in that The method further comprises: The executor and the service managed by the executor are integrated to obtain an integrated service; the integrated service includes the sub-service corresponding to the executor.
3. The timed task scheduling method according to claim 2, It is characterized in that The step of integrating the actuator and the service managed by the actuator to obtain the integrated service includes: Obtain the core data package corresponding to the executor and the preset project public data package; Adding the core data package to the project public data package to obtain a configured target public data package; The target public data package is added to the configuration file corresponding to the service to obtain an integrated service.
4. The timed task scheduling method according to claim 3, It is characterized in that The step of adding the core data package to the project public data package to obtain a configured target public data package includes: Obtaining relevant information of the scheduled task management platform; the relevant information includes at least one of the platform address, log storage path, and log retention time of the scheduled task management platform; The core data package is added to the project common data package, and the relevant information is configured in the project common data package to obtain the target common data package.
5. The timed task scheduling method according to any one of claims 1 to 4, It is characterized in that The scheduling configuration includes the name and port information of the service and the identifier of the target scheduled task; The determining the corresponding target service according to the scheduling configuration includes: Determining a target Internet Protocol IP address corresponding to the identifier of the target scheduled task in a database according to the identifier of the target scheduled task; the database stores a correspondence between the identifier of the scheduled task and the IP address of the executor; The target service is determined according to the target IP address, the name of the service and the port information.
6. The timed task scheduling method according to claim 5, It is characterized in that Determining the target service according to the target IP address, the name of the service and the port information includes: Determine, in the database, the target annotation content corresponding to the identifier according to the identifier of the target scheduled task; The target service is determined according to the target annotation content, the target IP address, the name of the service and the port information.
7. The timed task scheduling method according to any one of claims 1 to 4, It is characterized in that The method further comprises: Obtain heartbeat information between the executor corresponding to the target service and the scheduled task management platform; The state of the executor corresponding to the target service is determined according to the heartbeat information, and the state is displayed in the scheduled task management platform; the state includes the executor being online or the executor being offline.
8. A timed task scheduling system, It is characterized in that Including scheduled task management platform and executor; The scheduled task management platform is used to obtain the scheduling configuration input by the user, determine the corresponding target service according to the scheduling configuration, and send a scheduling request to the executor corresponding to the target service; the scheduling request includes the identifier of the target scheduled task; The executor is used to execute the target scheduled task through the target service; wherein the executor corresponding to the target service is pre-integrated into the target service, and the executor corresponding to the target service is started accordingly when the target service is started.
9. The timed task scheduling system according to claim 8, It is characterized in that The scheduled task management platform includes controls for operating scheduled tasks, and the operations include at least one of adding, deleting, modifying and searching.
10. The timed task scheduling system according to claim 8, It is characterized in that The scheduled task management platform is connected to a database, and the database is used to store data generated in the scheduled task management platform.
Citation Information
Cited By
Method and device for automatically configuring tasks based on task scheduling platform
CN119781872A
