CN112445598A - Task scheduling method and device based on quartz, electronic equipment and medium - Google Patents

Task scheduling method and device based on quartz, electronic equipment and medium Download PDF

Info

Publication number
CN112445598A
CN112445598A CN202011438049.7A CN202011438049A CN112445598A CN 112445598 A CN112445598 A CN 112445598A CN 202011438049 A CN202011438049 A CN 202011438049A CN 112445598 A CN112445598 A CN 112445598A
Authority
CN
China
Prior art keywords
task
list
instruction
instance
waiting
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.)
Granted
Application number
CN202011438049.7A
Other languages
Chinese (zh)
Other versions
CN112445598B (en
Inventor
郑辉煌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
CCB Finetech Co Ltd
Original Assignee
CCB Finetech Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by CCB Finetech Co Ltd filed Critical CCB Finetech Co Ltd
Priority to CN202011438049.7A priority Critical patent/CN112445598B/en
Publication of CN112445598A publication Critical patent/CN112445598A/en
Application granted granted Critical
Publication of CN112445598B publication Critical patent/CN112445598B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a task scheduling method, a task scheduling device, electronic equipment and a task scheduling medium based on quartz, wherein the method comprises the following steps: the system caches static information and dynamic information, the static information comprises task configuration information, task set information and task dependency information, the dynamic information stores task instances, and the task instances are classified into a waiting task list, an executable task list and an executing task list according to task states of the task instances; a step of dispatching a monitoring thread by a task, which is to start the monitoring thread, judge whether a waiting task list has a value, poll an instruction list, process the instruction list and process the waiting task list so as to judge whether a task instance in the waiting task list can be executed according to an execution condition; and a task execution step of starting a task execution thread when the task instance is judged to be executable.

Description

Task scheduling method and device based on quartz, electronic equipment and medium
Technical Field
The invention relates to the technical field of computers, in particular to a task scheduling method and device based on quartz, electronic equipment and a medium.
Background
Task scheduling is a function that most software systems need to use, which can help a project complete a less time-critical task in less busy time. The common work types include loading a data file given by an external system, processing the data of the business data of the day, generating a data analysis result and a visual report divided according to time periods, and providing system early warning by timing inspection. The invention mainly uses the most basic timing starting task mechanism of quartz to send out the touch task instruction.
Some task schedulers that are mainstream today have: the basic task scheduling system is a java open source tool, only a corresponding jar packet is introduced when the basic task scheduling system is used, and the basic task scheduling system is a widely used task scheduling tool, and has the principle that the basic task scheduling system is managed by two threads (one thread is responsible for task scheduling, whether a task needing to be executed starts a task or not is inquired regularly, and the other thread is responsible for managing a thread pool for the task to be executed in a thread-by-thread mode), when the basic task scheduling system is used, a task execution java class and a task schedule need to be set, and when the task reaches the specified time of the schedule, the java class can be started; and Control-M, which is commercial software developed by BMC, comprises three layers of application architectures, and is divided into a scheduling manager, a scheduling application server and a scheduling execution agent. By the aid of the three-layer architecture, task management, task scheduling and task execution are separated.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
aiming at quartz, the method is used as a basic tool, the establishment of a task dependency relationship cannot be realized, the system is interrupted and restarted, the field restoration, the task progress checking, the starting and stopping and the like cannot be realized, the system resource allocation cannot be realized, and the configuration cannot be databased.
Aiming at Control-M, the system is huge, the occupied resources are large, the configuration is complex as a mature business scheduling tool, and special software is used, so that the calling of the Java written task depends on a network request mode, and the real-time progress state query support of the task is poor. The software has high economic cost, needs specially-assigned persons for operation and maintenance when used for learning, and is not flexible enough and has poor expansibility.
Disclosure of Invention
In view of this, embodiments of the present invention provide a task scheduling method, apparatus, electronic device and medium based on quartz, which can expand quartz functions in a simple and mild manner, and implement functions required by a task scheduling system under most conditions, including task dependence, task set, on-site restoration, database-type parameter coordination, reasonable allocation of computer resources, and the like, and at the same time, the resource occupation is small, the extensibility is strong, the use is flexible, and the difficulty of the user is low, and the user can easily use the task scheduling system by only inheriting a task execution thread parent class to implement a service logic code thereof and configuring related database parameters. In addition, the technical scheme of the invention has clear logic, can obtain good user experience, has good adaptability with java and does not need multi-language mixed programming.
To achieve the above object, according to a first aspect of the embodiments of the present invention, there is provided a method for scheduling tasks based on quartz, the method including:
a system caching step, wherein the system caches static information and dynamic information, the static information comprises task configuration information, task set information and task dependency information, the dynamic information stores a task instance, and the task instance is classified into a waiting task list, an executable task list and an executing task list according to the task state of the task instance;
a step of dispatching a monitoring thread by a task, which is to start the monitoring thread, judge whether the waiting task list has a value, poll an instruction list, process the instruction list and process the waiting task list so as to judge whether a task instance in the waiting task list can be executed according to an execution condition; and
a task execution step of starting a task execution thread under the condition that the task instance can be executed, wherein the task scheduling and thread monitoring step comprises the following steps
A monitoring step, starting the monitoring thread, judging whether the waiting task list has a value or not, polling the instruction list, and waking up a system when the list has the value;
a step of processing an instruction list, wherein a task creation instruction list, a task ending instruction list and a task stopping instruction list are processed, and task instances in the task creation instruction list are added to the waiting task list, an
And processing a waiting task list, namely judging whether a task instance in the waiting task list can be executed or not according to an execution condition.
Further, when the system is started, task starting instructions generated by quartz based on the task schedule timing are added into the task creation instruction list.
Further, when the additional information of the task start instruction is 0, the task start instruction is generated by the quartz based on the task schedule timing, and
in the step of processing the instruction list, when the task creation instruction list is processed, the task instance corresponding to the task starting instruction with the additional information of 0 is directly moved to the waiting task list.
Further, a task starting instruction is generated by manually appointing task execution through a calling interface, and the task starting instruction is added into the task creating instruction list.
Further, when the additional information of the task start instruction is 1, the task start instruction is generated by manually specifying task execution through the call interface, and
in the step of processing the instruction list, when the task creation instruction list is processed, the task creation instruction list is queried to the executable task list or is synchronized from a database to obtain a task instance corresponding to the task starting instruction with the extra information of 1, and then the obtained task instance is moved to the waiting task list.
Further, in the step of processing the task end instruction list, when the task end instruction list is processed, the task state of the task instance in the task end instruction list is modified to SUCCESS or FAILURE, and the task instance is moved to the executable task list.
Further, in the step of processing the task STOP instruction list, when the task STOP instruction list is processed, the task state of the task instance in the task STOP instruction list is modified to be STOPPED or COMPLETE _ STOP, and the task instance is moved to the executable task list.
Further, when the additional information of the instruction in the task stop instruction list is 0, directly stopping the corresponding task instance and modifying the state of the task instance into STOPPED;
after a task instance in the RUNNING task state queries that a STOP flag bit STOPs, when the extra information of an instruction in the task STOP instruction list is 1, modifying the task state of the corresponding task instance to STOPPED, and when the extra information of the instruction in the task STOP instruction list is 2, modifying the task state of the corresponding task instance to COMPLETE _ STOP.
Further, in the task set information, each task set includes a parent task and a plurality of child tasks.
And further, synchronizing the task state of the parent task according to the task state of the subtask in the same task set.
Further, the task state of the task instance in the last system operation before the starting is modified, CREATED is modified into nounning, RUNNING is modified into nouccess, and the task instance is moved to the executable task list.
Further, in the task execution step, a task execution class is generated by reflection according to a task implementation java class recorded by task basic information of the task instance, the task execution class is a subclass of a task execution thread parent class, the subclass is run to add the task thread to a task execution thread List while executing the business logic, and
and the task execution thread parent class has an execution progress member variable, and queries the task execution thread List by calling an external interface so as to acquire the execution conditions of all task instances.
According to a second aspect of the embodiments of the present invention, there is provided a task scheduling apparatus based on quartz, the apparatus including:
the system cache module is used for caching static information and dynamic information, the static information comprises task configuration information, task set information and task dependency information, the dynamic information stores a task instance, and the task instance is classified into a waiting task list, an executable task list and an executing task list according to the task state of the task instance;
a task scheduling and monitoring thread module, which is used for starting a monitoring thread, judging whether the waiting task list has a value, polling an instruction list, processing the instruction list, and processing the waiting task list so as to judge whether a task instance in the waiting task list can be executed according to an execution condition; and
a task execution module, configured to start a task execution thread when it is determined that a task instance can be executed, where the task scheduling and monitoring thread module includes
The monitoring unit is used for starting the monitoring thread, judging whether the waiting task list has a value or not, polling the instruction list and awakening a system when the list has the value;
a processing instruction list unit for processing a task creation instruction list, a task end instruction list, and a task stop instruction list, and adding a task instance in the task creation instruction list to the waiting task list, and
and the processing waiting task list unit is used for judging whether the task instances in the waiting task list can be executed or not according to the execution conditions.
According to a third aspect of the present invention, there is provided an electronic apparatus comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement a method as described in the preceding first aspect.
According to a fourth aspect of the invention, there is provided a computer readable medium having stored thereon a computer program which, when executed by a processor, performs the method as described in the first aspect above.
The embodiments of the invention described above overcome the following technical problems:
task dependence cannot be realized, one task/task set does not work independently, and processing results of other tasks including data, files, signals and the like are needed. And secondly, when the task scheduling system is shut down and restarted accidentally, the task belongs to the state when the task is stopped, and the task scheduling cannot be recovered to the state before the task is stopped after the system is restarted. And thirdly, the task cannot be monitored and managed, wherein the task monitoring comprises the operation state and the operation percentage progress of checking the task. Task management includes task start, ignore dependency start, pause, resume, etc. And fourthly, scheduling the computing resources of the task execution machine, wherein the hardware resources of the computer, such as a central processing unit, a memory and the like, are limited, and the simultaneous operation of a large number of tasks cannot be ensured, so that the resource allocation management is required. And fifthly, configuring a task configuration database, wherein a plurality of current task scheduling tools need to restart the system when modifying the task configuration, and the method is troublesome. By means of the database configuration, the configuration can be modified at runtime without restarting.
Based on this, the invention achieves the following technical effects: the method can expand the quartz function in a simple and mild manner, realizes functions required by a task scheduling system under most conditions, including task dependence, task set, site restoration, database type parameter matching, reasonable distribution of computer resources and the like, and has the advantages of less resource occupation, strong expansibility, flexible use and low difficulty of hands, and a user can easily use the task scheduling system only by inheriting a task execution thread parent class to realize a service logic code and configuring related database parameters. In addition, the technical scheme of the invention has clear logic, can obtain good user experience, has good adaptability with java and does not need multi-language mixed programming.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main flow of a method for task scheduling based on quartz according to an embodiment of the present invention;
fig. 2 is a conversion diagram of the task states involved in the task scheduling method based on quartz according to the embodiment of the present invention.
FIG. 3 is a schematic diagram of the main flow of sub-steps included in a task scheduling listening thread step in a task scheduling method based on quartz according to an embodiment of the present invention;
fig. 4 is a schematic diagram of the main blocks of a quartz-based task scheduler according to an embodiment of the present invention.
Fig. 5 is a diagram illustrating a relationship between main modules of a quartz-based task scheduler according to an embodiment of the present invention.
FIG. 6 is a diagram of the main units included in the task scheduling snoop thread module of the task scheduling apparatus based on quartz according to the embodiment of the present invention.
FIG. 7 is a block diagram of a computer system suitable for use with a terminal device implementing an embodiment of the invention.
Detailed Description
First, terms to which the present invention may relate are explained.
And (3) time table: it refers to a regular time point, such as nine am every day, No. 1 monthly, etc., which is the time for the task to start automatically.
Task: the program to be executed in a specified time schedule in a computer is divided into a parent task and a child task.
Task set: refers to a set of tasks, and the tasks in the same group are often more related. Including a parent task and multiple child tasks.
And (4) parent task: the task set represents the tasks of the whole task set, is a virtual unit and does not execute actual functions.
And (3) subtasks: the task set is a unit for actually executing the task.
Task dependence: meaning that one task/task set needs to wait for another task/task set or sets to complete before execution can begin.
Task example: when the time point needing to be executed in each schedule is reached and the task dependency is satisfied, a task instance is generated, and one task generally has a plurality of task instances.
Task batch number: the execution date of the task is in the yyymmdd format, generally, the same task only needs to be executed once a day, and if multiple executions are really needed, multiple tasks can be configured.
The present invention will be described in detail below with reference to the accompanying drawings.
The task scheduling method based on the quartz comprises a system caching step, a task scheduling thread monitoring step and a task executing step.
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. 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.
A task scheduling method based on quartz according to an embodiment of the present invention will be described first with reference to fig. 1 to 3.
Fig. 1 is a schematic diagram of a main flow of a task scheduling method based on quartz according to an embodiment of the present invention. FIG. 2 is a transition diagram illustrating the states of tasks involved in a quartz-based task scheduling method of an embodiment of the present invention. Fig. 3 is a schematic diagram of the main flow of sub-steps included in the step of task scheduling listening to threads in the method for task scheduling based on quartz according to the embodiment of the present invention.
As shown in fig. 1 to 3, the task scheduling method based on quartz according to the present invention includes:
step S101, system cache step
In the system caching step, the system caches static information and dynamic information.
The static information is configured in the database, and is loaded into the system cache when the program is started, so that the system cache is convenient to search and the system operation efficiency is improved. When the task information is changed, the cache can be refreshed through the interface so as to achieve the aim of changing the configuration without restarting the system.
The static information specifically includes:
(1) task configuration information Map (key value pair) for storing basic task information, including:
task id: uniquely identifying a task;
task name: a task name;
task description: describing task functions;
dependent task id set: dividing the task id of the required preposed task by a separator '|';
the task implements java class: the method comprises the steps that a task scheduling module starts an actual function code through reflection;
task start time expression: representing a schedule using cron expressions;
parent task id: pointing to a parent task id of a task set to which the current task belongs, and if the task is the parent task, the task is empty;
task execution required parameter set: the same java class can achieve different functions by configuring different parameters.
The key of this Map is the task id.
(2) The task set Map: the task set information can be arranged through the task configuration information Map, and each task set comprises a parent task and a plurality of child tasks. The parent task does not participate in actual work and is a virtual task. The task set concept is presented to facilitate task management, and a group of tasks with closer relationship are taken as the same unit to make the system logic clearer. The function of starting and stopping a plurality of tasks in batches can be realized by starting and stopping the parent task, and the task dependence can be set on the parent task and can also be completed in batches.
(3) The task depends on Map: the task dependent information can be sorted out through the task configuration information Map, and the task dependent information is stored. The task dependence Map can inquire the preposed task and the date offset which are depended by the current task for condition judgment when the task is started. The date offset values are T, T-1 and T-2 …, T represents that the task depends on the previous task and needs to be executed on the day, T-1 represents that the task depends on the previous task and is executed on the day before the previous task, and the like. Therefore, if the task of the next day can be executed only after the same task is completed, the self-id can be added in the task dependency and the date offset is set to be T-1.
Further, in the system caching step, dynamic information is cached, the dynamic information mainly stores task instances, and each task instance comprises the following information:
example id: uniquely identifying a task instance, the same task can generate a plurality of task instances;
task id: indicating which task this instance is instantiated by;
task batch number: that is, the date yyyMMdd of the task execution is the current date of the system if the task instance is automatically generated from the date table, and is the input date if the task is manually started;
and (4) task state: indicating which phase the task is in during the task lifecycle;
the task starting type is as follows: 0 represents the first start, and 1 represents the restart;
and (3) task progress: the current task completed percentage.
Each new increment and modification of the task instance is accompanied by synchronization with the database, and the database copy of the information is an important basis for recovering the field after the system is restarted. In the dynamic information cache, three Map (key value pair) instances for classifying different task states are set, specifically as follows:
a) waiting for the task list: the list indicates that the task instance has just been created, the dependent task has not been completed or the system resources are insufficient, the task cannot be started, and the task is automatically started after the waiting condition is met. The task instance states include:
CREATED: the task instance creates a completion initial state.
b) List of executable tasks: tasks in the list are stopped for various reasons, whether conditions are met or not can not be automatically judged to be executed, and the tasks can be changed into a CREATED state to wait for starting by manually inputting a starting instruction. The task instance states include:
COMPLETE _ STOP: stopping the finished task manually;
FAILURE: a task execution failure;
nosuscess: last time (before system restart) not completed;
NORUNNING: the last time (before system restart) waiting for startup;
STOPPED: stopping the task artificially;
SUCCESS: the task was successful.
c) List of executing tasks: this list is the task instance that acquires the system execution resources. The task instance states include:
RUNNING: a task in operation.
The transition diagram of the task state described above is shown with reference to fig. 2.
In addition, according to the requirement, the task state of the last system operation before the system is started can be modified, the create of the last system operation is modified into normal (that is, waiting for starting before the system is restarted), the RUNNING of the last system operation is modified into normal (that is, not completed before the system is restarted), and the task instance is moved to the corresponding dynamic information cache (that is, the executable task list). In addition, the task instance in the CREATED/RUNNING state of the last system operation can be automatically re-run after the current startup according to the requirement, and the task instance is put into a waiting task list.
For example, if the task state of task instance 1 was CREATED during the last system outage, the task state of task instance 1 may be modified to NORUNNING during the system restart.
For another example, if the task state of task instance 2 was RUNNING during the last system outage, the task state of task instance 2 may be modified to nosucess during the system restart.
In addition, the task instance 1 and the task instance 2 can be re-run and put into the waiting task list as needed.
Step S102, task scheduling and thread monitoring step
In the step of scheduling the listening thread, starting the listening thread, judging whether the waiting task list has a value, polling an instruction list to process the instruction list and modify the task state of a task instance so as to move the task instance to the waiting task list or the executable task list, and then processing the waiting task list to judge whether the task instance in the waiting task list can be executed according to the execution condition.
Specifically, the task scheduling listening thread step S102 includes the following sub-steps:
substep S1021, a monitoring step
In the monitoring step, a monitoring thread is started, whether the dynamic cache waiting task list has a value or not and whether the three instruction lists have values or not are judged, and if the dynamic cache waiting task list does not have a value, the dynamic cache waiting task list is awakened when the dynamic cache waiting task list is updated.
Wherein the three instruction lists include:
task creation instruction list: the method is based on the quartz, and utilizes the timed task calling function of the quartz, and realizes that the quartz regularly generates a task starting instruction based on a task schedule by registering task information to the quartz when a system is started, wherein the instruction comprises a starting task id, a task batch number and additional information. The task instruction generated by Quartz will be added to the task creation instruction list with additional information of '0'. In addition, the task execution is manually specified through the calling interface, a task instruction is also generated and added into the task creation instruction list, and the additional information is '1'.
As an example, quartz generates a task start instruction s1 (including start task id, task batch number and additional information '0') at time t1 based on the task schedule, then the task start instruction s1 is added to the task creation instruction list; task start instructions s2 (including start task id, task batch number, and additional information '1') generated by manually specifying task execution at time t2 through a call interface may also be added to the task creation instruction list.
Task end instruction list: when a task ends normally or stops abnormally, an end instruction is created to add to the list.
Task stop instruction list: when the task is manually stopped by calling the interface, an end instruction is created to add to this list.
Substep S1022, instruction list processing step
The three instruction lists, namely, the task creation instruction list, the task end instruction list and the task stop instruction list are processed. The method comprises the following specific steps:
processing task creation instruction list
If an instruction is generated for quartz, the extra information is '0' for the first creation, and the newly created task instance is added to the dynamic cache waiting task list. If the additional information is '1' and is not created for the first time, the task list can be inquired to the dynamic cache to obtain a corresponding task instance, or the task instance is synchronized from the database, and then the task instance is moved to the dynamic cache waiting task list. All task instances that join the dynamic cache waiting task list need to update the status to CREATED.
Specifically, as for the task start instruction s1 added to the task creation instruction list in the above example, since it is a quartz generation instruction, it can be directly added to the dynamic cache wait task list; for the task start instruction s2 added to the task creation instruction list in the above example, since it is not created for the first time, it may query the dynamic cache executable task list to obtain the corresponding task instance, or synchronize the task instance from the database and then move it to the dynamic cache waiting task list.
Processing task end instruction list
And sending an instruction to a task ending instruction list after the task is normally completed/abnormally stopped, wherein the additional information is '1'/'0', so that a task instance is taken out, the task state is modified to SUCCESS/FAILURE, the task instance is moved to the executable task list and is removed from the task execution thread, and the task execution thread is returned to the task execution thread pool. And then, synchronizing the parent task state according to the child task state in the same task set.
Processing task stop instruction lists
The stop instruction list is divided into three types according to the content of the additional information of the instruction. When the extra information is '0', it indicates that it is a stop instruction sent by the call interface, for the CREATED, RUNNING type task instance. Wherein, for the task state in CREATED, the task is not processed actually yet, and can be STOPPED directly, and the modified task state is STOPPED. For a task in the RUNNING state, stopping its thread prematurely can result in unexpected data errors because it is already executing, and is therefore signaled to stop by setting a stop flag bit in its thread. If the stop flag bit is inquired to stop in the operation process, a stop instruction with the additional information of '1' is sent to the task stop instruction list, otherwise, a stop instruction with the additional information of '2' is sent to the task stop instruction list when the task is completed. The stop instruction list takes the task instance of the received instruction with the '1' state to modify the task state into STOPPED, and moves to the executable task list of the dynamic cache. The STOP instruction List takes the task instance of the received instruction in the '2' state, modifies the task state into COMPLETE _ STOP, moves to the dynamic cache executable task List, removes the task thread from the task execution thread List and returns the thread to the task execution thread pool. For the processed instruction, the parent task state is also synchronized according to the state of the subtask in the same task set.
Substep S1023, a process waiting task List step
In step S1023, the task service code is actually implemented to run. Firstly, judging whether the resource of the task execution thread pool is enough, then, taking out the task instance to judge whether the task instance can be executed, wherein the specific conditions are (the following is only one example for explanation):
Figure BDA0002821315830000121
Figure BDA0002821315830000131
specifically, it may be determined whether the task instances corresponding to the task start instructions s1 and s2 that have been added to the dynamic cache waiting task list can be executed by using the determination condition as described above.
Then, the step may return to step S1021, and the above steps S1021 to S1023 are repeated.
Step S103, task execution step
In the task execution step, under the condition that the task instance can be executed according to the execution condition, a task execution thread is started. Wherein, the user can inquire the execution status of the task.
The method comprises a task execution thread pool, a task execution thread parent class and actual business logic subclasses inheriting the task execution thread parent class. In step S102, the task scheduling monitors the task instances satisfying the execution condition in the thread, generates a task execution class by reflecting a task implementation java class according to the task basic information record of the task instance, where the classes are all subclasses of a task execution thread parent class, and runs the subclasses to execute the business logic and add the thread to a task execution thread List (List). For the task execution thread parent class, which has the execution progress member variable, the user can acquire the execution status of all tasks by calling the external interface to query the task execution thread List. The task execution thread parent class also contains a stop flag bit, and different tasks can add judgment to terminate the program when realizing the subclasses thereof.
Specifically, for example, if the execution condition of the task instance corresponding to the task starting instruction s1 is that the dependent task is completed, and it is determined that the execution condition has been satisfied, that is, the dependent task has been completed, the task execution thread of the task instance is started.
Therefore, according to the task scheduling method based on quartz, the structures and the contents of the static and dynamic caches required by task scheduling are defined so as to realize the parent-child task relationship and the dependent scheduling relationship. And the task records can be saved through the database, so that the required field restoration after the system is restarted is facilitated. The complete life cycle state of a completed task and the changed conditions of the completed task are defined, so that the task can be better monitored and managed, and the task scheduling is richer and more flexible. By using the form of sending instructions by quartz and monitoring the thread processing instructions by task scheduling, the problem that system resource occupation cannot be monitored and managed is solved, slow operation caused by mutual occupation of tasks is prevented, and sufficient expansion space is provided for the optimization of the subsequent task scheduling sequence. The functions that the task can be stopped when running and the task progress is visible are realized through the unified parent thread, and the scheduling management capability is improved.
Therefore, according to the task scheduling method based on the quartz, provided by the invention, the quartz function is expanded in a simple and mild manner, functions required by a task scheduling system under most conditions are realized, including task dependence, task set, site reduction, database type parameter matching, reasonable distribution of computer resources and the like, meanwhile, the resource occupation is less, the expansibility is strong, the use is flexible, the difficulty of the user is low, and the user can easily use the task scheduling system only by inheriting a task execution thread parent class to realize the service logic code and configuring related database parameters. In addition, the technical scheme of the invention has clear logic, can obtain good user experience, has good adaptability with java and does not need multi-language mixed programming.
For using Control-m, most functions of the invention can be realized, but the invention can better monitor and manage the task state through the development of native java.
The method for scheduling tasks based on the quartz according to the invention is described above, and according to the second aspect of the invention, the device for scheduling tasks based on the quartz according to the invention comprises a system cache module, a task scheduling thread monitoring module and a task execution module.
A specific embodiment of the quartz-based task scheduler will be described below with reference to fig. 4 to 6.
The module 401: system cache module
The system cache module 401 caches static information and dynamic information.
The static information is configured in the database, and is loaded into the system cache when the program is started, so that the system cache is convenient to search and the system operation efficiency is improved. When the task information is changed, the cache can be refreshed through the interface so as to achieve the aim of changing the configuration without restarting the system.
The static information specifically includes:
(1) task configuration information Map (key value pair) for storing basic task information, including:
task id: uniquely identifying a task;
task name: a task name;
task description: describing task functions;
dependent task id set: dividing the task id of the required preposed task by a separator '|';
the task implements java class: the method comprises the steps that a task scheduling module starts an actual function code through reflection;
task start time expression: representing a schedule using cron expressions;
parent task id: pointing to a parent task id of a task set to which the current task belongs, and if the task is the parent task, the task is empty;
task execution required parameter set: the same java class can achieve different functions by configuring different parameters.
The key of this Map is the task id.
(2) The task set Map: the task set information can be arranged through the task configuration information Map, and each task set comprises a parent task and a plurality of child tasks. The parent task does not participate in actual work and is a virtual task. The task set concept is presented to facilitate task management, and a group of tasks with closer relationship are taken as the same unit to make the system logic clearer. The function of starting and stopping a plurality of tasks in batches can be realized by starting and stopping the parent task, and the task dependence can be set on the parent task and can also be completed in batches.
(3) The task depends on Map: the task dependent information can be sorted out through the task configuration information Map, and the task dependent information is stored. The task dependence Map can inquire the preposed task and the date offset which are depended by the current task for condition judgment when the task is started. The date offset values are T, T-1 and T-2 …, T represents that the task depends on the previous task and needs to be executed on the day, T-1 represents that the task depends on the previous task and is executed on the day before the previous task, and the like. Therefore, if the task of the next day can be executed only after the same task is completed, the self-id can be added in the task dependency and the date offset is set to be T-1.
Further, the system cache module also caches dynamic information, the dynamic information mainly stores task instances, and each task instance comprises the following information:
example id: uniquely identifying a task instance, the same task can generate a plurality of task instances;
task id: indicating which task this instance is instantiated by;
task batch number: that is, the date yyyMMdd of the task execution is the current date of the system if the task instance is automatically generated from the date table, and is the input date if the task is manually started;
and (4) task state: indicating which phase the task is in during the task lifecycle;
the task starting type is as follows: 0 represents the first start, and 1 represents the restart;
and (3) task progress: the current task completed percentage.
Each new increment and modification of the task instance is accompanied by synchronization with the database, and the database copy of the information is an important basis for recovering the field after the system is restarted. In the dynamic information cache, three Map (key value pair) instances for classifying different task states are set, specifically as follows:
a) waiting for the task list: the list indicates that the task instance has just been created, the dependent task has not been completed or the system resources are insufficient, the task cannot be started, and the task is automatically started after the waiting condition is met. The task instance states include:
CREATED: the task instance creates a completion initial state.
b) List of executable tasks: tasks in the list are stopped for various reasons, whether conditions are met or not can not be automatically judged to be executed, and the tasks can be changed into a CREATED state to wait for starting by manually inputting a starting instruction. The task instance states include:
COMPLETE _ STOP: stopping the finished task manually;
FAILURE: a task execution failure;
nosuscess: last time (before system restart) not completed;
NORUNNING: the last time (before system restart) waiting for startup;
STOPPED: stopping the task artificially;
SUCCESS: the task was successful.
c) List of executing tasks: this list is the task instance that acquires the system execution resources. The task instance states include:
RUNNING: a task in operation.
The transition diagram of the task state described above is shown with reference to fig. 2.
In addition, according to the requirement, the task state of the last system operation before the system is started can be modified, the create of the last system operation is modified into normal (that is, the system is waiting for starting before the system is restarted), the RUNNING of the last system operation is modified into normal (that is, the system is not completed before the system is restarted), and the task instance of the last system operation is moved to the corresponding dynamic information cache (that is, the executable task list). In addition, the task instance in the CREATED/RUNNING state of the last system operation can be automatically re-run after the current startup according to the requirement, and the task instance is put into a waiting task list.
Module 402, task scheduling thread-listening Module
The task scheduling and monitoring thread module is used for starting a monitoring thread, judging whether the waiting task list has a value, polling the instruction list to process the instruction list and modify the task state of the task instance, so that the task instance is moved to the waiting task list or the executable task list, and then processing the waiting task list to judge whether the task instance in the waiting task list can be executed according to the execution condition.
Specifically, the task scheduling thread monitoring module includes the following sub-units:
unit 4021, snooping unit
And the monitoring unit starts a monitoring thread, judges whether the dynamic cache waiting task list has a value or not, judges whether the three instruction lists have values or not, and awakens when the lists are updated if the dynamic cache waiting task list does not enter a thread sleep state.
Wherein the three instruction lists include:
task creation instruction list: the method is based on the quartz, and utilizes the timed task calling function of the quartz, and realizes that the quartz regularly generates a task starting instruction based on a task schedule by registering task information to the quartz when a system is started, wherein the instruction comprises a starting task id, a task batch number and additional information. The task instruction generated by Quartz will be added to the task creation instruction list with additional information of '0'. In addition, the task execution is manually specified through the calling interface, a task instruction is also generated and added into the task creation instruction list, and the additional information is '1'.
Task end instruction list: when a task ends normally or stops abnormally, an end instruction is created to add to the list.
Task stop instruction list: when the task is manually stopped by calling the interface, an end instruction is created to add to this list.
Unit 4022, processing instruction list unit
The processing instruction list unit processes the above three instruction lists, i.e., the task creation instruction list, the task end instruction list, and the task stop instruction list. The method comprises the following specific steps:
processing task creation instruction list
If an instruction is generated for quartz, the additional information is '0' for the first time, and the processing instruction list unit 4022 adds the newly created task instance to the dynamic cache waiting task list. If the additional information is '1' and is not created for the first time, the processing instruction list unit 4022 may perform a task list query to the dynamic cache to obtain a corresponding task instance, or may perform synchronization from the database, and then move the task instance to the dynamic cache waiting task list. All task instances that join the dynamic cache waiting task list need to update the status to CREATED.
Processing task end instruction list
After the task is normally completed/abnormally stopped, an instruction is sent to a task ending instruction list, and the extra information is '1'/'0', so the processing instruction list unit 4022 takes out a task instance and modifies the task state into SUCCESS/FAILURE, moves the task instance to an executable task list, removes the task instance from a task execution thread, returns the thread to a task execution thread pool, and synchronizes the parent task state according to the sub-task state in the same task set.
Processing task stop instruction lists
The stop instruction list is divided into three types according to the content of the additional information of the instruction. When the extra information is '0', it indicates that it is a stop instruction sent by the call interface, for the CREATED, RUNNING type task instance. For the task state in CREATED, the task actually does not start to be processed, the processing instruction list unit 4022 may directly stop, and the modified task state is STOPPED. For a task in the RUNNING state, halting its thread prematurely may result in an unexpected data error since it is already in execution, so processing instruction list unit 4022 notifies it to halt by setting a halt flag bit in its thread. If the stop flag bit is inquired to stop in the operation process, a stop instruction with the additional information of '1' is sent to the task stop instruction list, otherwise, a stop instruction with the additional information of '2' is sent to the task stop instruction list when the task is completed. For a received instruction in the '1' state, the processing instruction list unit 4022 takes its task instance to modify the task state to STOPPED, and moves to the dynamic cache executable task list. For the received instruction in the '2' state, the processing instruction List unit 4022 takes its task instance to modify the task state to COMPLETE _ STOP, and moves to the dynamic cache executable task List, and removes its task thread from the task execution thread List and returns the thread to the task execution thread pool. For the processed instruction, the parent task state is also synchronized according to the state of the subtask in the same task set.
Unit 4023, process wait task list unit
And the unit for processing the dynamic cache waiting task list really realizes the running of task service codes. Firstly, processing a dynamic cache waiting task list unit to judge whether the resource of a task execution thread pool is enough, and then taking out a task instance to judge whether the task execution thread pool can be executed, wherein the specific conditions are (the following is only one example for explanation):
Figure BDA0002821315830000191
block 403, task execution Module
And the task execution module starts a task execution thread under the condition that the task instance can be executed according to the execution condition. Wherein, the user can inquire the execution status of the task.
The task execution module comprises a task execution thread pool, a task execution thread parent class and actual business logic subclasses inheriting the task execution thread parent class. And the task scheduling thread monitoring module judges the task instances meeting the conditions, generates task execution classes through reflection according to the task implementation java classes recorded by the task basic information of the task instances, wherein the classes are all subclasses of task execution thread parent classes, and runs the subclasses to execute the business logic and simultaneously add the threads into a task execution thread List (List). For the task execution thread parent class, which has the execution progress member variable, the user can acquire the execution status of all tasks by calling the external interface to query the task execution thread List. The task execution thread parent class also contains a stop flag bit, and different tasks can add judgment to terminate the program when realizing the subclasses thereof.
Therefore, according to the task scheduling device based on the quartz, which is disclosed by the invention, the structures and contents of static and dynamic caches required by task scheduling are defined so as to realize the parent-child task relationship and the dependent scheduling relationship. And the task records can be saved through the database, so that the required field restoration after the system is restarted is facilitated. The complete life cycle state of a completed task and the changed conditions of the completed task are defined, so that the task can be better monitored and managed, and the task scheduling is richer and more flexible. By using the form of sending instructions by quartz and monitoring the thread processing instructions by task scheduling, the problem that system resource occupation cannot be monitored and managed is solved, slow operation caused by mutual occupation of tasks is prevented, and sufficient expansion space is provided for the optimization of the subsequent task scheduling sequence. The functions that the task can be stopped when running and the task progress is visible are realized through the unified parent thread, and the scheduling management capability is improved.
Therefore, according to the task scheduling device based on the quartz, provided by the invention, the quartz function is expanded in a simple and mild manner, functions required by a task scheduling system under most conditions are realized, including task dependence, task set, site reduction, database type parameter matching, reasonable distribution of computer resources and the like, meanwhile, the resource occupation is less, the expansibility is strong, the use is flexible, the difficulty of the user is low, and the user can easily use the task scheduling device only by inheriting a task execution thread parent class to realize the service logic code and configuring related database parameters. In addition, the technical scheme of the invention has clear logic, can obtain good user experience, has good adaptability with java and does not need multi-language mixed programming. .
For using Control-m, most functions of the invention can be realized, but the invention can better monitor and manage the task state through the development of native java.
Referring now to FIG. 7, in accordance with another aspect of the present invention, a block diagram of a computer system 700 suitable for use with a terminal device implementing an embodiment of the present invention is shown. The terminal device shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 7, the computer system 700 includes a Central Processing Unit (CPU)701, which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM703, various programs and data necessary for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM703 are connected to each other via a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
The following components are connected to the I/O interface 705: an input portion 706 including a keyboard, a mouse, and the like; an output section 707 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 708 including a hard disk and the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. A drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read out therefrom is mounted into the storage section 708 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 709, and/or installed from the removable medium 711. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 701.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection 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, wire, fiber optic 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 the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). 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 the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules and units described in the embodiments of the present invention may be implemented by software or hardware. The described modules and units may also be provided in a processor, which may be described as: a processor comprises a system cache module, a task scheduling thread monitoring module and a task execution module. The names of these modules do not form a limitation on the modules themselves in some cases, for example, the task scheduling thread listening module may be a task scheduling module.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, implement the following:
the system cache step is S101, the system caches static information and dynamic information, the static information includes task configuration information, task set information and task dependency information, the dynamic information stores task instances, and the task instances are classified into a waiting task list, an executable task list and an executing task list according to task states of the task instances;
a task scheduling and monitoring thread step S102, starting a monitoring thread, judging whether the waiting task list has a value, polling an instruction list, processing the instruction list, and processing the waiting task list so as to judge whether a task instance in the waiting task list can be executed according to an execution condition; and
a task execution step S103, starting a task execution thread under the condition that the task instance can be executed, wherein the task scheduling thread monitoring step comprises
A monitoring step S1021, which is to start the monitoring thread, judge whether the waiting task list has a value, poll the instruction list, and wake up the system when the list has a value;
a processing instruction list step S1022 of processing a task creation instruction list, a task end instruction list and a task stop instruction list, an
The process waiting task list step S1023 determines whether the task instance in the waiting task list can be executed according to the execution condition.
For details of the above steps, reference may be made to the detailed description of the task scheduling method based on quartz, which is not described herein again.
Therefore, according to the above embodiment of the present invention, the quartz function is extended in a simple and mild manner, and functions required by the task scheduling system under most conditions, including task dependence, task collection, site restoration, database-type parameter matching, reasonable allocation of computer resources, etc., are realized. In addition, the technical scheme of the invention has clear logic, can obtain good user experience, has good adaptability with java and does not need multi-language mixed programming. .
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (15)

1. A task scheduling method based on quartz, which is characterized in that the method comprises the following steps:
a system caching step, wherein the system caches static information and dynamic information, the static information comprises task configuration information, task set information and task dependency information, the dynamic information stores a task instance, and the task instance is classified into a waiting task list, an executable task list and an executing task list according to the task state of the task instance;
a step of dispatching a monitoring thread by a task, which is to start the monitoring thread, judge whether the waiting task list has a value, poll an instruction list, process the instruction list and process the waiting task list so as to judge whether a task instance in the waiting task list can be executed according to an execution condition; and
a task execution step of starting a task execution thread under the condition that the task instance can be executed, wherein the task scheduling and monitoring thread step comprises the following steps:
a monitoring step, starting the monitoring thread, judging whether the waiting task list has a value or not, polling the instruction list, and waking up a system when the list has the value;
a step of processing an instruction list, wherein a task creation instruction list, a task ending instruction list and a task stopping instruction list are processed, and task instances in the task creation instruction list are added to the waiting task list, an
And processing a waiting task list, namely judging whether a task instance in the waiting task list can be executed or not according to an execution condition.
2. The method of claim 1, wherein,
when the system is started, task starting instructions generated by the quartz based on the task schedule are added into the task creation instruction list.
3. The method of claim 2, wherein,
when the additional information of the task starting instruction is 0, the task starting instruction is generated based on the task schedule timing, and
in the step of processing the instruction list, when the task creation instruction list is processed, the task instance corresponding to the task starting instruction with the additional information of 0 is directly moved to the waiting task list.
4. The method of claim 1, wherein,
and generating a task starting instruction by manually appointing task execution through a calling interface, and adding the task starting instruction into the task creation instruction list.
5. The method of claim 4, wherein,
when the additional information of the task starting instruction is 1, the task starting instruction is generated by manually specifying task execution through the call interface, and
in the step of processing the instruction list, when the task creation instruction list is processed, the task creation instruction list is queried to the executable task list or is synchronized from a database to obtain a task instance corresponding to the task starting instruction with the extra information of 1, and then the obtained task instance is moved to the waiting task list.
6. The method according to any one of claims 1 to 5, wherein,
in the step of processing the instruction list, when the task ending instruction list is processed, the task state of the task instance in the task ending instruction list is modified into SUCCESS or FAILURE, and the task instance is moved to the executable task list.
7. The method of claim 1, wherein,
in the step of processing the task STOP instruction list, when the task STOP instruction list is processed, the task state of the task instance in the task STOP instruction list is modified to be STOPPED or COMPLETE _ STOP, and the task instance is moved to the executable task list.
8. The method of claim 7, wherein,
when the additional information of the instruction in the task stop instruction list is 0, directly stopping the corresponding task instance and modifying the state of the task instance into STOPPED; and is
After a task instance in the RUNNING task state queries that a STOP flag bit STOPs, when the extra information of an instruction in the task STOP instruction list is 1, modifying the task state of the corresponding task instance to STOPPED, and when the extra information of the instruction in the task STOP instruction list is 2, modifying the task state of the corresponding task instance to COMPLETE _ STOP.
9. The method of claim 1, wherein,
in the task set information, each task set includes a parent task and a plurality of child tasks.
10. The method of claim 9, wherein,
and synchronizing the task state of the parent task according to the task state of the subtask under the same task set.
11. The method of claim 1, wherein,
modifying the task state of the task instance in the last system operation before the system is started, modifying CREATED into NORUNNING, modifying RUNNING into NOSUCCESS, and moving the task instance to the executable task list.
12. The method of claim 1, wherein,
in the task execution step, a task execution class is generated by reflection according to a task implementation java class recorded by task basic information of a task instance, the task execution class is a subclass of a task execution thread parent class, the subclass is run to add a task thread to a task execution thread List while executing business logic, and
and the task execution thread parent class has an execution progress member variable, and queries the task execution thread List by calling an external interface so as to acquire the execution conditions of all task instances.
13. A quartz-based task scheduling apparatus, comprising:
the system cache module is used for caching static information and dynamic information, the static information comprises task configuration information, task set information and task dependency information, the dynamic information stores a task instance, and the task instance is classified into a waiting task list, an executable task list and an executing task list according to the task state of the task instance;
a task scheduling and monitoring thread module, which is used for starting a monitoring thread, judging whether the waiting task list has a value, polling an instruction list, processing the instruction list, and processing the waiting task list so as to judge whether a task instance in the waiting task list can be executed according to an execution condition; and
a task execution module, configured to start a task execution thread when it is determined that a task instance can be executed, where the task scheduling and monitoring thread module includes:
the monitoring unit is used for starting the monitoring thread, judging whether the waiting task list has a value or not, polling the instruction list and awakening a system when the list has the value;
a processing instruction list unit for processing a task creation instruction list, a task end instruction list, and a task stop instruction list, and adding a task instance in the task creation instruction list to the waiting task list, and
and the processing waiting task list unit is used for judging whether the task instances in the waiting task list can be executed or not according to the execution conditions.
14. A quartz-based task scheduling electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-12.
15. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-12.
CN202011438049.7A 2020-12-07 2020-12-07 Task scheduling method and device based on quartz, electronic equipment and medium Active CN112445598B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011438049.7A CN112445598B (en) 2020-12-07 2020-12-07 Task scheduling method and device based on quartz, electronic equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011438049.7A CN112445598B (en) 2020-12-07 2020-12-07 Task scheduling method and device based on quartz, electronic equipment and medium

Publications (2)

Publication Number Publication Date
CN112445598A true CN112445598A (en) 2021-03-05
CN112445598B CN112445598B (en) 2022-11-01

Family

ID=74739025

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011438049.7A Active CN112445598B (en) 2020-12-07 2020-12-07 Task scheduling method and device based on quartz, electronic equipment and medium

Country Status (1)

Country Link
CN (1) CN112445598B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115623518A (en) * 2022-12-15 2023-01-17 阿里巴巴达摩院(杭州)科技有限公司 Task processing method, platform, system, device and storage medium
CN115934287A (en) * 2022-12-27 2023-04-07 无锡锡银金科信息技术有限责任公司 Timing task scheduling method under multi-service cluster of application system
CN116030398A (en) * 2023-03-31 2023-04-28 山东爱特云翔计算机有限公司 Task analysis method, system and storage medium based on multipath video signals
CN117391388A (en) * 2023-11-09 2024-01-12 北京易华录信息技术股份有限公司 Task distribution method and platform based on cloud computing

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190102222A1 (en) * 2017-09-29 2019-04-04 Oracle International Corporation Systems and methods defining thread specifications
CN109800080A (en) * 2018-12-14 2019-05-24 深圳壹账通智能科技有限公司 A kind of method for scheduling task based on Quartz frame, system and terminal device
CN109933422A (en) * 2017-12-19 2019-06-25 北京京东尚科信息技术有限公司 Method, apparatus, medium and the electronic equipment of processing task
CN110377406A (en) * 2019-06-17 2019-10-25 平安银行股份有限公司 A kind of method for scheduling task, device, storage medium and server node
CN110611707A (en) * 2019-09-05 2019-12-24 深圳前海微众银行股份有限公司 Task scheduling method and device
CN110688212A (en) * 2019-09-26 2020-01-14 山东浪潮通软信息科技有限公司 Timing management method and system based on quartz
CN111198753A (en) * 2018-11-16 2020-05-26 北京京东尚科信息技术有限公司 Task scheduling method and device
CN111782390A (en) * 2020-06-28 2020-10-16 平安普惠企业管理有限公司 Scheduling method of timing task and related equipment

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190102222A1 (en) * 2017-09-29 2019-04-04 Oracle International Corporation Systems and methods defining thread specifications
CN109933422A (en) * 2017-12-19 2019-06-25 北京京东尚科信息技术有限公司 Method, apparatus, medium and the electronic equipment of processing task
CN111198753A (en) * 2018-11-16 2020-05-26 北京京东尚科信息技术有限公司 Task scheduling method and device
CN109800080A (en) * 2018-12-14 2019-05-24 深圳壹账通智能科技有限公司 A kind of method for scheduling task based on Quartz frame, system and terminal device
CN110377406A (en) * 2019-06-17 2019-10-25 平安银行股份有限公司 A kind of method for scheduling task, device, storage medium and server node
CN110611707A (en) * 2019-09-05 2019-12-24 深圳前海微众银行股份有限公司 Task scheduling method and device
CN110688212A (en) * 2019-09-26 2020-01-14 山东浪潮通软信息科技有限公司 Timing management method and system based on quartz
CN111782390A (en) * 2020-06-28 2020-10-16 平安普惠企业管理有限公司 Scheduling method of timing task and related equipment

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115623518A (en) * 2022-12-15 2023-01-17 阿里巴巴达摩院(杭州)科技有限公司 Task processing method, platform, system, device and storage medium
CN115934287A (en) * 2022-12-27 2023-04-07 无锡锡银金科信息技术有限责任公司 Timing task scheduling method under multi-service cluster of application system
CN115934287B (en) * 2022-12-27 2023-09-12 无锡锡银金科信息技术有限责任公司 Timing task scheduling method under multi-service cluster of application system
CN116030398A (en) * 2023-03-31 2023-04-28 山东爱特云翔计算机有限公司 Task analysis method, system and storage medium based on multipath video signals
CN117391388A (en) * 2023-11-09 2024-01-12 北京易华录信息技术股份有限公司 Task distribution method and platform based on cloud computing

Also Published As

Publication number Publication date
CN112445598B (en) 2022-11-01

Similar Documents

Publication Publication Date Title
CN112445598B (en) Task scheduling method and device based on quartz, electronic equipment and medium
US10453010B2 (en) Computer device, method, and apparatus for scheduling business flow
US8185903B2 (en) Managing system resources
US7779298B2 (en) Distributed job manager recovery
US20170039239A1 (en) Distributed resource-aware task scheduling with replicated data placement in parallel database clusters
CN105719126B (en) system and method for scheduling Internet big data tasks based on life cycle model
CN112379995A (en) DAG-based unitized distributed scheduling system and method
CN109992407B (en) YARN cluster GPU resource scheduling method, device and medium
CN113569987A (en) Model training method and device
CN110019123B (en) Data migration method and device
CN112579267A (en) Decentralized big data job flow scheduling method and device
CN115373835A (en) Task resource adjusting method and device for Flink cluster and electronic equipment
CN109656692B (en) Big data task management method, device, equipment and storage medium
CN112559143A (en) Task scheduling method and system and computing device
CN115495221A (en) Data processing system and method
CN113658351B (en) Method and device for producing product, electronic equipment and storage medium
CN113204425B (en) Method, device, electronic equipment and storage medium for process management internal thread
US20080077925A1 (en) Fault Tolerant System for Execution of Parallel Jobs
CN114020506A (en) Data processing method and device, electronic equipment and storage medium
CN114237858A (en) Task scheduling method and system based on multi-cluster network
CN110990035B (en) Chain type software upgrading method based on Git
CN108958840B (en) Dynamic detection, merging and loading method for cluster configuration
CN109814991A (en) A kind of data administer in task management method and device
CN117112149B (en) Mining area mine business process communication method, device, medium and equipment
CN114780170B (en) Container resource configuration method, device, equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant