CN108829504A - A kind of method for scheduling task, device, medium and electronic equipment - Google Patents
A kind of method for scheduling task, device, medium and electronic equipment Download PDFInfo
- Publication number
- CN108829504A CN108829504A CN201810687115.0A CN201810687115A CN108829504A CN 108829504 A CN108829504 A CN 108829504A CN 201810687115 A CN201810687115 A CN 201810687115A CN 108829504 A CN108829504 A CN 108829504A
- Authority
- CN
- China
- Prior art keywords
- task
- node
- goal
- goal task
- destination node
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3003—Monitoring arrangements specially adapted to the computing system or computing system component being monitored
- G06F11/3017—Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is implementing multitasking
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/34—Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
- G06F11/3452—Performance evaluation by statistical analysis
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Software Systems (AREA)
- Quality & Reliability (AREA)
- Life Sciences & Earth Sciences (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Bioinformatics & Computational Biology (AREA)
- Evolutionary Biology (AREA)
- Probability & Statistics with Applications (AREA)
- Computer Hardware Design (AREA)
- Mathematical Physics (AREA)
- Debugging And Monitoring (AREA)
Abstract
A kind of method for scheduling task, device, medium and electronic equipment provided in an embodiment of the present invention.Applied in the Quartz cluster cached based on Redis, the Redis caches the corresponding task execution statistical information of each node in the task run information for storing each task, and storage Quartz cluster;Method includes:When monitoring that goal task needs to be implemented, the task run information of goal task is obtained from Redis caching;Judge whether goal task can be performed;If goal task is executable, from least one node of corresponding goal task, the destination node of performance objective task is determined;After monitoring destination node performance objective task, by Redis cache in correspond to the task execution statistical information of destination node and be updated.The embodiment of the present invention replaces relevant database to realize Quartz cluster using Redis caching, simplifies Quartz clustered deploy(ment).
Description
Technical field
The present invention relates to technical field of information processing more particularly to a kind of Quartz cluster realizations based on Redis caching
Method for scheduling task, device, medium and electronic equipment.
Background technique
Quartz is one completely by the open source task schedule frame of written in Java, is arranged by trigger (Trigger)
The timing operation rule of task (job), the runing time of control task.Quartz cluster passes through failover and load balance
Function can bring high availability and retractility to task dispatcher (Scheduler).
Currently, existing Quartz cluster dependence type database, needs separately installed deployment relevant database, and
Deployment is extremely complex dependent on the Quartz cluster of relevant database, and development process is veryer long, and maintenance cost is relatively high.
Therefore, how to simplify Quartz clustered deploy(ment), liberation relies on complicated relevant database, makes operation system quick
Disposing Quartz cluster becomes a technical problem of current urgent need to resolve.
Summary of the invention
In view of this, the present invention provides a kind of method for scheduling task, device, medium and electronic equipment, in generation, is cached with Redis
Quartz cluster is realized for relevant database.Technical solution is as follows:
One side based on the embodiment of the present invention, the embodiment of the present invention provide a kind of method for scheduling task, applied to being based on
In the Quartz cluster of Redis caching, the Redis caches the task run information for storing each task, and storage
The corresponding task execution statistical information of each node in the Quartz cluster, the method includes:
When monitoring that goal task needs to be implemented, the task fortune of the goal task is obtained from Redis caching
Row information;
According to the task run information of the goal task, judge whether the goal task can be performed;
If the goal task is executable, is determined from least one node of the correspondence goal task and execute institute
The destination node of goal task is stated, wherein the corresponding task execution statistical information of the destination node meets preset condition;
After monitoring that the destination node executes the goal task, the target will be corresponded in Redis caching
The task execution statistical information of node is updated.
Optionally, the task run information of the goal task includes the task status information of the goal task, foundation
The task run information of the goal task, judging that the goal task is executable includes:
When the task status information according to the goal task determines that the task status of the goal task is pending shape
When state, judge that the goal task is executable.
Optionally, the corresponding task execution statistical information of the destination node includes that the destination node executes the target
The statistical number of task, then the corresponding task execution statistical information of the destination node meets preset condition, including:
In at least one node of the correspondence goal task, the destination node executes the statistics of the goal task
Several numerical value is minimum.
Optionally, described after monitoring that the destination node executes the goal task, it will be right in Redis caching
The task execution statistical information of the destination node is answered to be updated, including:
After monitoring that the destination node executes the goal task, the target will be corresponded in Redis caching
The statistical number of the execution goal task of node adds 1.
Optionally, if in multiple nodes of the correspondence goal task, there are at least two nodes to execute the mesh
The numerical value of the statistical number of mark task is minimum, then the determining destination node for executing the goal task includes:
From the smallest at least two node of numerical value of statistical number for executing the goal task, hit by lock mode
One of node, the node of the hit is as the destination node.
Optionally, the method also includes:
When monitoring that new node is added to after the queue for executing the goal task, will be deposited in Redis caching
The corresponding task execution statistical information of each node of the execution goal task of storage is reset.
Optionally, the method also includes:
According to the renewal time of each node updates task execution statistical information, judge that each node last time is more newly appointed
Business executes whether time interval of the renewal time of statistical information apart from current time is greater than preset threshold;
If first node last time updates time of the renewal time of task execution statistical information apart from current time
Interval is greater than preset threshold, determines that the first node is abnormal, no longer distributes task for it, and the first node is corresponding
Task execution statistical information is reset;
Wherein, the first node is any one node in the Quartz cluster.
Another aspect based on the embodiment of the present invention, the embodiment of the present invention provide a kind of task scheduling apparatus, are applied to base
In the Quartz cluster of Redis caching, the Redis caches the task run information for storing each task, Yi Jicun
Store up the corresponding task execution statistical information of each node in the Quartz cluster;Described device includes:
Acquiring unit, for obtaining the target from Redis caching when monitoring that goal task needs to be implemented
The task run information of task;
Judging unit judges whether the goal task can be held for the task run information according to the goal task
Row;
Determination unit, for appointing from the correspondence target when the judging unit judges that the goal task can be performed
The destination node for executing the goal task is determined at least one node of business, wherein the corresponding task of the destination node is held
Row statistical information meets preset condition;
Updating unit will be in Redis caching for after monitoring that the destination node executes the goal task
The task execution statistical information of the corresponding destination node is updated.
It is based on the embodiment of the present invention in another aspect, the embodiment of the present invention provides a kind of storage medium, be stored thereon with journey
Sequence realizes previously described method for scheduling task when described program is executed by processor.
It is based on the embodiment of the present invention in another aspect, the embodiment of the present invention provide a kind of electronic equipment, including:Processor;
And memory, for storing the executable instruction of the processor;Wherein, the processor is configured to via executing institute above
The method for scheduling task stated.
Method for scheduling task, device, medium and electronic equipment provided in an embodiment of the present invention are applied to slow based on Redis
In the Quartz cluster deposited, the embodiment of the present invention replaces relevant database to realize Quartz cluster using Redis caching, simplifies
Quartz clustered deploy(ment) has liberated and has relied on complicated relevant database, allows operation system rapid deployment Quartz cluster, protects
It is uninterrupted to demonstrate,prove operation system function.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below
There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this
The embodiment of invention for those of ordinary skill in the art without creative efforts, can also basis
The attached drawing of offer obtains other attached drawings.
Fig. 1 is a kind of flow chart of method for scheduling task provided in an embodiment of the present invention;
Fig. 2 is the flow chart of another method for scheduling task provided in an embodiment of the present invention;
Fig. 3 is the flow chart of another method for scheduling task provided in an embodiment of the present invention;
Fig. 4 is a kind of structural schematic diagram of task scheduling apparatus provided in an embodiment of the present invention.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other
Embodiment shall fall within the protection scope of the present invention.
As shown in Figure 1, the present invention is real it illustrates a kind of flow chart of method for scheduling task provided in an embodiment of the present invention
The method for scheduling task for applying example offer is applied particularly in the Quartz cluster cached based on Redis, and the Redis caching is used for
Store the task run information of each task, and the corresponding task execution of each node in the storage Quartz cluster
Statistical information.The method includes:
Step 101, when monitoring that goal task needs to be implemented, the goal task is obtained from Redis caching
Task run information.
Task in the embodiment of the present invention includes timed task, and timed task such as periodically sending information, timing generate report
Deng.The task run information of task may include ID number, the task status information of task for identifying task, such as pending shape
State, to have executed state, execution state medium.For each task, the task can be executed by being all corresponding at least one node,
For example task A corresponding node 1 to node 10, i.e. task A can be performed in 10 nodes.
By taking specially daily early 7 points of goal task send weather forecast message to member as an example, in actual application,
Whenever reaching early 7 point moments, the sending the task from weather forecast message to member is just needed to be implemented, and just monitors that the needs are held at this time
The capable goal task that weather forecast message is sent to member, to further obtain the goal task from Redis caching
Task run information.
Step 102, according to the task run information of the goal task, judge whether the goal task can be performed.Such as
Fruit is executable, executes step 103, if not can be performed, executes step 104.
Existing Quartz cluster is when realizing task schedule, for pending goal task, corresponding all energy
The node for enough executing the goal task can all execute the primary goal task.For example, goal task B corresponding node 1, node
2, node 3 and node 4, then node 1, node 2, node 3 and node 4 can all be held when monitoring that goal task B is needed to be implemented
Goal task B of row, therefore there is task duplication execution in existing Quartz cluster.
In view of this, the embodiment of the present invention obtains the task run information of goal task, Jin Eryi from Redis caching first
According to the task run information of goal task, judge whether goal task can be performed.In the embodiment of the present invention, explanation is can be performed in task
Task was also not carried out, therefore this subtask can be performed;And task not can be performed and illustrate that task is held by other nodes
It went at least once, and in order to avoid repeating for task, therefore determined that this subtask can not execute.
Specifically, the embodiment of the present invention can judge whether goal task can be held according to the task status information of goal task
Row.It wherein, can be with when the task status information according to goal task determines that the task status of goal task is pending state
Judge that the goal task was not carried out, thereby determines that the goal task is executable;When the task status information according to goal task
Determine the task status of goal task for when having executed in state or execution state, it can be determined that the goal task had executed,
It thereby determines that and no longer executes the goal task, to guarantee goal task Exactly-once in Quartz cluster.
Step 103, determination does not execute the goal task.
In the embodiment of the present invention, when the task status information according to goal task determines that the task status of goal task is
When in execution state or execution state, it can be determined that the goal task had executed.In order to avoid same task is in Quartz collection
It is repeated in group, determination of the embodiment of the present invention no longer executes the goal task.
Step 104, from least one node of the correspondence goal task, the target for executing the goal task is determined
Node, wherein the corresponding task execution statistical information of the destination node meets preset condition.
Specifically, the embodiment of the present invention can calculate the mesh for executing the goal task using load-balancing algorithm
Node is marked, so that it is determined that running the goal task on which node.
In the embodiment of the present invention, when the task status information according to goal task determines that the task status of goal task is not
When execution state, it can be determined that the goal task is executable, and thus the embodiment of the present invention, which further determines that, executes the goal task
Destination node.Wherein the corresponding task execution statistical information of the destination node meets preset condition.
Specifically, the embodiment of the present invention obtains the task of each node corresponding with the goal task from Redis caching
Statistical information is executed, the task execution statistical information includes the statistical number that node executes the goal task, the statistical number table
The total degree that the node history executes the goal task is illustrated.The corresponding task execution statistical information of identified destination node
Meeting preset condition is specially at least one node of the correspondence goal task, and the destination node executes the target
The numerical value of the statistical number of task is minimum.
As an example it is assumed that current pending goal task is task C, the corresponding node of task C includes node 1, section
2 and node 3 are put, is stored in Redis caching statistical number 10 times that node 1 executes task C, node 2 executes the system of task C
It counts 9 times, node 3 executes statistical number 8 times of task C.The embodiment of the present invention by comparing Redis cache in the node that stores
1, the corresponding statistical number for executing task C of node 2, node 3 can determine that present node 3 executes the statistics of task C
Number is minimum, therefore the embodiment of the present invention selects and determines statistical number numerical value in the node 1, node 2 and node 3 of corresponding task C
Destination node of the smallest node 3 as execution task C.
Optionally, the embodiment of the present invention, can also be using the current load capacity of node as one when determining destination node
A reference index, for example, determining the numerical value of the statistical number of performance objective task from multiple nodes of the correspondence goal task
The minimum and/or current node maximum node of load capacity is as destination node, or, each node performance objective of comprehensive consideration
The statistical number of task and current load capacity therefrom select a destination node.
In the actual application of the embodiment of the present invention, in multiple nodes of the correspondence goal task, Ke Nengcun
It is all minimum situation in the numerical value that multiple nodes execute the statistical number of the goal task, still using aforementioned goal task as task
For the corresponding node of C, task C includes node 1, node 2 and node 3, it is assumed that storing that node 1 executes in Redis caching should
The statistical number of task C 10 times, node 2 execute statistical number 9 times of task C, and node 3 executes statistical number 9 times of task C, and
By comparing Redis cache in the corresponding statistical number for executing task C of the node 1, node 2, the node 3 that store, can be with
Determining that present node 2 and node 3 execute the statistical number of task C is all minimum value.
For this situation, the embodiment of the present invention it is further proposed that, most from the numerical value of the statistical number for executing the goal task
In at least two small nodes, one of node is hit by lock mode, the node of the hit as the destination node,
And the node of miss then continues waiting for the task execution of next round, to guarantee that goal task only carries out in Quartz cluster
Once.
Specifically, still with it is aforementioned " node 1 executes statistical number for 10 times of task C, and node 2 executes statistical number 9 times of task C,
It is illustrated for the statistical number of the execution of node 3 task C 9 times ", the embodiment of the present invention passes through lock mode from node 2 and node 3
It is middle to hit wherein any one node, it is assumed that hit node 2, then the embodiment of the present invention is by the node 2 of the hit as execution
The destination node of task C.
It step 105, will be corresponding in Redis caching after monitoring that the destination node executes the goal task
The task execution statistical information of the destination node is updated.
In the embodiment of the present invention, when monitor destination node execute the goal task after, by Redis cache in correspond to institute
The task execution statistical information for stating destination node is updated.Specifically, the embodiment of the present invention is monitoring the destination node
After executing the goal task, by Redis cache in correspond to the destination node the statistical number of the execution goal task add
1。
Still " node 1 executes statistical number for 10 times of task C, and node 2 executes statistical number 9 times of task C, and node 3 is held with aforementioned
The statistical number of row task C 9 times, for hit node 2 executes task C ", the embodiment of the present invention is monitoring the execution of node 2 task C
Afterwards, by Redis cache in corresponding node 2 execution task C statistical number 9 plus 1.
Method for scheduling task provided in an embodiment of the present invention is applied in the Quartz cluster cached based on Redis, this hair
Bright embodiment replaces relevant database to realize Quartz cluster using Redis caching, simplifies Quartz clustered deploy(ment), liberates
Complicated relevant database is relied on, allows operation system rapid deployment Quartz cluster, guarantees that operation system function is uninterrupted.
On the basis of previous embodiment, the embodiment of the invention also provides a kind of method for scheduling task, as shown in Fig. 2,
Method may include:
Step 201, monitor whether that new node is added to the queue for executing the goal task.If so, executing step
Rapid 202, otherwise continue to execute step 201.
Specifically, it by the way of the embodiment of the present invention can be monitored using real-time monitoring or periodically, monitors whether new
Node is added to the queue for executing the goal task.
Step 202, by each node corresponding of the execution goal task stored in Redis caching
Business executes statistical information and resets.
When monitoring that new node is added to when the queue for executing the goal task, the embodiment of the present invention is by Redis
The corresponding task execution statistical information of each node of the execution goal task stored in caching is reset.
It is specific that the node for executing task D includes node 1, node 2, node 3, node 4 for example, goal task is task D,
The corresponding task execution statistical information of node 1 wherein stored in Redis caching is 10 times, the corresponding task execution of node 2 system
Meter information is 11 times, the corresponding task execution statistical information of node 3 is 10 times, the corresponding task execution statistical information of node 4 is
11 times.
When there is new node 5 that the queue for extremely executing task D is added, since node 5 executes the task execution statistics of task D
Information is 0, and the execution work of follow-up work D will all focus on node 5, in order to avoid follow-up work D all focuses on section
Point 5 leads to load imbalance, the embodiment of the present invention by Redis cache in the node 1, node 2, node 3, the node 4 that store distinguish
The task execution statistical information of corresponding execution task D is all reset, to guarantee the load balancing of all nodes.
On the basis of previous embodiment, the embodiment of the invention also provides a kind of method for scheduling task, as shown in figure 3,
Method may include:
Step 301, the renewal time that first node updates task execution statistical information is obtained.
The first node is any one node in the Quartz cluster cached based on Redis.
In embodiments of the present invention, when node executes some task, just simultaneously record the node execute task when
Between namely node updates task execution statistical information renewal time, so that the embodiment of the present invention, which can pass through, obtains each section
Point updates the renewal time of task execution statistical information, knows that each node last time updates task execution statistical information more
The new time.
Step 302, according to first node update task execution statistical information renewal time, judge first node last
Whether time interval of the secondary renewal time for updating task execution statistical information apart from current time is greater than preset threshold.If big
In execution step 303, if it is not greater, can also continue to obtain next node update task execution system with return step 301
The renewal time for counting information, continue to execute the judgement whether being abnormal to next node.
Wherein preset threshold is, for example, 30 minutes, 1 hour etc., and value size can flexibly be set according to actual needs, this hair
Bright embodiment is not limited.
Step 303, it determines that the first node is abnormal, no longer distributes task for it, and the first node is corresponding
Task execution statistical information is reset.
In the embodiment of the present invention, when some node is not carried out task for a long time, exception is had occurred in the usual node, and
For the node being abnormal, task cannot be normally being executed, the node should be deleted in time.Therefore, the embodiment of the present invention
By judging whether node last time updates time interval of the renewal time of task execution statistical information apart from current time
Greater than preset threshold, to determine whether node is abnormal.By taking first node as an example, first node is appointing in Quartz cluster
Anticipate a node, when first node last time update renewal time of task execution statistical information apart from current time when
Between interval when being greater than preset threshold, determine first node exception, be no longer that it distributes task, and it is the first node is corresponding
Task execution statistical information is reset.
A kind of task is also provided based on a kind of method for scheduling task provided in an embodiment of the present invention, the embodiment of the present invention above
Dispatching device, as shown in Figure 4.The device is applied particularly in the Quartz cluster cached based on Redis, the Redis caching
For storing the task run information of each task, and the corresponding task of each node in the storage Quartz cluster
Execute statistical information;The apparatus may include:
Acquiring unit 100, described in being obtained from Redis caching when monitoring that goal task needs to be implemented
The task run information of goal task;
Judging unit 200 judges that the goal task whether may be used for the task run information according to the goal task
It executes;
Determination unit 300, for when the judging unit 200 judges that the goal task can be performed, described in correspondence
The destination node for executing the goal task is determined at least one node of goal task, wherein the destination node is corresponding
Task execution statistical information meets preset condition;
Updating unit 400, for after monitoring that the destination node executes the goal task, the Redis to be delayed
The task execution statistical information for depositing the middle correspondence destination node is updated.
Specifically in embodiments of the present invention, the task run information of the goal task may include the goal task
Task status information, the judging unit 200 are specifically used for, described in the task status information determination according to the goal task
When the task status of goal task is pending state, judge that the goal task is executable.
The corresponding task execution statistical information of the destination node may include that the destination node executes the target and appoints
The statistical number of business, then the corresponding task execution statistical information of destination node meets preset condition and can be in the embodiment of the present invention,
In at least one node of the correspondence goal task, the destination node executes the numerical value of the statistical number of the goal task
It is minimum.
In the embodiment of the present invention, updating unit 400 can be specifically used for monitoring the destination node execution mesh
After mark task, the statistical number that the execution goal task of the destination node is corresponded in Redis caching is added 1.
In the embodiment of the present invention, if there are at least two nodes to hold in multiple nodes of the correspondence goal task
The numerical value of the statistical number of the row goal task is minimum, then the determination unit 300 is specifically used for, from the execution goal task
Statistical number the smallest at least two node of numerical value in, one of node, the node of the hit are hit by lock mode
As the destination node.
Still optionally further, task scheduling apparatus provided in an embodiment of the present invention can also include:
Resetting unit will be described for when monitoring that new node is added to after the queue for executing the goal task
The corresponding task execution statistical information of each node of the execution goal task stored in Redis caching is reset;With
And
Time interval judging unit, for the renewal time according to each node updates task execution statistical information, judgement
Each node last time updates whether time interval of the renewal time of task execution statistical information apart from current time is greater than
Preset threshold;
Abnormal determination unit, for judging that first node last time more new task is held in the time interval judging unit
When time interval of the renewal time of row statistical information apart from current time is greater than preset threshold, determine that the first node is different
Often, task no longer is distributed for it.
The resetting unit is also used at this time, and the corresponding task execution statistical information of the first node is reset;Wherein,
The first node is any one node in the Quartz cluster.
The task scheduling apparatus includes processor and memory, and above-mentioned acquiring unit 100, determines list at judging unit 200
First 300 and updating unit 400 etc. store in memory as program unit, are executed by processor stored in memory
Above procedure unit realizes corresponding function.
Each functional module and above-mentioned method for scheduling task due to the task scheduling apparatus of example embodiments of the present invention
Example embodiment the step of it is corresponding, therefore for undisclosed details in apparatus of the present invention embodiment, please refer in the present invention
The embodiment for the method for scheduling task stated.
Include kernel in processor, is gone in memory to transfer corresponding program unit by kernel.Kernel can be set one
Or more, task schedule is realized by adjusting kernel parameter.
Memory may include the non-volatile memory in computer-readable medium, random access memory (RAM) and/
Or the forms such as Nonvolatile memory, if read-only memory (ROM) or flash memory (flash RAM), memory include that at least one is deposited
Store up chip.
The embodiment of the invention provides a kind of storage mediums, are stored thereon with program, real when which is executed by processor
The existing method for scheduling task.
The embodiment of the invention provides a kind of processor, the processor is for running program, wherein described program operation
Method for scheduling task described in Shi Zhihang.
The embodiment of the invention provides a kind of electronic equipment, equipment includes processor, memory and stores on a memory
And the program that can be run on a processor, processor realize following steps when executing program:
When monitoring that goal task needs to be implemented, the task fortune of the goal task is obtained from Redis caching
Row information;
According to the task run information of the goal task, judge whether the goal task can be performed;
If the goal task is executable, is determined from least one node of the correspondence goal task and execute institute
The destination node of goal task is stated, wherein the corresponding task execution statistical information of the destination node meets preset condition;
After monitoring that the destination node executes the goal task, the target will be corresponded in Redis caching
The task execution statistical information of node is updated.
Optionally, the task run information of the goal task includes the task status information of the goal task, foundation
The task run information of the goal task, judging that the goal task is executable includes:
When the task status information according to the goal task determines that the task status of the goal task is pending shape
When state, judge that the goal task is executable.
Optionally, the corresponding task execution statistical information of the destination node includes that the destination node executes the target
The statistical number of task, then the corresponding task execution statistical information of the destination node meets preset condition, including:
In at least one node of the correspondence goal task, the destination node executes the statistics of the goal task
Several numerical value is minimum.
Optionally, described after monitoring that the destination node executes the goal task, it will be right in Redis caching
The task execution statistical information of the destination node is answered to be updated, including:
After monitoring that the destination node executes the goal task, the target will be corresponded in Redis caching
The statistical number of the execution goal task of node adds 1.
Optionally, if in multiple nodes of the correspondence goal task, there are at least two nodes to execute the mesh
The numerical value of the statistical number of mark task is minimum, then the determining destination node for executing the goal task includes:
From the smallest at least two node of numerical value of statistical number for executing the goal task, hit by lock mode
One of node, the node of the hit is as the destination node.
Optionally, the method also includes:
When monitoring that new node is added to after the queue for executing the goal task, will be deposited in Redis caching
The corresponding task execution statistical information of each node of the execution goal task of storage is reset.
Optionally, the method also includes:
According to the renewal time of each node updates task execution statistical information, judge that each node last time is more newly appointed
Business executes whether time interval of the renewal time of statistical information apart from current time is greater than preset threshold;
If first node last time updates time of the renewal time of task execution statistical information apart from current time
Interval is greater than preset threshold, determines that the first node is abnormal, no longer distributes task for it, and the first node is corresponding
Task execution statistical information is reset;
Wherein, the first node is any one node in the Quartz cluster.
Equipment herein can be server, PC, PAD, mobile phone etc..
Present invention also provides a kind of computer program products, when executing on data processing equipment, are adapted for carrying out just
The program of beginningization there are as below methods step:
When monitoring that goal task needs to be implemented, the task fortune of the goal task is obtained from Redis caching
Row information;
According to the task run information of the goal task, judge whether the goal task can be performed;
If the goal task is executable, is determined from least one node of the correspondence goal task and execute institute
The destination node of goal task is stated, wherein the corresponding task execution statistical information of the destination node meets preset condition;
After monitoring that the destination node executes the goal task, the target will be corresponded in Redis caching
The task execution statistical information of node is updated.
Optionally, the task run information of the goal task includes the task status information of the goal task, foundation
The task run information of the goal task, judging that the goal task is executable includes:
When the task status information according to the goal task determines that the task status of the goal task is pending shape
When state, judge that the goal task is executable.
Optionally, the corresponding task execution statistical information of the destination node includes that the destination node executes the target
The statistical number of task, then the corresponding task execution statistical information of the destination node meets preset condition, including:
In at least one node of the correspondence goal task, the destination node executes the statistics of the goal task
Several numerical value is minimum.
Optionally, described after monitoring that the destination node executes the goal task, it will be right in Redis caching
The task execution statistical information of the destination node is answered to be updated, including:
After monitoring that the destination node executes the goal task, the target will be corresponded in Redis caching
The statistical number of the execution goal task of node adds 1.
Optionally, if in multiple nodes of the correspondence goal task, there are at least two nodes to execute the mesh
The numerical value of the statistical number of mark task is minimum, then the determining destination node for executing the goal task includes:
From the smallest at least two node of numerical value of statistical number for executing the goal task, hit by lock mode
One of node, the node of the hit is as the destination node.
Optionally, the method also includes:
When monitoring that new node is added to after the queue for executing the goal task, will be deposited in Redis caching
The corresponding task execution statistical information of each node of the execution goal task of storage is reset.
Optionally, the method also includes:
According to the renewal time of each node updates task execution statistical information, judge that each node last time is more newly appointed
Business executes whether time interval of the renewal time of statistical information apart from current time is greater than preset threshold;
If first node last time updates time of the renewal time of task execution statistical information apart from current time
Interval is greater than preset threshold, determines that the first node is abnormal, no longer distributes task for it, and the first node is corresponding
Task execution statistical information is reset;
Wherein, the first node is any one node in the Quartz cluster.
It should be understood by those skilled in the art that, the embodiment of the present invention can provide as method, system or computer program
Product.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the present invention
Apply the form of example.Moreover, it wherein includes the computer of computer usable program code that the present invention, which can be used in one or more,
The computer program implemented in usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) produces
The form of product.
The present invention be referring to according to the method for the embodiment of the present invention, the process of equipment (system) and computer program product
Figure and/or block diagram describe.It should be understood that every one stream in flowchart and/or the block diagram can be realized by computer program instructions
The combination of process and/or box in journey and/or box and flowchart and/or the block diagram.It can provide these computer programs
Instruct the processor of general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices to produce
A raw machine, so that being generated by the instruction that computer or the processor of other programmable data processing devices execute for real
The device for the function of being specified in present one or more flows of the flowchart and/or one or more blocks of the block diagram.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates,
Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or
The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting
Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or
The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one
The step of function of being specified in a box or multiple boxes.
In a typical configuration, calculating equipment includes one or more processors (CPU), input/output interface, net
Network interface and memory.
Memory may include the non-volatile memory in computer-readable medium, random access memory (RAM) and/
Or the forms such as Nonvolatile memory, such as read-only memory (ROM) or flash memory (flash RAM).Memory is computer-readable Jie
The example of matter.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology come realize information store.Information can be computer readable instructions, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase change memory (PRAM), static random access memory (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasable
Programmable read only memory (EEPROM), flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM),
Digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape magnetic disk storage or other magnetic storage devices
Or any other non-transmission medium, can be used for storage can be accessed by a computing device information.As defined in this article, it calculates
Machine readable medium does not include temporary computer readable media (transitory media), such as the data-signal and carrier wave of modulation.
It should also be noted that, the terms "include", "comprise" or its any other variant are intended to nonexcludability
It include so that the process, method, commodity or the equipment that include a series of elements not only include those elements, but also to wrap
Include other elements that are not explicitly listed, or further include for this process, method, commodity or equipment intrinsic want
Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including element
There is also other identical elements in process, method, commodity or equipment.
It will be understood by those skilled in the art that the embodiment of the present invention can provide as method, system or computer program product.
Therefore, complete hardware embodiment, complete software embodiment or embodiment combining software and hardware aspects can be used in the present invention
Form.It is deposited moreover, the present invention can be used to can be used in the computer that one or more wherein includes computer usable program code
The shape for the computer program product implemented on storage media (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.)
Formula.
The above is only the embodiment of the present invention, are not intended to restrict the invention.To those skilled in the art,
The invention may be variously modified and varied.It is all within the spirit and principles of the present invention made by any modification, equivalent replacement,
Improve etc., it should be included within scope of the presently claimed invention.
Claims (10)
1. a kind of method for scheduling task, which is characterized in that applied in the Quartz cluster cached based on Redis, the Redis
It is corresponding to cache each node in the task run information for storing each task, and the storage Quartz cluster
Task execution statistical information, the method includes:
When monitoring that goal task needs to be implemented, the task run letter of the goal task is obtained from Redis caching
Breath;
According to the task run information of the goal task, judge whether the goal task can be performed;
If the goal task is executable, is determined from least one node of the correspondence goal task and execute the mesh
The destination node of mark task, wherein the corresponding task execution statistical information of the destination node meets preset condition;
After monitoring that the destination node executes the goal task, the destination node will be corresponded in Redis caching
Task execution statistical information be updated.
2. the method according to claim 1, wherein the task run information of the goal task includes the mesh
The task status information of mark task judges the executable packet of the goal task according to the task run information of the goal task
It includes:
When the task status information according to the goal task determines that the task status of the goal task is pending state,
Judge that the goal task is executable.
3. the method according to claim 1, wherein the corresponding task execution statistical information packet of the destination node
The statistical number that the destination node executes the goal task is included, then the corresponding task execution statistical information of the destination node is full
Sufficient preset condition, including:
In at least one node of the correspondence goal task, the destination node executes the statistical number of the goal task
Numerical value is minimum.
4. according to the method described in claim 3, it is characterized in that, described monitoring the destination node execution target
After task, the task execution statistical information that the destination node is corresponded in Redis caching is updated, including:
After monitoring that the destination node executes the goal task, the destination node will be corresponded in Redis caching
The statistical number of the execution goal task add 1.
5. according to the method described in claim 3, it is characterized in that, if in multiple nodes of the correspondence goal task,
The numerical value for executing the statistical number of the goal task there are at least two nodes is minimum, then the determining execution goal task
Destination node include:
From the smallest at least two node of numerical value of statistical number for executing the goal task, wherein by lock mode hit
One node, the node of the hit is as the destination node.
6. method according to claim 1-5, which is characterized in that the method also includes:
When monitoring that new node is added to after the queue for executing the goal task, by what is stored in Redis caching
The corresponding task execution statistical information of each node for executing the goal task is reset.
7. method described in -5 according to claim 1, which is characterized in that the method also includes:
According to the renewal time of each node updates task execution statistical information, judge that each node last time more new task is held
Whether time interval of the renewal time of row statistical information apart from current time is greater than preset threshold;
If first node last time updates time interval of the renewal time of task execution statistical information apart from current time
It greater than preset threshold, determines that the first node is abnormal, is no longer that it distributes task, and by the corresponding task of the first node
Statistical information is executed to reset;
Wherein, the first node is any one node in the Quartz cluster.
8. a kind of task scheduling apparatus, which is characterized in that applied in the Quartz cluster cached based on Redis, the Redis
It is corresponding to cache each node in the task run information for storing each task, and the storage Quartz cluster
Task execution statistical information;Described device includes:
Acquiring unit, for obtaining the goal task from Redis caching when monitoring that goal task needs to be implemented
Task run information;
Judging unit judges whether the goal task can be performed for the task run information according to the goal task;
Determination unit is used for when the judging unit judges that the goal task can be performed, from the correspondence goal task
The destination node for executing the goal task is determined at least one node, wherein the corresponding task execution system of the destination node
Meter information meets preset condition;
Updating unit, for that will be corresponded in Redis caching after monitoring that the destination node executes the goal task
The task execution statistical information of the destination node is updated.
9. a kind of storage medium, which is characterized in that be stored thereon with program, realize that right is wanted when described program is executed by processor
Method for scheduling task described in asking any one of 1 to 7.
10. a kind of electronic equipment, which is characterized in that including:
Processor;And
Memory, for storing the executable instruction of the processor;
Wherein, the processor is configured to come described in any one of perform claim requirement 1 to 7 via the execution executable instruction
Method for scheduling task.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810687115.0A CN108829504A (en) | 2018-06-28 | 2018-06-28 | A kind of method for scheduling task, device, medium and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810687115.0A CN108829504A (en) | 2018-06-28 | 2018-06-28 | A kind of method for scheduling task, device, medium and electronic equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108829504A true CN108829504A (en) | 2018-11-16 |
Family
ID=64133479
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810687115.0A Pending CN108829504A (en) | 2018-06-28 | 2018-06-28 | A kind of method for scheduling task, device, medium and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108829504A (en) |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111309456A (en) * | 2018-12-12 | 2020-06-19 | 深圳市茁壮网络股份有限公司 | Task execution method and system |
CN111324436A (en) * | 2020-02-17 | 2020-06-23 | 山东有人信息技术有限公司 | Quartz-based Redis implementation method and system |
CN111581449A (en) * | 2020-05-18 | 2020-08-25 | 网易(杭州)网络有限公司 | Task node execution method and device, computer equipment and medium |
WO2020224218A1 (en) * | 2019-05-08 | 2020-11-12 | 平安科技(深圳)有限公司 | Hbase-based data writing method, system, device, and readable storage medium |
CN112130931A (en) * | 2020-09-27 | 2020-12-25 | 联想(北京)有限公司 | Application deployment method, node, system and storage medium |
WO2021000758A1 (en) * | 2019-07-04 | 2021-01-07 | 中国建设银行股份有限公司 | Robotic resource task cycle management and control method and apparatus |
CN112965796A (en) * | 2021-03-01 | 2021-06-15 | 亿企赢网络科技有限公司 | Task scheduling system, method and device |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102073546A (en) * | 2010-12-13 | 2011-05-25 | 北京航空航天大学 | Task-dynamic dispatching method under distributed computation mode in cloud computing environment |
CN106201694A (en) * | 2016-07-13 | 2016-12-07 | 北京农信互联科技有限公司 | Configuration method and system for executing timing task under distributed system |
CN106484530A (en) * | 2016-09-05 | 2017-03-08 | 努比亚技术有限公司 | A kind of distributed task dispatching O&M monitoring system and method |
CN107894919A (en) * | 2017-11-30 | 2018-04-10 | 中国平安财产保险股份有限公司 | Timed task triggering method, device, equipment and readable storage medium storing program for executing |
CN108182108A (en) * | 2017-12-19 | 2018-06-19 | 山东浪潮商用系统有限公司 | A kind of timed task cluster and its execution method |
-
2018
- 2018-06-28 CN CN201810687115.0A patent/CN108829504A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102073546A (en) * | 2010-12-13 | 2011-05-25 | 北京航空航天大学 | Task-dynamic dispatching method under distributed computation mode in cloud computing environment |
CN106201694A (en) * | 2016-07-13 | 2016-12-07 | 北京农信互联科技有限公司 | Configuration method and system for executing timing task under distributed system |
CN106484530A (en) * | 2016-09-05 | 2017-03-08 | 努比亚技术有限公司 | A kind of distributed task dispatching O&M monitoring system and method |
CN107894919A (en) * | 2017-11-30 | 2018-04-10 | 中国平安财产保险股份有限公司 | Timed task triggering method, device, equipment and readable storage medium storing program for executing |
CN108182108A (en) * | 2017-12-19 | 2018-06-19 | 山东浪潮商用系统有限公司 | A kind of timed task cluster and its execution method |
Non-Patent Citations (3)
Title |
---|
MODRED: "基于redis的分布式quartz定时任务", 《HTTPS://BLOG.CSDN.NET/QQ_37175369/ARTICLE/DETAILS/79486038》 * |
WEIXIN_34162695: "基于redis的分布式任务管理", 《HTTPS://BLOG.CSDN.NET/WEIXIN_34162695/ARTICLE/DETAILS/88908814》 * |
秦三行: "使用redis 作为注册中心实现quartz分布式服务", 《HTTPS://ZHUANLAN.ZHIHU.COM/P/28645660》 * |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111309456A (en) * | 2018-12-12 | 2020-06-19 | 深圳市茁壮网络股份有限公司 | Task execution method and system |
WO2020224218A1 (en) * | 2019-05-08 | 2020-11-12 | 平安科技(深圳)有限公司 | Hbase-based data writing method, system, device, and readable storage medium |
WO2021000758A1 (en) * | 2019-07-04 | 2021-01-07 | 中国建设银行股份有限公司 | Robotic resource task cycle management and control method and apparatus |
CN111324436A (en) * | 2020-02-17 | 2020-06-23 | 山东有人信息技术有限公司 | Quartz-based Redis implementation method and system |
CN111581449A (en) * | 2020-05-18 | 2020-08-25 | 网易(杭州)网络有限公司 | Task node execution method and device, computer equipment and medium |
CN111581449B (en) * | 2020-05-18 | 2023-04-28 | 网易(杭州)网络有限公司 | Task node execution method and device, computer equipment and medium |
CN112130931A (en) * | 2020-09-27 | 2020-12-25 | 联想(北京)有限公司 | Application deployment method, node, system and storage medium |
CN112965796A (en) * | 2021-03-01 | 2021-06-15 | 亿企赢网络科技有限公司 | Task scheduling system, method and device |
CN112965796B (en) * | 2021-03-01 | 2024-04-09 | 亿企赢网络科技有限公司 | Task scheduling system, method and device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108829504A (en) | A kind of method for scheduling task, device, medium and electronic equipment | |
US10693740B2 (en) | Data transformation of performance statistics and ticket information for network devices for use in machine learning models | |
Bhattacharjee et al. | Barista: Efficient and scalable serverless serving system for deep learning prediction services | |
US11005969B2 (en) | Problem solving in a message queuing system in a computer network | |
US11748154B2 (en) | Computing node job assignment using multiple schedulers | |
EP3133492B1 (en) | Network service incident prediction | |
US20190319881A1 (en) | Traffic management based on past traffic arrival patterns | |
US20180349202A1 (en) | Virtual Network Function Resource Allocation | |
Lv et al. | Microservice deployment in edge computing based on deep Q learning | |
US20150286507A1 (en) | Method, node and computer program for enabling automatic adaptation of resource units | |
US9965262B2 (en) | Application bundle pulling | |
US10389850B2 (en) | Managing redundancy among application bundles | |
US20210105228A1 (en) | Intelligent cloud platform to host resource efficient edge network function | |
CN108733509A (en) | Method and system for data to be backed up and restored in group system | |
JP7079998B1 (en) | Cluster capacity expansion method and equipment | |
US11212173B2 (en) | Model-driven technique for virtual network function rehoming for service chains | |
CN111338913A (en) | Analyzing device-related data to generate and/or suppress device-related alerts | |
US11310125B2 (en) | AI-enabled adaptive TCA thresholding for SLA assurance | |
WO2023207689A1 (en) | Change risk assessment method and apparatus, and storage medium | |
Dieye et al. | On achieving high data availability in heterogeneous cloud storage systems | |
CN109684381A (en) | Data hot statistics method and device | |
CN113608880A (en) | Algorithm model deployment system | |
CN113711250A (en) | Apparatus, program, and method for resource control | |
Dharmapriya et al. | Smart platform for cloud service providers | |
Montes et al. | Using global behavior modeling to improve qos in cloud data storage services |
Legal Events
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: 20181116 |