Disclosure of Invention
An object of the embodiments of the present application is to provide a job scheduling method, an apparatus, an electronic device, and a storage medium, so as to solve the problems of low fine granularity of job scheduling and low concurrency of task execution in the current scheduling manner.
In a first aspect, the present invention provides a job scheduling method, applied to each scheduler of a plurality of schedulers in a scheduling system, the method comprising: acquiring subtask information in job information, wherein the subtask information comprises subtasks and corresponding dependency conditions, the dependency conditions represent pre-tasks on which the subtasks depend for execution, the job information comprises a plurality of subtask information, and the subtask information acquired by different schedulers is different; judging whether the obtained dependent conditions corresponding to the subtasks are finished or not; and if the dependency condition is completed, executing the acquired subtasks.
In the job scheduling method designed above, the job information in this scheme is split into multiple pieces of sub-task information, then each scheduler in the scheduling system acquires one piece of subtask information, so that each scheduler judges the dependence condition in the subtask information acquired by itself, in case that the dependency condition is satisfied, the scheduler executes the subtask in the obtained subtask information, because each scheduler only needs to judge the dependence condition of the obtained subtask information, specifically only needs to read and judge the completion condition of the preposed task of the subtask in charge of the scheduler, without repeatedly scanning the execution state of the sub-task that has been previously completed as in the conventional manner, the scheduling method designed by the scheme of the application has the advantages that the scheduling of the job information is finer in granularity and higher in scheduling efficiency, and meanwhile, the scheduling concurrency is enhanced.
In an optional implementation manner of the first aspect, the determining whether the obtained dependency condition corresponding to the subtask is completed includes: reading the completion condition of a front task in the dependency condition according to the dependency condition corresponding to the subtask; and judging whether the acquired dependent conditions corresponding to the subtasks are finished or not according to the finishing condition of the front task in the dependent conditions.
In the embodiment designed above, the scheme only reads the completion condition of the pre-task in the dependency condition of the subtask in charge of the scheme, and then judges whether the dependency condition is completed, without rescanning the already-executed task like the existing scheme, thereby improving the scheduling efficiency.
In an optional implementation manner of the first aspect, each of the plurality of schedulers is assigned with an identifier of subtask information, and the obtaining one of the job information includes: and reading corresponding subtask information from the job information according to the identifier corresponding to the distributed subtask information.
In an optional implementation manner of the first aspect, the obtaining of one subtask information in the job information includes: when the read is turned to, one piece of subtask information which is not read by other schedulers is randomly read from the job information.
In an optional implementation manner of the first aspect, the dependency condition corresponding to the sub-task includes a single pre-task or multiple pre-tasks or 0 pre-tasks on which the sub-task executes.
In an optional implementation manner of the first aspect, the determining whether the obtained dependency condition corresponding to the subtask is completed includes: judging whether the number of the preposed tasks in the dependence condition of the subtasks is 0 or not; and if so, determining that the dependent condition is completed to execute the acquired subtasks.
In a second aspect, the present invention provides a job scheduling apparatus, which is applied to each scheduler of a plurality of schedulers in a scheduling system, the apparatus comprising:
the task scheduling system comprises an acquisition module, a scheduling module and a scheduling module, wherein the acquisition module is used for acquiring subtask information in job information, the subtask information comprises subtasks and corresponding dependence conditions, the dependence conditions represent pre-tasks on which the subtasks depend for execution, the job information comprises a plurality of subtask information, and the subtask information acquired by different schedulers is different; the judging module is used for judging whether the acquired dependent conditions corresponding to the subtasks are finished or not; and the execution module is used for executing the acquired subtasks under the condition that the dependent condition is completed.
In the job scheduling device designed above, the job information is split into a plurality of sub-task information, then each scheduler in the scheduling system acquires one piece of subtask information, so that each scheduler judges the dependence condition in the subtask information acquired by itself, in case that the dependency condition is satisfied, the scheduler executes the subtask in the obtained subtask information, because each scheduler only needs to judge the dependence condition of the obtained subtask information, specifically only needs to read and judge the completion condition of the preposed task of the subtask in charge of the scheduler, without repeatedly scanning the execution state of the sub-task that has been previously completed as in the conventional manner, the scheduling method designed by the scheme of the application has the advantages that the scheduling of the job information is finer in granularity and higher in scheduling efficiency, and meanwhile, the scheduling concurrency is enhanced.
In an optional implementation manner of the second aspect, the determining module is specifically configured to read, according to a dependency condition corresponding to the subtask, a completion condition of a pre-task in the dependency condition; and judging whether the acquired dependent conditions corresponding to the subtasks are finished or not according to the finishing condition of the front task in the dependent conditions.
In an optional implementation manner of the second aspect, each of the plurality of schedulers is assigned with an identifier of subtask information, and the obtaining module is specifically configured to read corresponding subtask information from the job information according to the identifier corresponding to the assigned subtask information.
In an optional implementation manner of the second aspect, the plurality of pieces of subtask information are sequentially read by the plurality of schedulers according to a preset reading order, and the obtaining module is further specifically configured to randomly read one piece of subtask information that is not read by another scheduler from the job information when the obtaining module is in turn to read itself.
In a third aspect, the present application provides an electronic device, including a memory and a processor, where the memory stores a computer program, and the processor executes the computer program to perform the method in the first aspect or any optional implementation manner of the first aspect.
In a fourth aspect, the present application provides a storage medium having stored thereon a computer program which, when executed by a processor, performs the method of the first aspect, any of the alternative implementations of the first aspect.
In a fifth aspect, the present application provides a computer program product, which when run on a computer, causes the computer to perform the method of the first aspect, any optional implementation manner of the first aspect.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
An embodiment of the present application provides a job scheduling method, which is applied to each scheduler of a plurality of schedulers in a scheduling system, and as shown in fig. 2, the method may include the following steps:
step S200: and acquiring one piece of subtask information in the job information.
Step S210: and judging whether the acquired dependency condition corresponding to the subtask is completed, if so, turning to step S120.
Step S220: and executing the acquired subtasks.
In step S200, the job information includes a plurality of subtask information, each subtask information includes a subtask and a corresponding dependency condition, the dependency condition indicates a pre-task on which the subtask is executed, that is, the dependency condition indicates that the subtask can be executed only after the condition that the execution of the dependent pre-task is completed is satisfied, where the pre-task in the dependency condition may be single, multiple, or 0, and the 0 pre-task may consider that the subtask has no dependency condition.
For example, thesubtask information 1 includes thesubtask 1 in fig. 1 and the dependency condition of the subtask 1 (thesubtask 1 has no pre-task), and thesubtask information 2 includes thesubtask 2 and the subtask 2 dependency condition in fig. 1, where the dependency condition of thesubtask 2 is the task1, that is, thesubtask 2 can be executed only after the execution of thesubtask 1 is completed.
Similarly, thesubtask information 3 includes the dependent conditions of thesubtask 3 and thesubtask 3 in fig. 1, and the dependent condition of thesubtask 3 is thesubtask 1 and thesubtask 5, that is, thesubtask 3 can only be executed after the respective execution of thesubtask 1 and thesubtask 5 is completed.
Thesubtask information 4 contains thesubtask 4 and the dependency condition of thesubtask 4 in fig. 1, and the dependency condition of thesubtask information 4 is thesubtask 6 and thesubtask 8.
Thesubtask information 5 contains the subtask 5 and the dependency condition of thesubtask 5 in fig. 1, and thesubtask 5 has no dependency condition.
Thesubtask information 6 contains the subtask 6 and the dependency condition of thesubtask 6 in fig. 1, and the dependency condition of thesubtask 6 is thesubtask 2 and thesubtask 3.
Thesubtask information 7 contains the subtask 7 and the dependency condition of thesubtask 7 in fig. 1, and the dependency condition of thesubtask 7 is the subtask 5.
Thesubtask information 8 contains the subtask 8 and the dependency condition of thesubtask 8 in fig. 1, and the dependency condition of thesubtask 8 is the subtask 7.
In step S200, each scheduler in the scheduling system may serve as an execution subject of the method, and each scheduler in the scheduling system acquires one piece of sub-task information in the job information, and the sub-task information acquired by different schedulers is different.
For example, taking the job information shown in fig. 3 as an example, if the job information includes 8 pieces of sub-task information, there may be 8 schedulers, and each scheduler acquires one piece of sub-task information, for example, scheduler aacquires sub-task information 1, scheduler B acquiressub-task information 2, scheduler C acquiressub-task information 3, scheduler D acquiressub-task information 4, scheduler E acquiressub-task information 5, scheduler F acquiressub-task information 6, scheduler G acquiressub-task information 7, and scheduler H acquiressub-task information 8.
As a possible implementation, the scheduler acquiring one subtask information in the job information may include the following steps, as shown in fig. 4:
step S400: and reading corresponding subtask information from the job information according to the identifier corresponding to the distributed subtask information.
In the above embodiment, the scheduler is allocated with an identifier corresponding to the subtask information in advance, for example, thesubtask information 1 corresponds to the identifier a, the identifier a is allocated or stored in the scheduler a in advance, and when the scheduler a acquires the subtask information, the scheduler a may find thesubtask information 1 in the job information according to the identifier a, so as to obtain the dependency conditions of thesubtask 1 and thesubtask 1.
As another possible implementation, when the scheduler turns to read itself, it randomly reads a piece of subtask information that is not read by other schedulers from the job information to obtain one piece of subtask information in the job information.
For example, according to the foregoing example, if it is assumed that, when the scheduler C is in turn reading, thesubtask information 1 in the job information is already read by the scheduler a, and thesubtask information 5 is already read by the scheduler B, then when the scheduler C reads, one subtask information that is not read by the other schedulers in the job information is read: that is, one piece of subtask information is randomly read from thesubtask information 2, thesubtask information 3, thesubtask information 4, thesubtask information 6, thesubtask information 7, and thesubtask information 8.
The scheduler is made available to one of the job information in the foregoing manner, thereby performing step S210.
In step S210, the scheduler determines whether the dependency condition corresponding to the subtask in the acquired subtask information is completed, that is, whether the pre-task corresponding to the subtask is completed.
As a possible implementation, as shown in fig. 5, step S210 can also be implemented as follows:
step S500: reading the completion condition of a front task in a dependency condition according to the dependency condition corresponding to the subtask;
step S510: and judging whether the acquired dependent conditions corresponding to the subtasks are finished or not according to the finishing condition of the front task in the dependent conditions.
In the above embodiment, after obtaining the subtask information, the scheduler may obtain the dependency condition corresponding to the subtask in the subtask information, so as to obtain the pre-task of the subtask, and then the scheduler only needs to read and determine whether the pre-task of the subtask is completed, without reading the states of all subtasks, and when the pre-task of the subtask is completed, it is determined that the dependency condition corresponding to the subtask is completed, and then step S120 is performed to execute the subtask in the subtask information.
For example, according to the foregoing example, after the device B obtains thesubtask information 2, it can be known that the dependency condition of thesubtask 2 is thepre-task 1, at this time, the device B only needs to read the completion condition of thesubtask 1, and when thesubtask 1 has not been executed, it indicates that the dependency condition of thesubtask 2 is not satisfied; when the execution of thesubtask 1 is completed, it indicates that the dependency condition of thesubtask 2 is satisfied, and thesubtask 2 is executed.
In the job scheduling method designed above, the job information in this scheme is split into multiple pieces of sub-task information, then each scheduler in the scheduling system acquires one piece of subtask information, so that each scheduler judges the dependence condition in the subtask information acquired by itself, in case that the dependency condition is satisfied, the scheduler executes the subtask in the obtained subtask information, because each scheduler only needs to judge the dependence condition of the obtained subtask information, specifically only needs to read and judge the completion condition of the preposed task of the subtask in charge of the scheduler, without repeatedly scanning the execution state of the sub-task that has been previously completed as in the conventional manner, the scheduling method designed by the scheme of the application has the advantages that the scheduling of the job information is finer in granularity and higher in scheduling efficiency, and meanwhile, the scheduling concurrency is enhanced.
In an optional implementation manner of this embodiment, the aforementioned descriptions may include that the number of the pre-tasks in the dependency condition corresponding to the sub-task is single, multiple, and 0, on this basis, it is determined in step S110 whether the dependency condition corresponding to the sub-task is completed, and it may further include determining whether the number of the pre-tasks in the dependency condition of the sub-task is 0, and if the number is 0, directly executing the sub-task whose number is 0.
Fig. 6 shows a schematic block diagram of a job scheduling apparatus provided by the present application, and it should be understood that the apparatus corresponds to the method embodiments executed in fig. 2 to 5, and can execute the steps related to the foregoing method, and the specific functions of the apparatus can be referred to the description above, and a detailed description is appropriately omitted here to avoid redundancy. The device includes at least one software function that can be stored in memory in the form of software or firmware (firmware) or solidified in the Operating System (OS) of the device. Specifically, the apparatus includes: an obtainingmodule 600, configured to obtain subtask information in job information, where the subtask information includes a subtask and a corresponding dependency condition, where the dependency condition indicates a pre-task on which the subtask is dependent for execution, and the job information includes a plurality of subtask information, where subtask information obtained by different schedulers is different; the judgingmodule 610 is configured to judge whether the obtained dependency condition corresponding to the sub-task is completed; and an executingmodule 620, configured to execute the acquired subtask when the dependent condition is completed.
In the job scheduling device designed above, the job information is split into a plurality of sub-task information, then each scheduler in the scheduling system acquires one piece of subtask information, so that each scheduler judges the dependence condition in the subtask information acquired by itself, in case that the dependency condition is satisfied, the scheduler executes the subtask in the obtained subtask information, because each scheduler only needs to judge the dependence condition of the obtained subtask information, specifically only needs to read and judge the completion condition of the preposed task of the subtask in charge of the scheduler, without repeatedly scanning the execution state of the sub-task that has been previously completed as in the conventional manner, the scheduling method designed by the scheme of the application has the advantages that the scheduling of the job information is finer in granularity and higher in scheduling efficiency, and meanwhile, the scheduling concurrency is enhanced.
In an optional implementation manner of this embodiment, the determiningmodule 610 is specifically configured to read a completion condition of a pre-task in a dependency condition according to the dependency condition corresponding to the sub-task; and judging whether the acquired dependent conditions corresponding to the subtasks are finished or not according to the finishing condition of the front task in the dependent conditions.
In an optional implementation manner of this embodiment, each scheduler in the multiple schedulers is assigned with an identifier of one piece of subtask information, and the obtainingmodule 600 is specifically configured to read corresponding subtask information from the job information according to the identifier corresponding to the assigned subtask information.
In an optional implementation manner of this embodiment, the plurality of pieces of subtask information are sequentially read by the plurality of schedulers according to a preset reading order, and the obtainingmodule 600 is further specifically configured to randomly read one piece of subtask information that is not read by another scheduler from the job information when the reading is in turn.
It should be clear that the present application provides a job scheduling apparatus (shown in fig. 6) that can be used to perform the job scheduling method described in the first aspect of the present application, and can also be used to perform other job scheduling methods without departing from the scope of the present invention.
As shown in fig. 7, the present application provides anelectronic device 7 including: theprocessor 701 and thememory 702, theprocessor 701 and thememory 702 being interconnected and communicating with each other via acommunication bus 703 and/or other form of connection mechanism (not shown), thememory 702 storing a computer program executable by theprocessor 701, theprocessor 701 executing the computer program when the computing device is running to perform the method in any alternative implementation, such as steps S200 to S220: acquiring subtask information in the operation information; and judging whether the dependency condition corresponding to the acquired subtask is completed, if so, executing the acquired subtask.
The present application provides a storage medium having stored thereon a computer program which, when executed by a processor, performs the method of any of the preceding alternative implementations.
The storage medium may be implemented by any type of volatile or nonvolatile storage device or combination thereof, such as a Static Random Access Memory (SRAM), an Electrically Erasable Programmable Read-Only Memory (EEPROM), an Erasable Programmable Read-Only Memory (EPROM), a Programmable Read-Only Memory (PROM), a Read-Only Memory (ROM), a magnetic Memory, a flash Memory, a magnetic disk, or an optical disk.
The present application provides a computer program product which, when run on a computer, causes the computer to perform the method of any of the alternative implementations.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and 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 of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
In addition, 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.
Furthermore, the functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
It should be noted that the functions, if implemented in the form of software functional modules and sold or used as independent products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
In this document, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.