The content of the invention
For above-mentioned technical problem, the application provides a kind of timed task dispatching method, apparatus and system, skill
Art scheme is as follows:
According to the first aspect of the application, there is provided a kind of timed task dispatching method, service node is applied to,
The method includes:
Receive the timed task triggering message that scheduling node sends;
Message is triggered according to the timed task, the timed task list local to service node is scanned,
Need the timed task for performing to record comprising service node in the task list, in every task record at least
Executive mode information comprising the task and execution time information;
Execution time information according to task, it is determined that current pending task;
Executive mode information according to task, performs identified pending task.
According to the second aspect of the application, there is provided a kind of timed task dispatching method, the method includes:
Scheduling node sends timed task triggering and disappears according to the clocked flip task being locally configured, to service node
Breath, in the clocked flip task, includes the identification information of triggering moment information and target service node;
Service node receives the timed task triggering message that scheduling node sends;Triggered according to the timed task
Message, the timed task list local to service node is scanned, and business section is included in the task list
Point needs the timed task record for performing, including at least the executive mode information of the task in every task record
With execution time information;Execution time information according to task, it is determined that current pending task;According to appoint
The executive mode information of business, performs identified pending task.
According to the third aspect of the application, there is provided a kind of timed task dispatching device, service node is applied to,
The device includes:
Triggering message reception module, the timed task for receiving scheduling node transmission triggers message;
Scan module, for triggering message, the timed task local to service node according to the timed task
List is scanned, and needs the timed task for performing to record comprising service node in the task list, every
Including at least the executive mode information and execution time information of the task in task record;
Task determining module, for the execution time information according to task, it is determined that current pending task;
Task execution module, for the executive mode information according to task, performs identified pending task.
According to the fourth aspect of the application, there is provided a kind of timed task dispatches system, the system includes that scheduling is saved
Point side device and service node side device:
Scheduling node side device sends timed task according to the clocked flip task being locally configured to service node
Triggering message, in the clocked flip task, includes the mark of triggering moment information and target service node
Information;
Service node side device receives the timed task triggering message that scheduling node sends;Appointed according to the timing
Business triggering message, the timed task list local to service node is scanned, is included in the task list
Service node needs the timed task record for performing, including at least the execution side of the task in every task record
Formula information and execution time information;Execution time information according to task, it is determined that current pending task;
Executive mode information according to task, performs identified pending task.
Technical scheme provided herein, the details of multiple timed tasks are stored in the way of list
In each service node, and in scheduling node, a small amount of triggering task only need to be configured, regularly to accuse
Know service node, voluntarily confirm there is which task needs to perform by the task list mode for scanning local.With
Existing timed task scheduling scheme is compared, and the pressure of scheduling node is significantly reduced.On the other hand, if needed
To increase task to service node, it is only necessary to corresponding task record is added in the task list of the node i.e.
Can, without carrying out configuration modification in scheduling node side, effectively improve the convenience of expanding of system function.
It should be appreciated that the general description of the above and detailed description hereinafter are only exemplary and explanatory,
The application can not be limited.
Specific embodiment
In order that those skilled in the art more fully understand the technical scheme in the application, below in conjunction with this Shen
Accompanying drawing that please be in embodiment, is described in detail, it is clear that institute to the technical scheme in the embodiment of the present application
The embodiment of description is only some embodiments of the present application, rather than whole embodiments.Based on the application
In embodiment, the every other embodiment that those of ordinary skill in the art are obtained should all belong to this Shen
The scope that please be protect.
Runtime framework first to application scheme is illustrated.It is shown in Figure 1, application scheme
The interaction agent being related to includes:One scheduling node 100 and multiple service nodes 200.Wherein scheduling node
100 is the distribution side of task, and service node 200 is the execution side of task.Scheduling node 100 and service node
There is communication connection between 200.The actual form of each node can be physical equipment, or virtual machine,
The application need not simultaneously be defined to this.
In the entire system, there are multiple timed tasks, these timed tasks need to be come by each service node
Perform.Application scheme difference with the prior art is:The details of each timed task are not stored
In scheduling node, and it is stored in service node.For scheduling node, without being concerned about each industry
Business node, the execution details of each task, only need to be when needing service node to perform task, regularly to business
Node send task triggering message, then by service node self-check whether have task to perform, Yi Jixu
Which task performed.
It is the flow chart of the timed task dispatching method that the application is provided shown in Fig. 2, the method can include
Following steps:
S101, scheduling node sends timed task according to the clocked flip task being locally configured to service node
Triggering message.
According to application scheme, configuring timing tasks are still needed in scheduling node, but scheduling node is in itself
And the details of actual task need not be paid close attention to, it is only necessary to record actual task need by which/which service node
Perform and need when triggering actual task execution.Area is carried out for convenience of difference and prior art
Not, the timed task configured in application scheme scheduling node is referred to as " clocked flip task ".
In a record for clocked flip task, it is necessary to comprising essential information be " triggering moment " and
" mark of target service node ".
Wherein " triggering moment " can be disposable effective moment, such as " 10:00 triggering ", has triggered
Bi Hou, the clocked flip task ceases to be in force automatically, or the moment is updated according to default rule, example
Such as after once triggering is finished, triggering moment is updated automatically according to the triggering cycle;Can also have
The moment of cyclophysis, such as " daily 10:00 triggering ", " daily 10:00 and 22:00 ", " daily integral point
Triggering " etc..
The concrete form of " mark of target service node " can be the numbering, communicatedly of target service node
Location etc..The quantity of target service node can be 1, or multiple.For target service node
Situation more than 1, scheduling node will be when triggering moment be reached, in a broadcast manner to each target industry
Business node sends timed task triggering message.
Certainly, in addition to " triggering moment " and " mark of target service node ", appoint in clocked flip
Other information, such as triggered time last time, triggering times statistics, triggering week can also be further included in business
Phase etc..The application need not simultaneously be defined to this.
Assuming that needing service node 1 to perform 4 timed tasks:10:00 perform task A and task B,
11:00 perform task C, 12:00 row task D, the timed task scheduling scheme according to prior art is needed
4 timed tasks are configured in scheduling node, and logger task respectively is needed in each timed task
The detail of A/B/C/D, the program called including needs, instruction, execution parameter etc..And according to the application
Scheme, it is only necessary to configure 1 clocked flip task, set triggering moment as 10:00、11:00、12:00,
Destination node is node 1.
When there is multiple service nodes, when the business if there is multiple service nodes performs triggering
Require at quarter it is identical, then can be directed to these service nodes, configure a shared clocked flip task;Such as
Really to perform the moment different for several node traffics, then need to be respectively configured for these service nodes and independent determine
When trigger task.
It can be seen that, if there is 10 service nodes, each service node needs to perform 20 tasks, according to
The timed task scheduling scheme of prior art in scheduling node, it is necessary to configure 200 timed tasks.And it is sharp
With timed task scheduling scheme provided herein, at most only need to configure 10 timings in scheduling node
Triggering task, performs triggering moment requirement identical, then adjusting if there is multiple service nodes, its business
The clocked flip task quantity configured in degree node can also be reduced further, (10 business under extreme case
It is all identical that the business of node performs triggering moment requirement), it is only necessary to configure 1 clocked flip in scheduling node and appoint
Business is capable of achieving to 200 scheduling of timed task altogether.
S102, after service node receives the timed task triggering message that scheduling node sends, disappears according to the triggering
The breath timed task list local to service node is scanned.
According to application scheme, the details of timed task are stored in the business section for needing to perform the task
In point, each timed task one task record of correspondence, a plurality of task record is stored in the form of a list,
Wherein, the essential information to be included needed for each record is the task " executive mode " and " holds
The row moment ".
Wherein, " executive mode ", can be program, instruction that execution task needs are called etc., enter one
Step can also include the execution parameter of task, and to realize various expanded functions, such as input and output control, are
Task assigned priority, distribution processor, memory source etc..
" performing the moment " is then that the expectation of the task performs the moment, similar with " triggering moment " in S101,
The moment can also be disposable effective moment or the moment with cyclophysis.For disposably having
The moment of effect, the tasks carrying ceases to be in force automatically after finishing, or is updated according to default rule.For example:
The execution frequency of certain task is 1 time per hour, and before tasks carrying, the execution moment in record is 10:00,
The moment represents that the next time of task performs the moment.Assuming that task is 10:Performed on time when 00, then tasks carrying is complete
Bi Hou, the execution frequency according to the task will perform the moment next time and is updated to 11 automatically:00.
It should be noted that for same task, its " triggering moment " with " performing the moment " not
It is required that strict conformance:On the one hand, from " triggering " to certainly existing time delay, practical application " execution "
In, if to the ageing less demanding of tasks carrying, need not deliberately consider this problem, if to appointing
Business is performed certain ageing requirement, then can be with, can " triggering moment " suitably shift to an earlier date.
On the other hand, because a triggering task may correspond to multiple actual tasks, and each actual task
It is required that performing the moment is likely to difference, therefore " triggering moment " often than " performing the moment " with higher
Frequency.And, for ageing task higher, it would however also be possible to employ shorten the mode at triggering moment interval,
So as to ensure that task node scan task list in time and can perform task.
Certainly, in addition to " executive mode " and " performing the moment " information, in a task record also
Other information, such as execution of triggered time last time, last time execution time, task can further be included frequently
Rate (can be used to automatically update execution time information), task switch mark (whether effective for identifying the task)
Etc., the application need not simultaneously be defined to this.
Table 1 show a kind of example of timed task list, it should be appreciated that the list is only used for illustrating
Property explanation, should not be construed the restriction to application scheme.
Table 1
S103, the execution time information according to task, it is determined that current pending task;
Service node is according to the scanning result of S102, it is determined that being currently needed for performing for task.Specifically, it is right
In each task record, if the current moment meets it performs moment requirement, you can the task is determined
It is pending task.It is understood that " meet and require " mentioned here not necessarily stricti jurise
On it is identical, actual is often " current time is later than the execution moment " i.e. it is believed that being currently needed for performing this
Business.
In addition, if the switch mark information of task is contained in task list, then in this step, only
Need to be from task identification task record, it is determined that current pending task.By taking table 1 as an example, it is assumed that when current
Carve is 11:05, then according to " next time perform moment ", task 1 and task 2 are satisfied by performing the requirement at moment,
But the task switch of task 2 is False, show that the task is currently at disarmed state, therefore finally only will
Task 1 is defined as pending task.
S104, the executive mode information according to task performs identified pending task.
In this step, according to the executive mode information be given in task list, perform and treated determined by S103
Execution task.
It can be seen that, using application scheme, and in scheduling node, a small amount of triggering task only need to be configured, make
The pressure for obtaining scheduling node is significantly reduced.On the other hand, if necessary to increase task to service node, only need
Corresponding task record is added in the task list of the node, without being matched somebody with somebody in scheduling node side
Modification is put, the convenience of expanding of system function is effectively improved.
Corresponding to above method embodiment, the application also provides a kind of timed task for being applied to service node side
Dispatching device, shown in Figure 3, the device can include:
Triggering message reception module 110, the timed task for receiving scheduling node transmission triggers message;
Scan module 120, for triggering message, the timed task row local to service node according to timed task
Table is scanned, and needs the timed task for performing to record comprising service node in task list, every task note
Including at least the executive mode information and execution time information of the task in record;
Task determining module 130, for the execution time information according to task, it is determined that current pending task;
Task execution module 140, for the executive mode information according to task, performs identified pending
Business.
In a kind of specific embodiment of the application, the execution time information of task is specifically as follows:This
The next time of business performs the moment;The execution frequency information of the task is also included in task record;Correspondingly, such as Fig. 4
It is shown, can also include in timed task dispatching device:Perform time information update module 150, for
Task execution module 140 is performed after identified pending task, the execution frequency information according to task,
Execution moment next time in task record is updated.
In a kind of specific embodiment of the application, in the executive mode information of task, holding comprising task
Line parameter.
In a kind of specific embodiment of the application, in task record, the also switch mark comprising the task;
Correspondingly, task determining module 130 can be specifically for:From the task record that task identification is out, really
Settled preceding pending task.
The application also provides a kind of timed task scheduling system, and the system includes scheduling node side device and business
Node side device:
Wherein scheduling node side device sends timing according to the clocked flip task being locally configured to service node
Task triggers message, in clocked flip task, includes the mark of triggering moment information and target service node
Information;
Service node side device is identical with the foregoing timed task dispatching device for being applied to service node side, this
In explanation is not repeated.
The function of modules and the implementation process of effect specifically refer to correspondence step in the above method in said apparatus
Rapid implementation process, will not be repeated here.
As seen through the above description of the embodiments, those skilled in the art can be understood that this
Application can add the mode of required general hardware platform to realize by software.Based on such understanding, this Shen
The part that technical scheme please substantially contributes to prior art in other words can be in the form of software product
Embody, the computer software product can be stored in storage medium, such as ROM/RAM, magnetic disc,
CD etc., including some instructions are used to so that computer equipment (can be personal computer, server,
Or the network equipment etc.) perform method described in some parts of each embodiment of the application or embodiment.
Each embodiment in this specification is described by the way of progressive, identical phase between each embodiment
As part mutually referring to what each embodiment was stressed is the difference with other embodiment.
For especially for device or system embodiment, because it is substantially similar to embodiment of the method, so description
Obtain fairly simple, the relevent part can refer to the partial explaination of embodiments of method.Device described above or
System embodiment be only it is schematical, wherein it is described as separating component illustrate module can be or
Can not be it is physically separate, when application scheme is implemented can the function of each module same or
Realized in multiple softwares and/or hardware.Some or all of mould therein can also according to the actual needs be selected
Block realizes the purpose of this embodiment scheme.Those of ordinary skill in the art are not paying the feelings of creative work
Under condition, you can to understand and implement.
The above is only the specific embodiment of the application, it is noted that common for the art
For technical staff, on the premise of the application principle is not departed from, some improvements and modifications can also be made,
These improvements and modifications also should be regarded as the protection domain of the application.