技术领域technical field
本发明涉及计算机技术领域,尤其涉及一种定时任务调度的方法和装置。The invention relates to the technical field of computers, in particular to a method and device for scheduling scheduled tasks.
背景技术Background technique
当今社会各个领域的应用都会有定时任务调度的需求,比如,某博需要几分钟生成一次热搜排名榜、某贴吧需要隔半小时生成精华帖子、以及某购物网站需要凌晨上架产品等等。考虑到资源的有限性,任务调度系统不能只顾虑一部分用户,需要对资源进行合理的分配,以使系统中的用户能够正常使用应用。因此,如何对定时任务进行合理调度具有重要意义。Applications in various fields in today's society will have the need for scheduled task scheduling. For example, a blog needs to generate a hot search ranking every few minutes, a post bar needs to generate elite posts every half an hour, and a shopping website needs to put products on the shelves in the early morning, etc. Considering the limitation of resources, the task scheduling system should not only consider some users, but need to allocate resources reasonably so that users in the system can use applications normally. Therefore, how to reasonably schedule scheduled tasks is of great significance.
当前定时任务调度的方法有以下三种:一、使用Spring Quartz(Spring是一个开源框架,Quartz是一种开源定时任务工具)提供定时任务调度技术,通过配置文件配置定时任务或者直接使用Quartz提供的接口来创建定时任务;二、使用crontab命令(即,定时任务命令)配置要执行的定时任务,存放到操作系统Linux的crontab列表中,然后定时触发定时任务;三、根据生成的服务器列表为定时任务分配服务器,完成定时任务的调度。There are currently three ways to schedule scheduled tasks: 1. Use Spring Quartz (Spring is an open source framework, Quartz is an open source scheduled task tool) to provide scheduled task scheduling technology, configure scheduled tasks through configuration files or directly use the one provided by Quartz interface to create a timed task; 2. use the crontab command (that is, the timed task command) to configure the timed task to be executed, store it in the crontab list of the operating system Linux, and then trigger the timed task regularly; 3. set the timed task according to the generated server list The task allocation server completes the scheduling of timed tasks.
在实现本发明过程中,发明人发现现有技术中至少存在如下问题:现有技术定时任务调度的方法中,调用链路无法透明化,导致不能快速查询定时任务执行失败的原因,并且在任务执行失败时不能提供补偿定时任务机制。In the process of realizing the present invention, the inventors found that there are at least the following problems in the prior art: in the prior art timing task scheduling method, the call link cannot be transparent, resulting in the inability to quickly query the reason for the timing task execution failure, and in the task Compensation timing task mechanism cannot be provided when execution fails.
发明内容Contents of the invention
有鉴于此,本发明实施例提供一种定时任务调度的方法和装置,能够达到任务调度透明化的效果,提高定时任务的调度效率。In view of this, the embodiments of the present invention provide a method and device for scheduling scheduled tasks, which can achieve the effect of transparent task scheduling and improve scheduling efficiency of scheduled tasks.
为实现上述目的,根据本发明实施例的一个方面,提供了一种定时任务调度的方法。To achieve the above purpose, according to an aspect of the embodiments of the present invention, a method for scheduling scheduled tasks is provided.
本发明实施例的一种定时任务调度的方法包括:从任务列表中读取定时任务,并获取所述定时任务的参数信息;根据所述参数信息,将所述定时任务派送至应用服务器,并监控所述定时任务的状态信息;根据所述状态信息,判断所述定时任务是否调度成功,若否,则对所述定时任务进行补偿调度。A method for scheduling a scheduled task in an embodiment of the present invention includes: reading a scheduled task from a task list, and obtaining parameter information of the scheduled task; dispatching the scheduled task to an application server according to the parameter information, and Monitoring the status information of the timing task; judging whether the scheduling of the timing task is successful according to the status information, and if not, performing compensation scheduling on the timing task.
可选地,在从任务列表中读取定时任务并获取所述定时任务的参数信息之后,所述方法还包括:监控所述任务列表,并且根据所述任务列表变更所述定时任务的参数信息。Optionally, after reading the scheduled task from the task list and obtaining the parameter information of the scheduled task, the method further includes: monitoring the task list, and changing the parameter information of the scheduled task according to the task list .
可选地,在将所述定时任务派送至应用服务器之前,所述方法还包括:获取可用应用服务器列表,并从所述可用应用服务器列表中筛选可派送应用服务器;以及将所述定时任务派送至应用服务器包括:将所述定时任务派送至所述可派送应用服务器。Optionally, before dispatching the timed task to the application server, the method further includes: obtaining a list of available application servers, and screening dispatchable application servers from the list of available application servers; and dispatching the timed task To the application server includes: dispatching the timed task to the dispatchable application server.
可选地,所述状态信息包括:正在派送、派送成功或者派送失败,正在执行、执行成功、部分执行成功或者执行失败,正在取消、取消成功或者取消失败。Optionally, the status information includes: being dispatched, dispatched successfully or dispatched failed, being executed, executed successfully, partially executed successfully or executed failed, canceling, canceled successfully or canceled failed.
可选地,根据所述状态信息,判断所述定时任务是否调度成功,若否,则对所述定时任务进行补偿调度包括:当所述状态信息是执行成功时,确认所述定时任务调度成功,并发送将所述定时任务从所述任务列表中删除的指令;当所述状态信息是派送失败、部分执行成功或执行失败时,确认所述定时任务调度失败,并再次派送所述定时任务;当所述执行状态信息是取消成功时,确认所述定时任务调度失败,并发送将所述定时任务从所述任务列表中删除的指令;当所述执行状态信息是取消失败时,确认所述定时任务调度失败,并发送再次取消所述定时任务的指令。Optionally, judging whether the scheduled task is successfully scheduled according to the status information, if not, performing compensation scheduling on the scheduled task includes: confirming that the scheduled task is successfully scheduled when the status information indicates that the scheduled task is successfully scheduled , and send an instruction to delete the scheduled task from the task list; when the status information is dispatch failure, partial execution success, or execution failure, confirm that the scheduling of the scheduled task fails, and dispatch the scheduled task again ; When the execution status information is that the cancellation is successful, confirm that the scheduling of the scheduled task has failed, and send an instruction to delete the scheduled task from the task list; when the execution status information is that the cancellation failed, confirm that the scheduled task The scheduling of the scheduled task fails, and an instruction to cancel the scheduled task is sent again.
为实现上述目的,根据本发明实施例的另一方面,提供了一种定时任务调度的装置。To achieve the above purpose, according to another aspect of the embodiments of the present invention, an apparatus for scheduling scheduled tasks is provided.
本发明实施例的一种定时任务调度的装置,包括:获取模块,用于从任务列表中读取定时任务,并获取所述定时任务的参数信息;监控模块,用于根据所述参数信息,将所述定时任务派送至应用服务器,并监控所述定时任务的状态信息;判断模块,用于根据所述状态信息,判断所述定时任务是否调度成功,若否,则对所述定时任务进行补偿调度。A device for scheduling scheduled tasks according to an embodiment of the present invention includes: an acquisition module, configured to read a scheduled task from a task list, and acquire parameter information of the scheduled task; a monitoring module, configured to, according to the parameter information, Sending the timing task to the application server, and monitoring the status information of the timing task; a judging module, configured to judge whether the scheduling of the timing task is successful according to the status information, and if not, perform the scheduling of the timing task Compensation schedule.
可选地,所述获取模块还用于:监控所述任务列表,并且根据所述任务列表变更所述定时任务的参数信息。Optionally, the obtaining module is further configured to: monitor the task list, and change the parameter information of the scheduled task according to the task list.
可选地,所述监控模块还用于:获取可用应用服务器列表,并从所述可用应用服务器列表中筛选可派送应用服务器;将所述定时任务派送至所述可派送应用服务器。Optionally, the monitoring module is further configured to: obtain a list of available application servers, and filter dispatchable application servers from the list of available application servers; and dispatch the scheduled task to the dispatchable application servers.
可选地,所述状态信息包括:正在派送、派送成功或者派送失败,正在执行、执行成功、部分执行成功或者执行失败,正在取消、取消成功或者取消失败。Optionally, the status information includes: being dispatched, dispatched successfully or dispatched failed, being executed, executed successfully, partially executed successfully or executed failed, canceling, canceled successfully or canceled failed.
可选地,所述判断模块还用于:当所述状态信息是执行成功时,确认所述定时任务调度成功,并发送将所述定时任务从所述任务列表中删除的指令;当所述状态信息是派送失败、部分执行成功或执行失败时,确认所述定时任务调度失败,并再次派送所述定时任务;当所述执行状态信息是取消成功时,确认所述定时任务调度失败,并发送将所述定时任务从所述任务列表中删除的指令;当所述执行状态信息是取消失败时,确认所述定时任务调度失败,并发送再次取消所述定时任务的指令。Optionally, the judging module is further configured to: when the state information indicates that the execution is successful, confirm that the scheduling of the scheduled task is successful, and send an instruction to delete the scheduled task from the task list; when the When the status information is delivery failure, partial execution success or execution failure, confirm that the timing task scheduling has failed, and dispatch the timing task again; when the execution status information is cancellation success, confirm that the timing task scheduling has failed, and Sending an instruction to delete the scheduled task from the task list; when the execution status information indicates that the cancellation failed, confirm that the scheduling of the scheduled task failed, and send an instruction to cancel the scheduled task again.
为实现上述目的,根据本发明实施例的再一方面,提供了一种电子设备。To achieve the above purpose, according to still another aspect of the embodiments of the present invention, an electronic device is provided.
本发明实施例的一种电子设备包括:一个或多个处理器;存储装置,用于存储一个或多个程序,当一个或多个程序被一个或多个处理器执行,使得一个或多个处理器实现本发明实施例的定时任务调度的方法。An electronic device according to an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, and when one or more programs are executed by one or more processors, one or more The processor implements the method for scheduling scheduled tasks in the embodiment of the present invention.
为实现上述目的,根据本发明实施例的又一方面,提供了一种计算机可读介质。To achieve the above purpose, according to still another aspect of the embodiments of the present invention, a computer-readable medium is provided.
本发明实施例的一种计算机可读介质,其上存储有计算机程序,程序被处理器执行时实现本发明实施例的定时任务调度的方法。A computer-readable medium according to an embodiment of the present invention stores a computer program thereon, and when the program is executed by a processor, the method for scheduling a scheduled task according to the embodiment of the present invention is implemented.
上述发明中的一个实施例具有如下优点或有益效果:能够实时获取定时任务的状态信息,达到任务调度透明化的效果,并且本发明提供定时任务补偿机制,提高了定时任务的调度效率;本发明实施例中监控任务列表,从而在定时任务有变更时,可以将定时任务的参数信息及时更新,提高了定时任务调度的效率;本发明实施例中派送定时任务之前,从获取的可用应用服务器列表中筛选可派送应用服务器,从而可以提高定时任务派送的准确性;本发明实施例中状态信息可以包括:正在派送、派送成功或者派送失败,正在执行、执行成功、部分执行成功或者执行失败,正在取消、取消成功或者取消失败,能够实时获取定时任务的调度状态,实现调度链路的透明化;本发明实施例中根据状态信息,确认定时任务的调度进程,判断定时任务的调度结果,从而可以对定时任务进行相应处理。An embodiment of the above invention has the following advantages or beneficial effects: the status information of the timing task can be obtained in real time, achieving the effect of transparent task scheduling, and the invention provides a timing task compensation mechanism, which improves the scheduling efficiency of the timing task; In the embodiment, the task list is monitored, so that when the scheduled task changes, the parameter information of the scheduled task can be updated in time, which improves the scheduling efficiency of the scheduled task; In this way, the dispatchable application server can be screened in order to improve the accuracy of scheduled task dispatch; in the embodiment of the present invention, the status information can include: dispatching, successful dispatch or dispatch failure, executing, executing successfully, partially executing successfully or failing to execute, being executed Cancellation, cancellation success or cancellation failure, can obtain the scheduling status of the timing task in real time, and realize the transparency of the scheduling link; in the embodiment of the present invention, according to the state information, the scheduling process of the timing task is confirmed, and the scheduling result of the timing task is judged, so that Process the scheduled tasks accordingly.
上述的非惯用的可选方式所具有的进一步效果将在下文中结合具体实施方式加以说明。The further effects of the above-mentioned non-conventional alternatives will be described below in conjunction with specific embodiments.
附图说明Description of drawings
附图用于更好地理解本发明,不构成对本发明的不当限定。其中:The accompanying drawings are used to better understand the present invention, and do not constitute improper limitations to the present invention. in:
图1是根据本发明实施例的定时任务调度的方法的主要步骤的示意图;FIG. 1 is a schematic diagram of main steps of a method for scheduled task scheduling according to an embodiment of the present invention;
图2是根据本发明实施例的定时任务调度的多机房运行架构图;FIG. 2 is a multi-room operation architecture diagram of scheduled task scheduling according to an embodiment of the present invention;
图3是根据本发明实施例的定时任务调度的主备切换的架构图;FIG. 3 is an architecture diagram of active-standby switching of scheduled task scheduling according to an embodiment of the present invention;
图4是根据本发明实施例的定时任务的调度状态示意图;FIG. 4 is a schematic diagram of a scheduling state of a timing task according to an embodiment of the present invention;
图5是根据本发明的一个可参考实施例的定时任务调度的方法的主要流程的示意图;FIG. 5 is a schematic diagram of the main flow of a method for scheduling scheduled tasks according to a reference embodiment of the present invention;
图6是实现本发明定时任务调度方法的整体架构图;FIG. 6 is an overall architecture diagram for implementing the timing task scheduling method of the present invention;
图7是根据本发明实施例的定时任务调度的装置的主要模块的示意图;FIG. 7 is a schematic diagram of main modules of an apparatus for scheduling scheduled tasks according to an embodiment of the present invention;
图8是本发明实施例可以应用于其中的示例性系统架构图;Fig. 8 is an exemplary system architecture diagram to which the embodiment of the present invention can be applied;
图9是适于用来实现本发明实施例的终端设备或服务器的计算机系统的结构示意图。FIG. 9 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present invention.
具体实施方式Detailed ways
以下结合附图对本发明的示范性实施例做出说明,其中包括本发明实施例的各种细节以助于理解,应当将它们认为仅仅是示范性的。因此,本领域普通技术人员应当认识到,可以对这里描述的实施例做出各种改变和修改,而不会背离本发明的范围和精神。同样,为了清楚和简明,以下的描述中省略了对公知功能和结构的描述。Exemplary embodiments of the present invention are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present invention to facilitate understanding, and they should be regarded as exemplary only. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
图1是根据本发明实施例的定时任务调度的方法的主要步骤的示意图。本发明中的定时任务调度是指某个操作触发执行定时任务。作为本发明的一个实施例,如图1所示,本发明实施例的定时任务调度的方法主要包括以下步骤:Fig. 1 is a schematic diagram of main steps of a method for scheduling scheduled tasks according to an embodiment of the present invention. The scheduled task scheduling in the present invention refers to a certain operation triggering the execution of a scheduled task. As an embodiment of the present invention, as shown in FIG. 1, the method for scheduled task scheduling in the embodiment of the present invention mainly includes the following steps:
步骤S101:从任务列表中读取定时任务,并获取定时任务的参数信息。Step S101: Read the scheduled task from the task list, and obtain the parameter information of the scheduled task.
本发明中,定时任务服务器和应用服务器通过Zookeeper(即,一种分布式服务协调框架,本发明中可以但不限于是Zookeeper,也可以是其他服务框架,如Etcd或Consul)集群建立连接。应用服务器将需要调度的定时任务注册到Zookeeper集群上,生成任务列表,因此定时任务服务器对任务进行调度时,需要首先从任务列表中读取定时任务,同时获取定时任务的参数信息,例如,定时任务的触发操作、定时任务的触发时间、以及与定时任务相关的应用服务器(若定时任务A与应用服务器S相关,则应用服务器S可以执行定时任务A,此外,一个定时任务可以与多个应用服务器相关)等,然后将获取的参数信息写入数据库中(可以但不限于是数据库,本发明也可以采用其他存储设备)。本发明中,定时任务服务器可以通过哈希时间轮算法,对任务列表中的定时任务进行统一调度和分发。其中,哈希时间轮算法是哈希算法的延伸算法,具体可以理解为有一条时间闭环履带,每一节代表等长时间,假想有一个指针在这条履带圆心转动,转动速度恒定。当转到某一节时,可以从这节(假想每一节都是一个容器)取出要执行的任务,或者删除掉这节中的特定任务,或者是往该节添加新的任务。如果这个指针一直转动,那么每节中的每个任务就可以按照恒定的时间周期执行。针对本发明可以理解为任务列表是一个时间闭环履带,而定时任务注册在时间闭环履带的每一节中。当然,本发明也可以使用其他方法代替哈希时间轮算法,对此不作限定。In the present invention, the scheduled task server and the application server are connected through Zookeeper (that is, a distributed service coordination framework, which can be but not limited to Zookeeper in the present invention, and can also be other service frameworks, such as Etcd or Consul) cluster. The application server registers the timed tasks that need to be scheduled to the Zookeeper cluster and generates a task list. Therefore, when the timed task server schedules tasks, it needs to read the timed tasks from the task list first, and at the same time obtain the parameter information of the timed tasks, for example, the timed task The trigger operation of the task, the trigger time of the scheduled task, and the application server related to the scheduled task (if the scheduled task A is related to the application server S, the application server S can execute the scheduled task A, in addition, a scheduled task can be associated with multiple applications server-related), etc., and then write the obtained parameter information into a database (which can be but not limited to a database, and the present invention can also use other storage devices). In the present invention, the timing task server can uniformly schedule and distribute the timing tasks in the task list through the hash time wheel algorithm. Among them, the hash time wheel algorithm is an extended algorithm of the hash algorithm. Specifically, it can be understood that there is a time closed-loop track, and each section represents an equal time. It is assumed that there is a pointer rotating at the center of the track, and the rotation speed is constant. When turning to a certain section, you can take out tasks to be executed from this section (assuming each section is a container), or delete specific tasks in this section, or add new tasks to this section. If the pointer keeps turning, each task in each section can be executed in a constant time period. For the present invention, it can be understood that the task list is a time-closed-loop crawler, and the timing tasks are registered in each section of the time-closed-loop crawler. Certainly, the present invention may also use other methods instead of the hash time-wheel algorithm, which is not limited thereto.
作为本发明的一个实施例,在步骤S101从任务列表中读取定时任务并获取定时任务的参数信息之后,本发明的定时任务调度的方法还可以包括:监控任务列表,并且根据任务列表变更定时任务的参数信息。本发明中,定时任务服务器监控任务列表的信息,一旦发现任务列表上的信息有变更,会将变更信息写入数据库(可以但不限于是数据库,本发明也可以采用其他存储设备)中。其中,变更信息可以是更改任务列表中原有定时任务的参数信息,也可以是将新的定时任务及其参数信息添加到任务列表中的信息,还可以是从任务列表中删除已经成功调度的定时任务的信息等。As an embodiment of the present invention, after step S101 reads the timed task from the task list and acquires the parameter information of the timed task, the method for scheduling the timed task of the present invention may further include: monitoring the task list, and changing the timing according to the task list The parameter information of the task. In the present invention, the timed task server monitors the information of the task list, and once it finds that the information on the task list has changed, it will write the change information into the database (which can be but not limited to a database, and the present invention can also use other storage devices). Among them, the change information can be to change the parameter information of the original scheduled task in the task list, or to add a new scheduled task and its parameter information to the task list, or to delete the scheduled task from the task list. task information, etc.
步骤S102:根据参数信息,将定时任务派送至应用服务器,并监控定时任务的状态信息。本发明中,定时任务的参数信息包括定时任务的调度时间,因此定时任务服务器可以根据调度时间将定时任务派送至应用服务器,然后应用服务器执行定时任务服务器派送的定时任务,同时定时任务服务器监控定时任务的调度过程,获取定时任务的状态信息。Step S102: According to the parameter information, dispatch the scheduled task to the application server, and monitor the status information of the scheduled task. In the present invention, the parameter information of the timing task includes the scheduling time of the timing task, so the timing task server can send the timing task to the application server according to the scheduling time, and then the application server executes the timing task sent by the timing task server, and the timing task server monitors the timing task at the same time. The scheduling process of the task obtains the status information of the scheduled task.
作为本发明的又一个实施例,在步骤S102中的将定时任务派送至应用服务器之前,本发明的定时任务调度的方法还可以包括:获取可用应用服务器列表,并从可用应用服务器列表中筛选可派送应用服务器。相应地,将定时任务派送至应用服务器可以包括:将定时任务派送至可派送应用服务器。本发明中,应用服务器将需要调度的定时任务注册到Zookeeper集群上,生成任务列表的同时,也将应用服务器信息注册到Zookeeper集群上,作为任务调度的应用服务器列表,即可用应用服务器列表。例如,待调度的定时任务为A,定时任务服务器T从Zookeeper集群上获取可用应用服务器列表L,并从L中筛选出可以执行定时任务A的应用服务器S,接着将定时任务A派送至应用服务器S。As yet another embodiment of the present invention, before dispatching the timed task to the application server in step S102, the method for scheduling the timed task of the present invention may further include: obtaining a list of available application servers, and screening available application servers from the list of available application servers dispatch application server. Correspondingly, dispatching the scheduled task to the application server may include: dispatching the scheduled task to the dispatchable application server. In the present invention, the application server registers the scheduled tasks to be scheduled on the Zookeeper cluster, and at the same time as generating the task list, also registers the application server information on the Zookeeper cluster as the list of application servers for task scheduling, that is, the list of available application servers. For example, the timed task to be scheduled is A, the timed task server T obtains the list L of available application servers from the Zookeeper cluster, and filters out the application server S that can execute the timed task A from L, and then dispatches the timed task A to the application server S.
本发明中,定时任务服务集群在多个机房中进行多活部署(即,在多个城市的多个机房部署定时任务服务集群),采用主备工作方式,可以只有零个或者一个主定时服务集群,以及多个备定时服务集群存在。主和备的定时任务服务集群都可以对本机房内部的定时任务进行调度。在主定时任务服务集群中的定时任务的信息可以同步到备定时任务服务集群中。本发明中可以设置在主定时任务服务集群所做的修改都会同步到备定时任务服务集群中。本发明中也可以设置备定时任务服务集群内的定时任务不开启,只有设置了在备定时任务服务集群中开启定时任务的情况下,才可以在备服务集群中进行该定时任务的调度。此外,定时任务服务器的底层系统支持数据库中的存储信息在机房间复制。其中,定时任务服务集群是由多个定时任务服务器按照一定规则部署形成的,比如按照顺序依次选择定时任务服务器调度定时任务。In the present invention, the scheduled task service cluster is deployed in multiple computer rooms (that is, the scheduled task service cluster is deployed in multiple computer rooms in multiple cities), and the active and standby working mode is adopted, and there can be only zero or one active scheduled service cluster, and multiple standby timing service clusters exist. Both the active and standby timing task service clusters can schedule timing tasks inside the computer room. The information of the scheduled tasks in the main scheduled task service cluster can be synchronized to the standby scheduled task service cluster. In the present invention, it can be set that the modifications made in the main timing task service cluster will be synchronized to the standby timing task service cluster. In the present invention, it is also possible to set that the scheduled tasks in the standby scheduled task service cluster are not enabled, and only when the scheduled tasks are enabled in the standby scheduled task service cluster, the scheduled task can be scheduled in the standby service cluster. In addition, the underlying system of the scheduled task server supports the replication of stored information in the database in the computer room. Wherein, the scheduled task service cluster is formed by deploying multiple scheduled task servers according to certain rules, for example, the scheduled task servers are sequentially selected to schedule scheduled tasks.
图2是根据本发明实施例的定时任务调度的多机房运行架构图。如图2所示,定时任务服务集群在多机房中的运行如下:主机房中的定时任务服务集群将监控主机房内的Zookeeper集群上关于定时任务服务集群相关数据的变动情况,并根据情况把需要跨机房传播的数据通过Zookeeper数据同步工具,将相关变动同步到备机房的Zookeeper集群中。此外,对于在数据库中某些需要跨机房复制的表,系统运行过程中的数据变更操作需要及时同步到备机房对应的数据库中去。本发明中数据同步工具可以是通过编码实现两个机房之间数据的同步共用,当然也可以采用其他方法实现数据同步,对此不作限定。机房之间数据同步可以解决当前的跨机房的定时任务调度和机房容灾问题。容灾是指在相隔较远的异地,建立两套或多套功能相同的IT系统,互相之间可以进行健康状态监视和功能切换,当一处系统因意外,如火灾、地震等,停止工作时,整个应用系统可以切换到另一处,使得该系统功能可以继续正常工作。Fig. 2 is a multi-computer room operation architecture diagram of scheduled task scheduling according to an embodiment of the present invention. As shown in Figure 2, the operation of the scheduled task service cluster in multiple computer rooms is as follows: the scheduled task service cluster in the host room will monitor the changes in the data related to the scheduled task service cluster on the Zookeeper cluster in the host room, and The data that needs to be transmitted across the computer room is synchronized to the Zookeeper cluster in the backup computer room through the Zookeeper data synchronization tool. In addition, for some tables in the database that need to be replicated across computer rooms, data change operations during system operation need to be synchronized to the corresponding database in the backup computer room in time. The data synchronization tool in the present invention can realize the synchronization and sharing of data between two computer rooms through coding, and of course other methods can also be used to realize data synchronization, which is not limited. Data synchronization between computer rooms can solve the current cross-computer room timing task scheduling and computer room disaster recovery problems. Disaster recovery refers to the establishment of two or more sets of IT systems with the same functions in remote places, which can monitor the health status and switch functions between each other. When one system stops working due to accidents, such as fires and earthquakes , the entire application system can be switched to another place, so that the system functions can continue to work normally.
图3是根据本发明实施例的定时任务调度的主备切换的架构图。如图3所示,定时任务服务集群的主备切换的过程如下:从定时任务服务集群在系统中已经就绪,等待从备升为主的命令;切换工具发起备升主的命令给从定时任务集群;主定时任务服务集群停止工作,备定时任务服务集群以主开始工作。本发明中,切换工具可以是通过编码实现定时任务服务集群的主备切换,当然也可以采用其他方法,对此不作限定。Fig. 3 is an architecture diagram of active-standby switchover of scheduled task scheduling according to an embodiment of the present invention. As shown in Figure 3, the master-standby switching process of the scheduled task service cluster is as follows: the slave scheduled task service cluster is ready in the system, waiting for the command to upgrade the slave to the master; Cluster; the main timing task service cluster stops working, and the standby timing task service cluster starts working as the master. In the present invention, the switchover tool can realize the active-standby switchover of the timed task service cluster through coding, and of course other methods can also be used, which is not limited.
步骤S103:根据状态信息,判断定时任务是否调度成功,若否,则对定时任务进行补偿调度。补偿调度是指定时任务A应该被执行,但是没有被执行,因此提供再一次机会执行定时任务A。Step S103: According to the status information, it is judged whether the scheduled task is successfully scheduled, and if not, the scheduled task is compensated for scheduling. Compensation scheduling is when it is specified that task A should be executed, but it is not executed, thus providing another opportunity to execute scheduled task A.
本发明实施例中,定时任务服务器监控定时任务的调度过程,获取定时任务的状态信息。其中,调度过程可以包括以下三项过程中至少一项:派送过程、执行过程和取消过程;状态信息可以包括:正在派送、派送成功或者派送失败,正在执行、执行成功、部分执行成功或者执行失败,正在取消、取消成功或者取消失败。图4是根据本发明实施例的定时任务的调度状态示意图。若定时任务A可以被调度,则创建定时任务A,然后根据任务列表更新定时任务A的参数信息,接着派送定时任务A,此时A的状态信息为正在派送。若派送成功,此时A的状态信息为派送成功,若派送失败,此时A的状态信息为派送失败。当A派送成功时,执行任务A,此时A的状态信息为正在执行。若执行成功,此时A的状态信息为执行成功,若执行失败,此时A的状态信息为执行失败,若任务A中的部分被执行了,此时A的状态信息为部分执行成功。若在执行定时任务A的过程中收到取消定时任务A的指令,此时A的状态信息是正在取消,若取消成功,则A的状态信息是取消成功,否则A的状态信息是取消失败。In the embodiment of the present invention, the timed task server monitors the scheduling process of the timed task, and obtains status information of the timed task. Among them, the scheduling process may include at least one of the following three processes: dispatching process, execution process, and cancellation process; status information may include: dispatching, dispatching success or dispatching failure, execution, execution success, partial execution success or execution failure , canceling, canceling successfully, or canceling failed. Fig. 4 is a schematic diagram of a scheduling state of a scheduled task according to an embodiment of the present invention. If scheduled task A can be scheduled, create scheduled task A, then update the parameter information of scheduled task A according to the task list, and then dispatch scheduled task A. At this time, the status information of A is dispatching. If the delivery is successful, the status information of A at this time is delivery success, and if the delivery fails, the status information of A is delivery failure. When A is successfully dispatched, task A is executed, and the status information of A is currently being executed. If the execution is successful, the state information of A at this time is execution success. If the execution fails, the state information of A is execution failure. If part of task A is executed, the state information of A is partial execution success. If the command to cancel the scheduled task A is received during the execution of the scheduled task A, the status information of A is canceling at this time. If the cancellation is successful, the status information of A is canceled successfully, otherwise the status information of A is canceled failed.
作为本发明的另一个实施例,上述步骤S103可以包括:当状态信息是执行成功时,确认定时任务调度成功,并发送将定时任务从任务列表中删除的指令;当状态信息是派送失败、部分执行成功或执行失败时,确认定时任务调度失败,并再次派送定时任务;当执行状态信息是取消成功时,确认定时任务调度失败,并发送将定时任务从任务列表中删除的指令;当执行状态信息是取消失败时,确认定时任务调度失败,并发送再次取消定时任务的指令。As another embodiment of the present invention, the above step S103 may include: when the status information is that the execution is successful, confirm that the scheduling of the scheduled task is successful, and send an instruction to delete the scheduled task from the task list; When the execution succeeds or fails, confirm that the scheduled task scheduling has failed, and send the scheduled task again; when the execution status information is canceled successfully, confirm that the scheduled task has failed, and send an instruction to delete the scheduled task from the task list; when the execution status The information is that when the cancellation fails, confirm that the scheduling of the scheduled task fails, and send an instruction to cancel the scheduled task again.
图5是根据本发明的一个可参考实施例的定时任务调度的方法的主要流程的示意图。如图5所示,定时任务调度的方法的主要流程可以包括:Fig. 5 is a schematic diagram of a main flow of a method for scheduling scheduled tasks according to a reference embodiment of the present invention. As shown in Figure 5, the main process of the method for scheduled task scheduling may include:
步骤S501,定时任务服务器从任务列表中读取待调度的定时任务,并获取该定时任务的参数信息;Step S501, the scheduled task server reads the scheduled task from the task list, and obtains the parameter information of the scheduled task;
步骤S502,监控任务列表,并且根据任务列表变更该定时任务的参数信息;Step S502, monitor the task list, and change the parameter information of the scheduled task according to the task list;
步骤S503,获取可用应用服务器列表,并从可用应用服务器列表中筛选可派送应用服务器;Step S503, obtaining a list of available application servers, and selecting dispatchable application servers from the list of available application servers;
步骤S504,根据该定时任务的参数信息,将该定时任务派送至可派送应用服务器,并监控该定时任务的状态信息;Step S504, according to the parameter information of the timed task, dispatch the timed task to the dispatchable application server, and monitor the state information of the timed task;
步骤S505,当状态信息是执行成功时,确认该定时任务调度成功,并发送将该定时任务从任务列表中删除的指令;Step S505, when the status information is that the execution is successful, confirm that the scheduled task is successfully scheduled, and send an instruction to delete the scheduled task from the task list;
步骤S506,当状态信息是派送失败、部分执行成功或执行失败时,确认该定时任务调度失败,并再次派送该定时任务;Step S506, when the status information is dispatch failure, partial execution success or execution failure, confirm that the timing task scheduling fails, and dispatch the timing task again;
步骤S507,当执行状态信息是取消成功时,确认该定时任务调度失败,并发送将该定时任务从任务列表中删除的指令;Step S507, when the execution status information indicates that the cancellation is successful, confirm that the scheduling of the scheduled task has failed, and send an instruction to delete the scheduled task from the task list;
步骤S508,当执行状态信息是取消失败时,确认该定时任务调度失败,并发送再次取消该定时任务的指令。Step S508, when the execution status information is cancellation failure, confirm that the scheduling of the scheduled task fails, and send an instruction to cancel the scheduled task again.
图6是实现本发明定时任务调度方法的整体架构图。如图6所示,实现本发明定时任务调度方法的整体架构主要由定时任务服务集群和应用服务器两部分组成。应用服务器相当于是客户端,定时任务服务集群相当于是服务端。如图6所示,实现本发明定时任务调度方法中,首先部署好定时任务服务器,定时任务服务器之间组成一个分布式定时任务服务集群,对外提供任务调度功能。首先部署好定时任务服务器,定时任务服务器之间,组成一个分布式定时任务服务集群,对外提供任务调度功能。图中的Zookeeper集群可以看作是配置中心,定时任务的参数信息均注册在Zookeeper集群中,另外,应用服务器的信息也注册在Zookeeper集群中。图6中,定时任务首先由应用服务器注册到Zookeeper集群中,并记录定时任务的参数信息。由于定时任务服务集群监听Zookeeper集群,因此一旦有新的定时任务注册到集群中或者定时任务的参数信息有变更时,该信息会被记录到数据库中。FIG. 6 is an overall architecture diagram for implementing the timing task scheduling method of the present invention. As shown in FIG. 6 , the overall framework for implementing the scheduled task scheduling method of the present invention is mainly composed of two parts: a scheduled task service cluster and an application server. The application server is equivalent to the client, and the scheduled task service cluster is equivalent to the server. As shown in FIG. 6 , in implementing the scheduled task scheduling method of the present invention, the scheduled task servers are deployed first, and a distributed scheduled task service cluster is formed among the scheduled task servers to provide external task scheduling functions. First of all, the scheduled task server is deployed, and a distributed scheduled task service cluster is formed between the scheduled task servers to provide external task scheduling functions. The Zookeeper cluster in the figure can be regarded as a configuration center. The parameter information of the scheduled task is registered in the Zookeeper cluster. In addition, the information of the application server is also registered in the Zookeeper cluster. In Fig. 6, the scheduled task is first registered in the Zookeeper cluster by the application server, and the parameter information of the scheduled task is recorded. Since the scheduled task service cluster monitors the Zookeeper cluster, once a new scheduled task is registered in the cluster or the parameter information of the scheduled task is changed, the information will be recorded in the database.
需要注意的是,当定时任务服务器可以既是定时任务服务器,又是应用服务器时,定时任务服务集群也可以在Zookeeper上注册定时任务。还需要注意的是,图6中的应用服务器1、2和3并不是指3个应用服务器,而是指针对不同应用的3种类型的服务器,即应用服务器1可以包括多个可以执行同一个定时任务的服务器。It should be noted that when the scheduled task server can be both a scheduled task server and an application server, the scheduled task service cluster can also register scheduled tasks on Zookeeper. It should also be noted that application servers 1, 2, and 3 in Figure 6 do not refer to three application servers, but three types of servers for different applications, that is, application server 1 may include multiple servers that can execute the same Server for scheduled tasks.
根据本发明实施例的定时任务调度的技术方案可以看出,能够实时获取定时任务的状态信息,达到任务调度透明化的效果,并且本发明提供定时任务补偿机制,提高了定时任务的调度效率;本发明实施例中监控任务列表,从而在定时任务有变更时,可以将定时任务的参数信息及时更新,提高了定时任务调度的效率;本发明实施例中派送定时任务之前,从获取的可用应用服务器列表中筛选可派送应用服务器,从而可以提高定时任务派送的准确性;本发明实施例中状态信息可以包括:正在派送、派送成功或者派送失败,正在执行、执行成功、部分执行成功或者执行失败,正在取消、取消成功或者取消失败,能够实时获取定时任务的调度状态,实现调度链路的透明化;本发明实施例中根据状态信息,确认定时任务的调度进程,判断定时任务的调度结果,从而可以对定时任务进行相应处理。According to the technical solution of timing task scheduling in the embodiment of the present invention, it can be seen that the status information of timing tasks can be obtained in real time, achieving the effect of transparent task scheduling, and the invention provides a compensation mechanism for timing tasks, which improves the scheduling efficiency of timing tasks; In the embodiment of the present invention, the task list is monitored, so that when the scheduled task is changed, the parameter information of the scheduled task can be updated in time, which improves the efficiency of scheduled task scheduling; before the scheduled task is dispatched in the embodiment of the present invention, the available application Filter the dispatchable application server in the server list, so as to improve the accuracy of scheduled task dispatch; in the embodiment of the present invention, the status information may include: dispatching, dispatching success or dispatch failure, execution, execution success, partial execution success or execution failure , canceling, canceling successfully, or canceling failed, the scheduling status of the scheduled task can be obtained in real time to realize the transparency of the scheduling link; in the embodiment of the present invention, according to the status information, the scheduling process of the scheduled task is confirmed, and the scheduling result of the scheduled task is judged. In this way, the timing tasks can be processed accordingly.
图7是根据本发明实施例的定时任务调度的装置的主要模块的示意图。如图7所示,本发明实施例的定时任务调度的装置700主要包括以下模块:获取模块701、监控模块702和判断模块703。其中,获取模块701可用于从任务列表中读取定时任务,并获取定时任务的参数信息。监控模块702可用于根据参数信息,将定时任务派送至应用服务器,并监控定时任务的状态信息。判断模块703可用于根据状态信息,判断定时任务是否调度成功,若否,则对定时任务进行补偿调度。Fig. 7 is a schematic diagram of main modules of an apparatus for scheduling scheduled tasks according to an embodiment of the present invention. As shown in FIG. 7 , an apparatus 700 for scheduled task scheduling according to an embodiment of the present invention mainly includes the following modules: an acquisition module 701 , a monitoring module 702 and a judging module 703 . Wherein, the obtaining module 701 can be used to read the scheduled task from the task list, and obtain the parameter information of the scheduled task. The monitoring module 702 can be used to dispatch the scheduled task to the application server according to the parameter information, and monitor the status information of the scheduled task. The judging module 703 can be used to judge whether the scheduled task is successfully scheduled according to the state information, and if not, perform compensation scheduling for the scheduled task.
本发明实施例中,获取模块701还可用于:监控任务列表,并且根据任务列表变更所述定时任务的参数信息。In the embodiment of the present invention, the obtaining module 701 can also be used to: monitor the task list, and change the parameter information of the scheduled task according to the task list.
本发明实施例中,监控模块702还可用于:获取可用应用服务器列表,并从可用应用服务器列表中筛选可派送应用服务器;将定时任务派送至可派送应用服务器。In the embodiment of the present invention, the monitoring module 702 can also be used to: obtain a list of available application servers, and filter dispatchable application servers from the list of available application servers; and dispatch scheduled tasks to dispatchable application servers.
本发明实施例中,状态信息可以包括:正在派送、派送成功或者派送失败,正在执行、执行成功、部分执行成功或者执行失败,正在取消、取消成功或者取消失败。In the embodiment of the present invention, the status information may include: being dispatched, dispatched successfully or dispatched failed, executing, executed successfully, partially executed successfully or executed failed, canceling, canceled successfully or canceled failed.
本发明实施例中,判断模块703还可用于:当状态信息是执行成功时,确认定时任务调度成功,并发送将定时任务从任务列表中删除的指令;当状态信息是派送失败、部分执行成功或执行失败时,确认定时任务调度失败,并再次派送定时任务;当执行状态信息是取消成功时,确认定时任务调度失败,并发送将定时任务从任务列表中删除的指令;当执行状态信息是取消失败时,确认定时任务调度失败,并发送再次取消定时任务的指令。In the embodiment of the present invention, the judging module 703 can also be used to: when the status information is that the execution is successful, confirm that the scheduling of the scheduled task is successful, and send an instruction to delete the scheduled task from the task list; Or when the execution fails, confirm that the scheduling of the scheduled task has failed, and send the scheduled task again; when the execution status information is canceled successfully, confirm that the scheduling of the scheduled task has failed, and send an instruction to delete the scheduled task from the task list; when the execution status information is When the cancellation fails, confirm that the scheduling of the scheduled task fails, and send an instruction to cancel the scheduled task again.
从以上描述可以看出,能够实时获取定时任务的状态信息,达到任务调度透明化的效果,并且本发明提供定时任务补偿机制,提高了定时任务的调度效率;本发明实施例中监控任务列表,从而在定时任务有变更时,可以将定时任务的参数信息及时更新,提高了定时任务调度的效率;本发明实施例中派送定时任务之前,从获取的可用应用服务器列表中筛选可派送应用服务器,从而可以提高定时任务派送的准确性;本发明实施例中状态信息可以包括:正在派送、派送成功或者派送失败,正在执行、执行成功、部分执行成功或者执行失败,正在取消、取消成功或者取消失败,能够实时获取定时任务的调度状态,实现调度链路的透明化;本发明实施例中根据状态信息,确认定时任务的调度进程,判断定时任务的调度结果,从而可以对定时任务进行相应处理。It can be seen from the above description that the status information of the scheduled task can be obtained in real time, achieving the effect of transparent task scheduling, and the present invention provides a scheduled task compensation mechanism, which improves the scheduling efficiency of the scheduled task; in the embodiment of the present invention, the monitoring task list, Therefore, when the scheduled task is changed, the parameter information of the scheduled task can be updated in time, which improves the scheduling efficiency of the scheduled task; before dispatching the scheduled task in the embodiment of the present invention, the dispatchable application server is selected from the obtained list of available application servers, Thereby, the accuracy of timing task delivery can be improved; in the embodiment of the present invention, the status information can include: being delivered, successfully delivered or failed to deliver, being executed, successfully executed, partially executed successfully or failed to execute, being canceled, successfully canceled or failed to cancel , the scheduling status of the scheduled task can be obtained in real time, and the transparency of the scheduling link can be realized; in the embodiment of the present invention, the scheduling process of the scheduled task can be confirmed according to the status information, and the scheduling result of the scheduled task can be judged, so that the scheduled task can be processed accordingly.
图8示出了可以应用本发明实施例的定时任务调度的方法或定时任务调度的装置的示例性系统架构800。FIG. 8 shows an exemplary system architecture 800 to which the method for scheduling a scheduled task or the device for scheduling a scheduled task according to an embodiment of the present invention can be applied.
如图8所示,系统架构800可以包括终端设备801、802、803,网络804和服务器805。网络804用以在终端设备801、802、803和服务器805之间提供通信链路的介质。网络804可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。As shown in FIG. 8 , a system architecture 800 may include terminal devices 801 , 802 , and 803 , a network 804 and a server 805 . The network 804 is used as a medium for providing communication links between the terminal devices 801 , 802 , 803 and the server 805 . Network 804 may include various connection types, such as wires, wireless communication links, or fiber optic cables, among others.
用户可以使用终端设备801、802、803通过网络804与服务器805交互,以接收或发送消息等。终端设备801、802、803上可以安装有各种通讯客户端应用,例如购物类应用、网页浏览器应用、搜索类应用、即时通信工具、邮箱客户端、社交平台软件等(仅为示例)。Users can use terminal devices 801, 802, 803 to interact with server 805 through network 804 to receive or send messages and the like. Various communication client applications can be installed on the terminal devices 801, 802, and 803, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (just examples).
终端设备801、802、803可以是具有显示屏并且支持网页浏览的各种电子设备,包括但不限于智能手机、平板电脑、膝上型便携计算机和台式计算机等等。The terminal devices 801, 802, and 803 may be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
服务器805可以是提供各种服务的服务器,例如对用户利用终端设备801、802、803所浏览的购物类网站提供支持的后台管理服务器(仅为示例)。后台管理服务器可以对接收到的产品信息查询请求等数据进行分析等处理,并将处理结果(例如目标推送信息、产品信息--仅为示例)反馈给终端设备。The server 805 may be a server that provides various services, such as a background management server that provides support for shopping websites browsed by users using the terminal devices 801 , 802 , and 803 (just an example). The background management server can analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information—just an example) to the terminal device.
需要说明的是,本发明实施例所提供的定时任务调度的方法一般由服务器805执行,相应地,定时任务调度的装置一般设置于服务器805中。It should be noted that the scheduled task scheduling method provided by the embodiment of the present invention is generally executed by the server 805 , and correspondingly, the scheduled task scheduling device is generally set in the server 805 .
应该理解,图8中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。It should be understood that the numbers of terminal devices, networks and servers in FIG. 8 are only illustrative. According to the implementation needs, there can be any number of terminal devices, networks and servers.
下面参考图9,其示出了适于用来实现本发明实施例的终端设备的计算机系统900的结构示意图。图9示出的终端设备仅仅是一个示例,不应对本发明实施例的功能和使用范围带来任何限制。Referring now to FIG. 9 , it shows a schematic structural diagram of a computer system 900 suitable for implementing a terminal device according to an embodiment of the present invention. The terminal device shown in FIG. 9 is only an example, and should not limit the functions and scope of use of this embodiment of the present invention.
如图9所示,计算机系统900包括中央处理单元(CPU)901,其可以根据存储在只读存储器(ROM)902中的程序或者从存储部分908加载到随机访问存储器(RAM)903中的程序而执行各种适当的动作和处理。在RAM 903中,还存储有系统900操作所需的各种程序和数据。CPU 901、ROM 902以及RAM 903通过总线904彼此相连。输入/输出(I/O)接口905也连接至总线904。As shown in FIG. 9 , a computer system 900 includes a central processing unit (CPU) 901 that can be programmed according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage section 908 into a random-access memory (RAM) 903 Instead, various appropriate actions and processes are performed. In the RAM 903, various programs and data necessary for the operation of the system 900 are also stored. The CPU 901 , ROM 902 , and RAM 903 are connected to each other via a bus 904 . An input/output (I/O) interface 905 is also connected to the bus 904 .
以下部件连接至I/O接口905:包括键盘、鼠标等的输入部分906;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分907;包括硬盘等的存储部分908;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分909。通信部分909经由诸如因特网的网络执行通信处理。驱动器910也根据需要连接至I/O接口905。可拆卸介质911,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器910上,以便于从其上读出的计算机程序根据需要被安装入存储部分908。The following components are connected to the I/O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 908 including a hard disk, etc. and a communication section 909 including a network interface card such as a LAN card, a modem, or the like. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I/O interface 905 as needed. A removable medium 911 such as a magnetic disk, optical disk, magneto-optical disk, semiconductor memory, etc. is mounted on the drive 910 as necessary so that a computer program read therefrom is installed into the storage section 908 as necessary.
特别地,根据本发明公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本发明公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分909从网络上被下载和安装,和/或从可拆卸介质911被安装。在该计算机程序被中央处理单元(CPU)901执行时,执行本发明的系统中限定的上述功能。In particular, according to the disclosed embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the disclosed embodiments of the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, where the computer program includes program codes for executing the methods shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communication portion 909 and/or installed from removable media 911 . When this computer program is executed by a central processing unit (CPU) 901, the above-described functions defined in the system of the present invention are performed.
需要说明的是,本发明所示的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本发明中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本发明中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. A computer readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, electrical connections with one or more wires, portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, however, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, in which computer-readable program codes are carried. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. . Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
附图中的流程图和框图,图示了按照本发明各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, program segment, or portion of code that includes one or more logical functions for implementing specified executable instructions. It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved. It should also be noted that each block in the block diagrams or flowchart illustrations, and combinations of blocks in the block diagrams or flowchart illustrations, can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a A combination of dedicated hardware and computer instructions.
描述于本发明实施例中所涉及到的模块可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的模块也可以设置在处理器中,例如,可以描述为:一种处理器包括获取模块、监控模块和判断模块。其中,这些模块的名称在某种情况下并不构成对该模块本身的限定,例如,获取模块还可以被描述为“从任务列表中读取定时任务,并获取定时任务的参数信息的模块”。The modules involved in the embodiments described in the present invention may be implemented by software or by hardware. The described modules can also be set in a processor, for example, it can be described as: a processor includes an acquisition module, a monitoring module and a judging module. Among them, the names of these modules do not constitute a limitation of the module itself under certain circumstances. For example, the acquisition module can also be described as "a module that reads the scheduled tasks from the task list and obtains the parameter information of the scheduled tasks." .
作为另一方面,本发明还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的设备中所包含的;也可以是单独存在,而未装配入该设备中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被一个该设备执行时,使得该设备包括:从任务列表中读取定时任务,并获取定时任务的参数信息;根据参数信息,将定时任务派送至应用服务器,并监控定时任务的状态信息;根据状态信息,判断定时任务是否调度成功,若否,则对定时任务进行补偿调度。As another aspect, the present invention also provides a computer-readable medium. The computer-readable medium may be contained in the device described in the above embodiments, or it may exist independently without being assembled into the device. The above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by the device, the device includes: reading the scheduled task from the task list, and obtaining the parameter information of the scheduled task; according to Parameter information, dispatch the scheduled task to the application server, and monitor the status information of the scheduled task; judge whether the scheduled task is successfully scheduled according to the status information, and if not, perform compensation scheduling for the scheduled task.
根据本发明实施例的技术方案,能够实时获取定时任务的状态信息,达到任务调度透明化的效果,并且本发明提供定时任务补偿机制,提高了定时任务的调度效率;本发明实施例中监控任务列表,从而在定时任务有变更时,可以将定时任务的参数信息及时更新,提高了定时任务调度的效率;本发明实施例中派送定时任务之前,从获取的可用应用服务器列表中筛选可派送应用服务器,从而可以提高定时任务派送的准确性;本发明实施例中状态信息可以包括:正在派送、派送成功或者派送失败,正在执行、执行成功、部分执行成功或者执行失败,正在取消、取消成功或者取消失败,能够实时获取定时任务的调度状态,实现调度链路的透明化;本发明实施例中根据状态信息,确认定时任务的调度进程,判断定时任务的调度结果,从而可以对定时任务进行相应处理。According to the technical solution of the embodiment of the present invention, the status information of the scheduled task can be obtained in real time, achieving the effect of transparent task scheduling, and the present invention provides a compensation mechanism for the scheduled task, which improves the scheduling efficiency of the scheduled task; the monitoring task in the embodiment of the present invention list, so that when the timed task is changed, the parameter information of the timed task can be updated in time, which improves the efficiency of timed task scheduling; before dispatching the timed task in the embodiment of the present invention, the dispatchable application can be selected from the obtained list of available application servers server, so as to improve the accuracy of timed task dispatch; in the embodiment of the present invention, the status information may include: dispatching, successful dispatch or dispatch failure, executing, executing successfully, partially executing successfully or failing to execute, canceling, canceling successfully or If the cancellation fails, the scheduling status of the scheduled task can be obtained in real time to realize the transparency of the scheduling link; in the embodiment of the present invention, according to the status information, the scheduling process of the scheduled task is confirmed, and the scheduling result of the scheduled task is judged, so that the scheduled task can be correspondingly deal with.
上述具体实施方式,并不构成对本发明保护范围的限制。本领域技术人员应该明白的是,取决于设计要求和其他因素,可以发生各种各样的修改、组合、子组合和替代。任何在本发明的精神和原则之内所作的修改、等同替换和改进等,均应包含在本发明保护范围之内。The above specific implementation methods do not constitute a limitation to the protection scope of the present invention. It should be apparent to those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201810620782.7ACN110609734A (en) | 2018-06-15 | 2018-06-15 | Method and device for scheduled task scheduling |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201810620782.7ACN110609734A (en) | 2018-06-15 | 2018-06-15 | Method and device for scheduled task scheduling |
| Publication Number | Publication Date |
|---|---|
| CN110609734Atrue CN110609734A (en) | 2019-12-24 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201810620782.7APendingCN110609734A (en) | 2018-06-15 | 2018-06-15 | Method and device for scheduled task scheduling |
| Country | Link |
|---|---|
| CN (1) | CN110609734A (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113590276A (en)* | 2021-05-11 | 2021-11-02 | 深圳市数商时代科技有限公司 | Information pushing method and related product |
| CN113672358A (en)* | 2020-05-15 | 2021-11-19 | 北京沃东天骏信息技术有限公司 | Timing task processing method, device and system, electronic equipment and storage medium |
| CN113760481A (en)* | 2020-06-18 | 2021-12-07 | 北京沃东天骏信息技术有限公司 | Distributed timed task scheduling system and method |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| GB201516856D0 (en)* | 2015-09-23 | 2015-11-04 | Fujitsu Ltd | Task scheduler and task scheduling process |
| JP2016018396A (en)* | 2014-07-08 | 2016-02-01 | キヤノン株式会社 | Information processing system, server, control method and computer program |
| CN105955811A (en)* | 2016-05-05 | 2016-09-21 | 北京思特奇信息技术股份有限公司 | System and method for achieving task scheduling based on remote invoking mode |
| CN107133089A (en)* | 2017-04-27 | 2017-09-05 | 努比亚技术有限公司 | A kind of task scheduling server and method for scheduling task |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2016018396A (en)* | 2014-07-08 | 2016-02-01 | キヤノン株式会社 | Information processing system, server, control method and computer program |
| GB201516856D0 (en)* | 2015-09-23 | 2015-11-04 | Fujitsu Ltd | Task scheduler and task scheduling process |
| CN105955811A (en)* | 2016-05-05 | 2016-09-21 | 北京思特奇信息技术股份有限公司 | System and method for achieving task scheduling based on remote invoking mode |
| CN107133089A (en)* | 2017-04-27 | 2017-09-05 | 努比亚技术有限公司 | A kind of task scheduling server and method for scheduling task |
| Title |
|---|
| 田明杰;黄飞;方涛;: "SIG框架基于多线程技术分布式系统的任务调度", 计算机工程, no. 23, 5 December 2005 (2005-12-05)* |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113672358A (en)* | 2020-05-15 | 2021-11-19 | 北京沃东天骏信息技术有限公司 | Timing task processing method, device and system, electronic equipment and storage medium |
| CN113760481A (en)* | 2020-06-18 | 2021-12-07 | 北京沃东天骏信息技术有限公司 | Distributed timed task scheduling system and method |
| CN113590276A (en)* | 2021-05-11 | 2021-11-02 | 深圳市数商时代科技有限公司 | Information pushing method and related product |
| Publication | Publication Date | Title |
|---|---|---|
| US11210185B2 (en) | Method and system for data recovery in a data system | |
| CN108647083B (en) | Task execution method, device, system, electronic equipment and computer readable medium | |
| US20210117895A1 (en) | Systems and Methods for Cross-Platform Scheduling and Workload Automation | |
| CN109245908B (en) | Method and device for switching master cluster and slave cluster | |
| US10261872B2 (en) | Multilevel disaster recovery | |
| US20190163763A1 (en) | Centralized Multi-Cloud Workload Protection with Platform Agnostic Centralized File Browse and File Retrieval Time Machine | |
| US20130091376A1 (en) | Self-repairing database system | |
| US20200026786A1 (en) | Management and synchronization of batch workloads with active/active sites using proxy replication engines | |
| CN111666134B (en) | A distributed task scheduling method and system | |
| CN108932157B (en) | Method, system, electronic device and readable medium for distributed processing of tasks | |
| CN112825525B (en) | Method and apparatus for processing transactions | |
| US11799839B2 (en) | Cross-regional replication of keys | |
| US11693682B2 (en) | Method and system for disaster recovery of a regional cloud based desktop fabric | |
| CN110659124A (en) | A message processing method and device | |
| CN111181765A (en) | Task processing method and device | |
| CN110609734A (en) | Method and device for scheduled task scheduling | |
| CN112860505A (en) | Method and device for regulating and controlling distributed clusters | |
| CN113472638B (en) | Edge gateway control method, system, device, electronic equipment and storage medium | |
| CN102185717A (en) | Service processing equipment, method and system | |
| WO2020131485A2 (en) | Methods, apparatuses and systems for cloud-based disaster recovery | |
| CN114925052A (en) | Method, device, equipment and computer readable medium for restarting database | |
| CN108833147B (en) | Configuration information updating method and device | |
| JP2015114952A (en) | Network system, monitoring control unit, and software verification method | |
| CN110019059B (en) | Timing synchronization method and device | |
| CN106357735B (en) | For operating the method and apparatus of the infrastructure layer of cloud computing framework |
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| RJ01 | Rejection of invention patent application after publication | ||
| RJ01 | Rejection of invention patent application after publication | Application publication date:20191224 |