CN113010276A - Task scheduling method and device, terminal equipment and storage medium - Google Patents

Task scheduling method and device, terminal equipment and storage medium Download PDF

Info

Publication number
CN113010276A
CN113010276A CN202010528315.9A CN202010528315A CN113010276A CN 113010276 A CN113010276 A CN 113010276A CN 202010528315 A CN202010528315 A CN 202010528315A CN 113010276 A CN113010276 A CN 113010276A
Authority
CN
China
Prior art keywords
task
subtask
executed
subtasks
execution
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
Application number
CN202010528315.9A
Other languages
Chinese (zh)
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.)
Shenzhen Kemai Technology Co ltd
Original Assignee
Shenzhen Kemai Technology 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 Shenzhen Kemai Technology Co ltd filed Critical Shenzhen Kemai Technology Co ltd
Priority to CN202010528315.9A priority Critical patent/CN113010276A/en
Publication of CN113010276A publication Critical patent/CN113010276A/en
Pending legal-status Critical Current

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
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The application is applicable to the technical field of task scheduling, and provides a task scheduling method, a task scheduling device, terminal equipment and a storage medium. In the embodiment of the application, a subtask to be executed currently is selected from preset compound tasks; if the subtask has a dependent external task, acquiring the execution condition of the external task; if the subtask has a precursor task, acquiring the execution condition of the precursor task; if the execution condition of the external task and the execution condition of the precursor task are both completed, executing the subtask; when the execution of the subtasks is completed, if the unexecuted subtasks still exist in the compound task, the current subtasks to be executed are selected again from the unexecuted subtasks until all the subtasks in the compound task are executed, and therefore the service problem with a complex topological relation is solved.

Description

Task scheduling method and device, terminal equipment and storage medium
Technical Field
The present application belongs to the technical field of task scheduling, and in particular, to a task scheduling method, apparatus, terminal device, and storage medium.
Background
With the development of society, there are various businesses in any kind of enterprise, and these businesses can use task scheduling to achieve unified management and execution. However, with the expansion of services and the accumulation of various service functions, the requirement of users on task processing is higher and higher, while the traditional task scheduling can only process a single linear connection simple task and cannot process services with a complex topological relation, which results in poor user experience of users.
Disclosure of Invention
The embodiment of the application provides a task scheduling method, a task scheduling device, a terminal device and a storage medium, and can solve the problem of how to process a service with a complex topological relation.
In a first aspect, an embodiment of the present application provides a task scheduling method, including:
selecting a current subtask to be executed from preset compound tasks;
if the subtask has a dependent external task, acquiring the execution condition of the external task;
if the subtask has a precursor task, acquiring the execution condition of the precursor task;
if the execution condition of the external task and the execution condition of the precursor task are both completed, executing the subtask;
when the execution of the subtasks is completed, if the subtasks which are not executed yet exist in the composite task, the subtasks to be executed currently are selected again from the subtasks which are not executed yet until all the subtasks in the composite task are executed completely.
Optionally, after the sub-tasks are executed, the method includes:
if the subtask fails to be executed, acquiring a preset attribute of the subtask, and determining whether to execute the subtask again according to the preset attribute;
if the execution time of the subtask exceeds a preset time threshold, determining whether to execute the subtask again according to the preset attribute;
and if the times of re-execution operation exceed the preset times of re-execution, determining whether to ignore the abnormal operation of the subtask according to the preset attribute.
Optionally, the task scheduling method includes:
if a skip instruction is received, skipping to execute the subtasks when the subtasks are executed according to the skip instruction;
if an inserting instruction is received, inserting a preset execution cycle in the execution process of the subtask according to the inserting instruction;
and if a deleting instruction is received, deleting a preset execution period in the execution process of the subtask according to the deleting instruction.
Optionally, the task scheduling method includes:
and if the working time of the composite task is longer than a preset time threshold, finishing the work of the composite task after the execution of the currently executed subtask in the composite task is finished.
Optionally, the process of creating the compound task includes:
acquiring compound task information, and creating the compound task according to the compound task information;
and importing a preset task template into the composite task to generate each subtask, and performing topological arrangement on the subtasks.
Optionally, before importing a preset task template into the composite task and generating each subtask, the method includes:
acquiring interface information, and creating a task import interface according to the interface information;
verifying the import interface, and acquiring task template information when the verification is passed;
and generating the task template by importing the verified task into an interface according to the task template information.
Optionally, before performing the topological arrangement on the subtasks, the method includes:
when a dragging instruction is received, loading a preset task type to a preset position in the composite task;
and acquiring task information, and generating a subtask according to the task type according to the task information.
In a second aspect, an embodiment of the present application provides a task scheduling apparatus, including:
the selection module is used for selecting a current subtask to be executed from a preset composite task;
the external task module is used for acquiring the execution condition of the external task if the subtask has a dependent external task;
the precursor task module is used for acquiring the execution condition of the precursor task if the subtask has the precursor task;
the execution module is used for executing the subtasks if the execution condition of the external task and the execution condition of the precursor task are both completed;
and the completion module is used for reselecting the current subtask to be executed from the unexecuted subtasks until all subtasks in the compound task are executed and completed if the unexecuted subtasks exist in the compound task when the execution of the subtasks is completed.
In a third aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, a scheduler, an executor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of any one of the task scheduling methods when executing the computer program.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the computer program implements the steps of any one of the task scheduling methods described above.
In a fifth aspect, an embodiment of the present application provides a computer program product, which, when running on a terminal device, causes the terminal device to execute any one of the task scheduling methods in the first aspect.
In the embodiment of the application, a subtask to be executed currently is selected from preset compound tasks; if the subtask has a dependent external task, acquiring the execution condition of the external task; if the subtask has a precursor task, acquiring the execution condition of the precursor task; if the execution condition of the external task and the execution condition of the precursor task are both completed, executing the subtask; when the execution of the subtasks is completed, if the subtasks which are not executed yet exist in the composite task, the subtasks to be executed currently are selected again from the subtasks which are not executed yet until all the subtasks in the composite task are executed completely. According to the method and the device, the subtasks to be executed are selected from the preset compound tasks, whether the subtasks are executed when the current subtasks have the external tasks or the precursor tasks is detected, the fact that the subtasks are executed when the external tasks and the precursor tasks are not executed is avoided, the execution result is deviated, when the external tasks and the precursor tasks are executed completely, the current subtasks are executed again, whether the subtasks still exist in the compound tasks or not is judged after the current subtasks are executed completely, the subtasks to be executed are selected from the subtasks not executed again until all the subtasks in the compound tasks are executed completely, and therefore the service problem with complex topological relation is solved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a first flowchart illustrating a task scheduling method according to an embodiment of the present application;
fig. 2 is a second flowchart of a task scheduling method according to an embodiment of the present application;
fig. 3 is a third flowchart illustrating a task scheduling method according to an embodiment of the present application;
fig. 4 is a fourth flowchart illustrating a task scheduling method according to an embodiment of the present application;
fig. 5 is a fifth flowchart illustrating a task scheduling method according to an embodiment of the present application;
fig. 6 is a sixth flowchart illustrating a task scheduling method according to an embodiment of the present application;
fig. 7 is a seventh flowchart illustrating a task scheduling method according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a task scheduling apparatus according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of a terminal device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to" determining "or" in response to detecting ". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
Furthermore, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used for distinguishing between descriptions and not necessarily for describing or implying relative importance.
Fig. 1 is a schematic flowchart of a task scheduling method in an embodiment of the present application, and as shown in fig. 1, the task scheduling method may include the following steps:
and S101, selecting a currently to-be-executed subtask from preset compound tasks.
In this embodiment, a subtask to be executed is selected from a pre-created compound task. The subtasks to be executed can be selected according to the topological order, and the selected subtasks are further prompted to execute the relevant operation.
Optionally, the selecting manner may be that the subtasks in the composite task are selected in the order of topological arrangement.
It can be understood that, when a pre-created compound task is commanded to work, each sub-task is started to be executed in a certain order from a start node of the compound task, as shown in fig. 2, because the external condition of each sub-task is different, that is, the precondition for satisfying the execution of the sub-task is different, the actual execution time of each sub-task is determined according to the external condition, so that the selected sub-task does not meet the execution condition, and the re-selection occurs.
And S102, if the subtasks have dependent external tasks, acquiring the execution condition of the external tasks.
In this embodiment, after selecting the currently to-be-executed subtask, the external condition of the currently to-be-executed subtask is detected, and if it is detected that the currently to-be-executed subtask has an external task whose task depends on the currently to-be-executed subtask, the execution condition of the dependent external task is obtained, and whether to execute the currently to-be-executed subtask is determined according to the execution condition of the external task. The external task with dependency refers to an external task that is task-dependent on a sub-task to be executed currently, that is, the sub-task to be executed currently depends on the execution condition of some external task to perform its own task execution, where the external task is a task independent from the other composite task, and may be a sub-task in another composite task or a simple task that is executed separately, as shown in fig. 2, and the sub-task 3 in fig. 2 has an external task.
Alternatively, each sub-task in the composite task may rely on one or more external tasks, and the external tasks on which they depend are low frequency relative to the sub-tasks. The low frequency means that the frequency cycle of task execution is less than that of the subtasks. For example, if the execution frequency period of the current sub-task is executed every minute, the external task dependent on the current sub-task is lower than the execution frequency period of the sub-task, for example, every hour. When the external tasks which depend on the subtasks exist, the subtasks can be executed only if the external tasks in the current period are successfully executed. In general, the subtasks are based on the last execution of the external task during the current time period.
Optionally, if the external task that depends on the subtask is not executed, the subtask is not executed until the task that depends on the subtask is successfully executed, and the subtask is executed again. It can be understood that, if there are other external conditions in the above subtask, the subtask is executed again according to the conditions that the other external conditions and the external task are both satisfied.
By way of specific example and not limitation, the factor task is high-frequency relative to the external task that the factor task depends on, so that the sub-tasks are set to be executed once at 8 am and 5 pm each day, and the external task that the factor task depends on with the sub-tasks is executed at 11 am each day, so that when the sub-task that is executed at 8 am is ready to be executed, the external task that the factor task depends on is detected to exist, and the external task is not started to be executed, the current sub-task is not executed until the external task is detected to be executed at 11 am, the sub-task is executed according to the execution condition of the external task at 11 am, and when the sub-task that is executed at 5 pm is ready to be executed, the sub-task is executed according to the last execution condition of the external task, namely the execution condition of the external task that is executed at 11 am.
And step S103, if the subtask has a precursor task, acquiring the execution condition of the precursor task.
In this embodiment, after selecting a currently to-be-executed subtask, an external condition of the currently to-be-executed subtask is detected, and if it is detected that the currently to-be-executed subtask has a predecessor task, an execution condition of the predecessor task is obtained, and whether to execute the currently to-be-executed subtask is determined according to the execution condition of the predecessor task. The predecessor task is a task which is connected with a current subtask to be executed after each subtask is topologically arranged in the composite task, is sequenced before the current subtask to be executed, and can be executed after the current drive task is executed.
Optionally, there may be one or more predecessor tasks for each sub-task in the composite task. If the above sub-task has two predecessor tasks, as shown in fig. 2, the sub-task 4 in fig. 2 has two predecessor tasks, which are the sub-task 1 and the sub-task 2, and then the sub-task 4 can be executed only when the sub-task 1 and the sub-task 2 are executed. It is understood that if there are other external conditions in the subtask, the subtask is executed again according to the condition that the other external conditions and the predecessor task are both satisfied.
Specifically, for example, but not by way of limitation, after the current driving task B is executed, the subsequent driving subtask a is selected as the subtask to be executed currently, and the subtask a further comprises another precursor task C, at this time, two precursor tasks of the subtask a are respectively the precursor task B and the precursor task C, the precursor task B is executed, at this time, the execution condition of the precursor task C needs to be detected, and whether the subtask a is executed or not is determined according to the execution condition of the precursor task C. The post-driving task is a task which is connected with the current subtask to be executed after each subtask is topologically arranged in the composite task and is sequenced after the current subtask to be executed, and the post-driving task can be selected as the next subtask to be executed according to the topological order after the current subtask to be executed is executed.
And step S104, if the execution condition of the external task and the execution condition of the precursor task are both completed, executing the subtask.
In this embodiment, when it is detected that the execution of both the external task and the predecessor task of the currently to-be-executed subtask is completed, the currently to-be-executed subtask is executed.
Optionally, if the current sub-task to be executed only has no predecessor task from the external task, the current sub-task to be executed is executed under the condition that the execution of the external task is completed; if the current subtask to be executed only has the predecessor task without an external task, the current subtask to be executed is executed under the condition that the predecessor task is executed; if the number of the subtasks to be executed currently is two or more than two, the subtasks to be executed currently are executed under the condition that the execution of the two or more than two predecessor tasks and the external tasks is completed.
Step S105, when the execution of the subtasks is completed, if the subtasks which are not executed yet exist in the composite task, the subtasks to be executed currently are selected again from the subtasks which are not executed yet until all the subtasks in the composite task are executed completely.
In this embodiment, after the selected currently to-be-executed subtasks are executed, if it is detected that there are any more unexecuted subtasks in the composite task, the subtasks are re-selected from the unexecuted subtasks as the currently to-be-executed subtasks until it is detected that all the subtasks in the composite task are executed completely. If the external environment of the back-drive task does not meet the execution condition after the steps, that is, the back-drive task has another front-drive task and the other front-drive task does not start to be executed, or the back-drive task has another external task and the external tasks do not start to be executed, and the like, another back-drive task is reselected according to the sequence of the topological arrangement.
It can be understood that the compound task may form a directed acyclic graph, that is, each sub task in the compound task may be arranged in a complex topology, as shown in fig. 2, and the compound task is executed only after each sub task is executed according to the topology.
Optionally, if none of the sub-tasks that have not been executed in the compound task meet the execution condition after undergoing the above steps, waiting is performed until the execution condition of a certain sub-task is detected to be met, and then the sub-task is executed.
Optionally, as shown in fig. 3, after step S104, the method includes:
step S301, if the execution of the subtask fails, acquiring a preset attribute of the subtask, and determining whether to execute the subtask again according to the preset attribute.
In this embodiment, in the process of creating a subtask in a compound task, task information of the task is obtained, and attribute values of respective parameters of the subtask are preset according to the task information, for example, whether to re-execute the failed subtask after the subtask fails to be executed, the number of times to re-execute the subtask, and the like. And through setting the attribute values of the subtasks, if the current subtask fails to be executed, determining whether to execute the failed subtask again according to the preset attribute values of the parameters.
By way of specific example and not limitation, if the execution of the preset subtask fails, the subtask is re-executed, and after the current subtask fails to be executed, the failed subtask is re-executed according to the preset attribute.
Optionally, if the execution of the subtask fails, an alarm may be performed to remind the user, and the log query module may mark the failed subtask in the composite task in red, so that the user may find a problem immediately, and thus perform real-time control.
Step S302 determines whether to re-execute the subtask according to the preset attribute if the execution time of the subtask exceeds a preset time threshold.
In this embodiment, in the process of creating a sub-task in a compound task, task information of the task is acquired, and attribute values of various parameters of the sub-task are preset according to the task information, for example, whether to re-execute an overtime sub-task after the execution time of the sub-task exceeds a preset time threshold, the number of times to re-execute the sub-task, and the like. And through setting the attribute values of the subtasks, if the current execution time of the subtasks exceeds a preset time threshold, determining whether to execute the overtime subtasks again according to the attribute values of the preset parameters.
By way of specific example and not limitation, if the execution time of the preset subtask exceeds a preset time threshold, the subtask is re-executed, and after the execution time of the current subtask exceeds the preset time threshold, the failed subtask is re-executed according to the preset attribute.
Optionally, different time thresholds are determined according to different execution conditions of each subtask, where a time threshold refers to a preset execution time of the subtask, generally, the time threshold is set to be a larger amount of time relative to a normal execution time of the subtask, and the larger amount of time is a timeout time agreed by a user.
Optionally, the subtasks may be divided into two execution modes, one is synchronous execution and the other is asynchronous execution. The response speed of the synchronously executed subtasks is high, the execution and the response are generally close to synchronous, and the set time threshold is smaller; the sub-tasks executed asynchronously are slow in response speed, and the difference between the normal execution time and the response time may be several hours, and the time threshold is set to be large.
Optionally, if the execution time of the subtask exceeds the preset time threshold, an alarm may be performed, and the user may change the parameter in real time according to the related prompt, for example, change the time threshold, force the success, and the like. So that the subtask execution succeeds.
Step S303, if the times of the re-execution operation exceed the preset re-execution times, determining whether to ignore the abnormal operation of the subtask according to the preset attribute.
In this embodiment, when the subtask performs the re-execution operation, if an exception such as failure or timeout occurs after the number of times of re-execution operation of the subtask exceeds the preset number of times of re-execution, it is determined whether to ignore the exception operation of the subtask according to the attribute values of the respective parameters of the preset subtask, that is, whether to automatically ignore the exception operation when the number of times of re-execution operation of the subtask exceeds the preset number of times of re-execution. If the abnormal operation of the subtask is ignored, the subtask is successfully executed, and the subsequent judgment is continued, and the process is shown in fig. 4.
By way of specific example and not limitation, if the number of times of re-execution operation of the preset subtask exceeds the preset number of times of re-execution, the abnormal operation of the subtask is automatically ignored, and after the number of times of re-execution operation of the current subtask exceeds the preset number of times of re-execution, the abnormal operation of the subtask is automatically ignored according to the preset attribute.
Optionally, if a skip instruction is received, the sub-task is skipped when the sub-task is executed according to the skip instruction.
In this embodiment, if a user can control a task in real time during the working process of a composite task, for example, a skip instruction of a sub-task is issued, and if the task scheduling center receives a skip instruction of a certain sub-task, that is, the sub-task is no longer executed, the task scheduling center skips when the sub-task is executed, and executes the next sub-task. The skip instruction includes related information of the subtask, that is, information identifying the subtask.
Optionally, if an insertion instruction is received, a preset execution cycle is inserted in the execution process of the subtask according to the insertion instruction.
In this embodiment, if an insertion instruction of a certain sub-task is received during the working process of the composite task, the number of the preset execution cycles included in the insertion instruction is analyzed, and the execution cycles included in the insertion instruction are inserted into the execution process of the sub-task according to the insertion instruction, so that the sub-task can execute the execution cycles included in the insertion instruction. That is, a preset execution cycle of the subtask is inserted based on the original execution cycle of the subtask, and according to the insertion instruction, the subtask executes a preset specific cycle included in the insertion instruction in addition to the original preset cycle according to the preset execution cycle included in the insertion instruction during the execution process, thereby increasing the execution frequency of the subtask. The inserting instruction is used for inserting a specific cycle in the execution process of the task; the preset execution cycle refers to the execution frequency of the cycle inserted halfway, and is, for example, executed once at 8 am on monday every week.
Optionally, the insertion instruction may also be applied to a compound task, and each subtask in the compound task may be comprehensively regulated and controlled. For example, the fixed execution period of the compound task is run once every month end at 5 pm, and on the basis, an insertion instruction including run once every saturday at 9 am is sent to the task scheduling center, so that the task scheduling center uses its internal executor to run once every saturday at 9 am in addition to running once every month end at 5 pm, thereby driving its internal subtasks to run.
Optionally, if a delete instruction is received, deleting a preset execution cycle in the execution process of the subtask according to the delete instruction.
In this embodiment, in the working process of the composite task, if a delete instruction of a certain sub-task is received, how many preset execution cycles are included in the delete instruction is analyzed, the execution cycles included in the delete instruction are inserted into the execution process of the sub-task according to the delete instruction, and when the execution time of the sub-task in the execution process meets the execution cycle marked by the delete instruction, the sub-task in this time period is not executed. According to the deleting instruction, when the subtask executes the original preset period, if the current execution period is detected to accord with the preset specific period contained in the deleting instruction, the current period is not executed, so that the subtask is controlled better, and the efficiency is improved. The deleting instruction refers to deleting a specific cycle in the execution process of the task.
Optionally, the delete instruction may also be applied to the compound task, and may comprehensively regulate and control each subtask in the compound task. For example, the fixed execution period of the compound task is once executed at 5 pm at the end of each month, and on the basis that the compound task is not executed in 5 months because of special activities in 5 months, a delete instruction including once execution at 5 pm at the end of 5 months can be sent to the task scheduling center, and the task scheduling center does not execute the compound task at 5 pm at the end of 5 months by using its internal executor, so that its internal subtasks are not executed.
Optionally, if the working time of the compound task is greater than a preset time threshold, the work of the compound task is finished after the currently executed subtask in the compound task is executed.
In this embodiment, since the compound task comprehensively regulates each sub-task therein, the working time, that is, the preset time threshold, is set in the compound task in advance, and if the working duration of the compound task is longer than the preset time threshold when the compound task works, that is, the current compound task does not complete the work within the specified time and is overtime, after the currently executed sub-task of the compound task is completed, the next unexecuted sub-task is no longer selected again, and the work of the compound task is finished, so as to prevent the situation from occurring due to the overlong working time of the compound task. The time threshold is determined according to the normal working time of the compound task, the general time threshold is set to be more than the normal execution time of the compound task, and the more time is the overtime time approved by the user.
Optionally, after the work of the overtime composite task is ended due to the fact that the working time of the composite task is longer than the preset time threshold, the overtime composite task may be re-run after a part of parameters are changed according to the running result, for example, the overtime time is changed; or selecting to continue to start from the executed subtasks in the compound task, and selecting the next unexecuted subtask to continue to run.
Optionally, the process of creating the compound task includes:
and acquiring compound task information, and creating the compound task according to the compound task information.
In this embodiment, the compound task information is acquired according to a creation instruction for creating a compound task issued by a user, and a compound task is created according to the acquired compound task information. The compound task information refers to attribute information required for creating a compound task, and can be adjusted according to different user requirements, wherein the compound task information includes but is not limited to a normal period, an insertion period, an exclusion period, a task re-execution frequency, a synchronous task timeout time, an asynchronous task timeout time and the like. The normal cycle refers to an execution cycle of the compound task; the insertion cycle refers to an execution cycle carried in the insertion instruction; the exclusion period refers to an execution period carried in the delete instruction.
And importing a preset task template into the composite task to generate each subtask, and performing topological arrangement on the subtasks.
In this embodiment, task templates of some tasks to be performed in batch are preset in advance, the preset task templates are imported into the compound task, each subtask is directly generated, relevant task information of each subtask already exists in each subtask, and the subtasks are topologically arranged under a start node, so that a directed acyclic graph can be formed. In the process, the templates are led into the compound tasks in batches to generate each subtask, so that omission of the subtasks and errors of task information of certain subtasks can be avoided, the efficiency of adding the subtasks into the compound tasks and the correctness of the subtasks can be improved, and the workload of operators for creating and scheduling tasks is reduced.
It will be appreciated that the creation of a compound task may have overall control over the various sub-tasks within it.
Optionally, the preset task module may be led into the compound task in a visual dragging manner, and if a user has a need in the process, the task information of the subtask may be changed in real time.
Optionally, as shown in fig. 5, if the simple task is created, the task information is directly obtained, and the simple task is created according to the task information.
Optionally, as shown in fig. 6, before importing a preset task template into the compound task and generating each subtask, the method includes:
step S601, interface information is obtained, and a task import interface is created according to the interface information.
In this embodiment, interface information is acquired according to a creation instruction issued by a user to create a task import interface, and the task import interface is created according to the acquired interface information. The interface information may be adjusted according to different user requirements, and the interface information includes, but is not limited to, an interface name, a URL request address, a request mode, an interface description, and the like. The task import interface is used for creating an interface, and a task template can be generated and converted into a subtask according to the interface.
And step S602, verifying the import interface, and acquiring task template information when the verification is passed.
And step S603, importing the verified task into an interface to generate the task template according to the task template information.
In this embodiment, the created import interface is verified, when the interface is verified, task template information required for creating the task template is obtained, and the task template is generated by importing the verified task interface through the task template information. The task template information refers to task attribute information required by creating a task module, and can be filled and changed by a user according to requirements, including but not limited to overtime response time, re-execution times, whether to automatically ignore exception and the like; the task template refers to that all task information is set, the task template can be directly imported into the compound task to generate the subtask, and other task information does not need to be added.
Optionally, the task template may select a corresponding task template to be directly converted into a subtask or a simple task according to a conversion instruction sent by a user.
Optionally, there are various ways for verifying the import interface, which are not limited herein, for example, whether the interface verification is passed is determined by verifying whether the data returned by the interface is consistent with the expected result.
Optionally, as shown in fig. 7, before the task template is generated, which batch tasks currently exist is verified, and the task template corresponding to the batch tasks may be generated according to the interface information. After the task template is generated, the task template is executed, the execution log is checked, and when the content displayed by the execution log is in accordance with an expected result, the task template is proved to be verified to be passed and can be used, and the correctness of the composite task is improved through layer-by-layer verification.
Optionally, before performing the topological arrangement on the subtasks, the method includes:
and when a dragging instruction is received, loading a preset task type to a preset position in the compound task.
And acquiring task information, and generating a subtask according to the task type according to the task information.
In this embodiment, some commonly used task types supported by the current device are preset, when a drag instruction about a certain task type is received, the preset task type is loaded to a preset position of an editing area for creating a subtask in the compound task, task information about the task type is obtained, and the subtask is generated according to the task type loaded in the compound task. The task information refers to task attribute information required for creating the subtasks, and can be filled and changed by the user according to requirements, including but not limited to time for responding to timeout, times for re-execution, whether to automatically ignore exception, and the like.
It can be understood that the task template can generate the same subtasks in batch, and the related task information in the task template is filled in and can be changed correspondingly, but the change is not large generally; and the subtasks generated by the task types are loaded into the composite task in a mode of generating the subtasks by the task types without batch import of the subtasks by filling related task information according to the user requirements.
Optionally, the task types may be expanded according to user requirements, the task types further include a start task type, the start task type is used at a start of the task, and the task starts to execute the task with a start node formed by the start task type in the composite task, so that the subtasks generated by the other task types are located behind the start node generated by the start type.
Optionally, the log of the composite task scheduling may be checked in real time during the working process of the composite task, the execution progress of each sub-task may be checked through the log, and the execution of each sub-task may be controlled in real time according to the progress condition, for example, the selected sub-task may be subjected to real-time control techniques such as forced success, forced failure, execution skipping, re-execution, and the like, and each sub-task may be displayed in different colors and sizes according to different current execution conditions, so as to facilitate the user to look up and perform corresponding operations. For example, the subtask whose execution failed is displayed in red, the subtask whose execution is in progress is displayed in yellow, the subtask whose execution is not in progress is displayed in black, and the like. Wherein, the forced success means that when the subtask is abnormal, the subtask is controlled to be forced to succeed so as to avoid influencing the proceeding of the subsequent task; the skip execution means that a subtask is skipped according to a user's requirement, and the subtask is not executed any more.
Optionally, a tag may be added to the compound task, the compound task is queried through the tag, and grouping management is performed according to the tag, so that permission isolation of scheduling tasks among different departments or project groups is facilitated.
In the embodiment of the application, a subtask to be executed currently is selected from preset compound tasks; if the subtask has a dependent external task, acquiring the execution condition of the external task; if the subtask has a precursor task, acquiring the execution condition of the precursor task; if the execution condition of the external task and the execution condition of the precursor task are both completed, executing the subtask; when the execution of the subtasks is completed, if the subtasks which are not executed yet exist in the composite task, the subtasks to be executed currently are selected again from the subtasks which are not executed yet until all the subtasks in the composite task are executed completely. According to the method and the device, the subtasks to be executed are selected from the preset compound tasks, whether the subtasks are executed when the current subtasks have the external tasks or the precursor tasks is detected, the fact that the subtasks are executed when the external tasks and the precursor tasks are not executed is avoided, the execution result is deviated, when the external tasks and the precursor tasks are executed completely, the current subtasks are executed again, whether the subtasks still exist in the compound tasks or not is judged after the current subtasks are executed completely, the subtasks to be executed are selected from the subtasks not executed again until all the subtasks in the compound tasks are executed completely, and therefore the service problem with complex topological relation is solved.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Fig. 8 is a schematic structural diagram of a task scheduling device in an embodiment of the present application, and as shown in fig. 5, the task scheduling device may include:
and the selecting module 81 is configured to select a currently to-be-executed subtask from the preset compound task.
An external task module 82, configured to obtain an execution condition of the external task if the sub-task has a dependent external task.
A predecessor task module 83, configured to obtain an execution condition of the predecessor task if the sub-task has a predecessor task.
And an execution module 84, configured to execute the subtask if the execution condition of the external task and the execution condition of the predecessor task are both completed.
And a completion module 85, configured to, when the execution of the subtasks is completed, if there are subtasks that have not yet been executed in the composite task, reselect a subtask to be currently executed from the subtasks that have not yet been executed until all subtasks in the composite task are executed.
Optionally, the task scheduling device may further include:
and the first re-execution module is used for acquiring the preset attribute of the subtask if the execution of the subtask fails, and determining whether to re-execute the subtask according to the preset attribute.
And the second re-execution module is used for determining whether to re-execute the subtask according to the preset attribute if the execution time of the subtask exceeds a preset time threshold.
And the abnormal operation ignoring module is used for determining whether to ignore the abnormal operation of the subtask according to the preset attribute if the times of the re-execution operation exceed the preset re-execution times.
Optionally, the task scheduling device may further include:
and the task skipping module is used for skipping the execution of the subtasks when the subtasks are executed according to the skipping instruction if the skipping instruction is received.
And the insertion period module is used for inserting a preset execution period in the execution process of the subtask according to the insertion instruction if the insertion instruction is received.
And the deleting period module is used for deleting a preset executing period in the executing process of the subtask according to the deleting instruction if the deleting instruction is received.
Optionally, the task scheduling device may further include:
and the work ending module is used for ending the work of the compound task after the execution of the currently executed subtask in the compound task is finished if the work duration of the compound task is greater than a preset time threshold.
Optionally, the task scheduling device may further include:
and the creating module is used for acquiring the compound task information and creating the compound task according to the compound task information.
And the topological arrangement module is used for importing a preset task template into the composite task to generate each subtask and carrying out topological arrangement on the subtasks.
Optionally, the task scheduling device may further include:
and the acquisition module is used for acquiring the interface information and creating a task import interface according to the interface information.
And the verification module is used for verifying the import interface and acquiring the task template information when the verification is passed.
And the conversion module is used for leading the verified task into an interface to generate the task template according to the task template information.
Optionally, the task scheduling device may further include:
and the loading module is used for loading a preset task type to a preset position in the composite task when a dragging instruction is received.
And the generating module is used for acquiring task information and generating the task type into a subtask according to the task information.
In the embodiment of the application, a subtask to be executed currently is selected from preset compound tasks; if the subtask has a dependent external task, acquiring the execution condition of the external task; if the subtask has a precursor task, acquiring the execution condition of the precursor task; if the execution condition of the external task and the execution condition of the precursor task are both completed, executing the subtask; when the execution of the subtasks is completed, if the subtasks which are not executed yet exist in the composite task, the subtasks to be executed currently are selected again from the subtasks which are not executed yet until all the subtasks in the composite task are executed completely. According to the method and the device, the subtasks to be executed are selected from the preset compound tasks, whether the subtasks are executed when the current subtasks have the external tasks or the precursor tasks is detected, the fact that the subtasks are executed when the external tasks and the precursor tasks are not executed is avoided, the execution result is deviated, when the external tasks and the precursor tasks are executed completely, the current subtasks are executed again, whether the subtasks still exist in the compound tasks or not is judged after the current subtasks are executed completely, the subtasks to be executed are selected from the subtasks not executed again until all the subtasks in the compound tasks are executed completely, and therefore the service problem with complex topological relation is solved.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the apparatus and the module described above may refer to corresponding processes in the foregoing system embodiments and method embodiments, and are not described herein again.
Fig. 9 is a schematic structural diagram of a terminal device according to an embodiment of the present application. For convenience of explanation, only portions related to the embodiments of the present application are shown.
As shown in fig. 9, the terminal device 9 of this embodiment includes: at least one processor 900 (only one shown in fig. 9), a memory 901 connected to the processor 900, a scheduler 902, an actuator 903 and a computer program 904, such as a task scheduler, stored in the memory 901 and executable on the at least one processor 900. The processor 900 implements the steps in the various embodiments of the task scheduling method described above, such as steps S101 to S105 shown in fig. 1, when executing the computer program 904. Alternatively, the processor 900 implements the functions of the modules in the device embodiments described above, for example, the functions of the modules 81 to 85 shown in fig. 8, when executing the computer program 904. The scheduler 902 is used for task scheduling. The executor 903 is used for executing the task after the task is scheduled
Illustratively, the computer program 904 may be partitioned into one or more modules that are stored in the memory 901 and executed by the processor 900 to accomplish the present application. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program 904 in the terminal device 9. For example, the computer program 602 may be divided into a selection module 81, an external task module 82, a predecessor task module 83, an execution module 84, and a completion module 85, and the specific functions of each module are as follows:
and the selecting module 81 is configured to select a currently to-be-executed subtask from the preset compound task.
An external task module 82, configured to obtain an execution condition of the external task if the sub-task has a dependent external task.
A predecessor task module 83, configured to obtain an execution condition of the predecessor task if the sub-task has a predecessor task.
And an execution module 84, configured to execute the subtask if the execution condition of the external task and the execution condition of the predecessor task are both completed.
And a completion module 85, configured to, when the execution of the subtasks is completed, if there are subtasks that have not yet been executed in the composite task, reselect a subtask to be currently executed from the subtasks that have not yet been executed until all subtasks in the composite task are executed.
The terminal device 9 may include, but is not limited to, a processor 900, a memory 901, a scheduler 902, and an executor 903. Those skilled in the art will appreciate that fig. 9 is only an example of the terminal device 9, and does not constitute a limitation to the terminal device 9, and may include more or less components than those shown, or combine some components, or different components, such as an input/output device, a network access device, a bus, etc.
The Processor 900 may be a Central Processing Unit (CPU), and the Processor 900 may be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The storage 901 may be an internal storage unit of the terminal device 9 in some embodiments, for example, a hard disk or a memory of the terminal device 9. The memory 901 may also be an external storage device of the terminal device 9 in other embodiments, for example, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), or the like provided on the terminal device 9. Further, the memory 901 may also include both an internal storage unit and an external storage device of the terminal device 9. The memory 901 is used for storing an operating system, an application program, a BootLoader (BootLoader), data, and other programs, such as program codes of the computer program. The memory 901 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium and can implement the steps of the embodiments of the methods described above when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer readable medium may include at least: any entity or device capable of carrying computer program code to a photographing apparatus/terminal apparatus, a recording medium, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), an electrical carrier signal, a telecommunications signal, and a software distribution medium. Such as a usb-disk, a removable hard disk, a magnetic or optical disk, etc. In certain jurisdictions, computer-readable media may not be an electrical carrier signal or a telecommunications signal in accordance with legislative and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (10)

1. A method for task scheduling, comprising:
selecting a current subtask to be executed from preset compound tasks;
if the subtask has a dependent external task, acquiring the execution condition of the external task;
if the subtask has a precursor task, acquiring the execution condition of the precursor task;
if the execution condition of the external task and the execution condition of the precursor task are both completed, executing the subtask;
when the execution of the subtasks is completed, if the subtasks which are not executed yet exist in the composite task, the subtasks to be executed currently are selected again from the subtasks which are not executed yet until all the subtasks in the composite task are executed completely.
2. The task scheduling method of claim 1, after executing the subtasks, comprising:
if the subtask fails to be executed, acquiring a preset attribute of the subtask, and determining whether to execute the subtask again according to the preset attribute;
if the execution time of the subtask exceeds a preset time threshold, determining whether to execute the subtask again according to the preset attribute;
and if the times of re-execution operation exceed the preset times of re-execution, determining whether to ignore the abnormal operation of the subtask according to the preset attribute.
3. The task scheduling method of claim 1, comprising:
if a skip instruction is received, skipping to execute the subtasks when the subtasks are executed according to the skip instruction;
if an inserting instruction is received, inserting a preset execution cycle in the execution process of the subtask according to the inserting instruction;
and if a deleting instruction is received, deleting a preset execution period in the execution process of the subtask according to the deleting instruction.
4. The task scheduling method of claim 1, comprising:
and if the working time of the composite task is longer than a preset time threshold, finishing the work of the composite task after the execution of the currently executed subtask in the composite task is finished.
5. The task scheduling method of claim 1, wherein the creation process of the compound task comprises:
acquiring compound task information, and creating the compound task according to the compound task information;
and importing a preset task template into the composite task to generate each subtask, and performing topological arrangement on the subtasks.
6. The task scheduling method according to claim 5, wherein before importing a preset task template into the compound task and generating each subtask, the method comprises:
acquiring interface information, and creating a task import interface according to the interface information;
verifying the import interface, and acquiring task template information when the verification is passed;
and generating the task template by importing the verified task into an interface according to the task template information.
7. The task scheduling method of claim 5, prior to topologically arranging the subtasks, comprising:
when a dragging instruction is received, loading a preset task type to a preset position in the composite task;
and acquiring task information, and generating a subtask according to the task type according to the task information.
8. A task scheduling apparatus, comprising:
the selection module is used for selecting a current subtask to be executed from a preset composite task;
the external task module is used for acquiring the execution condition of the external task if the subtask has a dependent external task;
the precursor task module is used for acquiring the execution condition of the precursor task if the subtask has the precursor task;
the execution module is used for executing the subtasks if the execution condition of the external task and the execution condition of the precursor task are both completed;
and the completion module is used for reselecting the current subtask to be executed from the unexecuted subtasks until all subtasks in the compound task are executed and completed if the unexecuted subtasks exist in the compound task when the execution of the subtasks is completed.
9. A terminal device comprising a memory, a processor, a scheduler, an executor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of a method for task scheduling according to any of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of a method for task scheduling according to any one of claims 1 to 7.
CN202010528315.9A 2020-06-11 2020-06-11 Task scheduling method and device, terminal equipment and storage medium Pending CN113010276A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010528315.9A CN113010276A (en) 2020-06-11 2020-06-11 Task scheduling method and device, terminal equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010528315.9A CN113010276A (en) 2020-06-11 2020-06-11 Task scheduling method and device, terminal equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113010276A true CN113010276A (en) 2021-06-22

Family

ID=76383029

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010528315.9A Pending CN113010276A (en) 2020-06-11 2020-06-11 Task scheduling method and device, terminal equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113010276A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114529301A (en) * 2022-02-21 2022-05-24 山东浪潮通软信息科技有限公司 Voucher posting method, device, equipment and medium
CN114860301A (en) * 2022-03-04 2022-08-05 北京快乐茄信息技术有限公司 Service request processing method and device, electronic equipment and storage medium
WO2023202006A1 (en) * 2022-04-20 2023-10-26 Zhejiang Dahua Technology Co., Ltd. Systems and methods for task execution

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114529301A (en) * 2022-02-21 2022-05-24 山东浪潮通软信息科技有限公司 Voucher posting method, device, equipment and medium
CN114860301A (en) * 2022-03-04 2022-08-05 北京快乐茄信息技术有限公司 Service request processing method and device, electronic equipment and storage medium
WO2023202006A1 (en) * 2022-04-20 2023-10-26 Zhejiang Dahua Technology Co., Ltd. Systems and methods for task execution

Similar Documents

Publication Publication Date Title
CN113010276A (en) Task scheduling method and device, terminal equipment and storage medium
CN107944773A (en) Business process control method, device and storage medium
EP2264595A1 (en) Workflow-definition alteration program, workflow-definition alteration method, and workflow-definition alteration device
CN111984390A (en) Task scheduling method, device, equipment and storage medium
CN110471754B (en) Data display method, device, equipment and storage medium in job scheduling
US20060225042A1 (en) Virtual threads in business process programs
CN111400011B (en) Real-time task scheduling method, system, equipment and readable storage medium
US20220164222A1 (en) Execution of Services Concurrently
CN111797604A (en) Report generation method, device, equipment and computer readable storage medium
CN110019144A (en) A kind of method and system of big data platform data O&M
US20050144596A1 (en) Method and apparatus for parallel action processing
CN116089040A (en) Service flow scheduling method and device, electronic equipment and storage medium
CN111158800A (en) Method and device for constructing task DAG based on mapping relation
CN113609101A (en) Real-time data task issuing method and device, electronic equipment and storage medium
CN113485814A (en) Batch task scheduling method and device
CN110928672B (en) Task arranging method, device and equipment and storage medium
CN115495527A (en) Data synchronization management system and method
CN111190725B (en) Task processing method, device, storage medium and server
CN114675948A (en) DAG data model dynamic scheduling method and system
JP5229223B2 (en) Workflow definition change program and workflow definition change method
CN115185825A (en) Interface test scheduling method and device
CN112418796A (en) Sub-process node activation method and device, electronic equipment and storage medium
CN113553098A (en) Method and device for submitting Flink SQL (structured query language) operation and computer equipment
JP2010224812A (en) Job management system and method
CN115936402B (en) Task replication method, device, electronic 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