CN113778652A - Task scheduling method and device, electronic equipment and storage medium - Google Patents
Task scheduling method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN113778652A CN113778652A CN202111106267.5A CN202111106267A CN113778652A CN 113778652 A CN113778652 A CN 113778652A CN 202111106267 A CN202111106267 A CN 202111106267A CN 113778652 A CN113778652 A CN 113778652A
- Authority
- CN
- China
- Prior art keywords
- task
- scheduler
- cluster
- actuator
- information
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 66
- 230000015654 memory Effects 0.000 claims abstract description 46
- 230000008859 change Effects 0.000 claims description 25
- 238000004590 computer program Methods 0.000 claims description 12
- 230000008569 process Effects 0.000 description 9
- 238000012545 processing Methods 0.000 description 8
- 238000010586 diagram Methods 0.000 description 7
- 238000001514 detection method Methods 0.000 description 4
- 230000006870 function Effects 0.000 description 4
- 230000008901 benefit Effects 0.000 description 3
- 238000004891 communication Methods 0.000 description 3
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 238000011161 development Methods 0.000 description 2
- 230000003203 everyday effect Effects 0.000 description 2
- 230000000977 initiatory effect Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000011160 research Methods 0.000 description 2
- 238000012546 transfer Methods 0.000 description 2
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000004064 recycling Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000001360 synchronised effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/52—Program synchronisation; Mutual exclusion, e.g. by means of semaphores
- G06F9/524—Deadlock detection or avoidance
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The disclosure provides a task scheduling method, a task scheduling device, an electronic device and a storage medium, wherein the method comprises the following steps: under the condition that the target task needs to be executed, controlling a plurality of schedulers in the scheduler cluster to respectively acquire distributed locks from the coordinator cluster; reading the associated information in the first scheduler of the obtained distributed lock, and determining a target actuator from the actuator cluster according to the target task and the associated information; and controlling the first scheduler to schedule the target executor to execute the target task. According to the embodiment of the disclosure, because the coordinator cluster is adopted to replace a database in the prior art, namely, the lock data is cached in the memory of the coordinator cluster, compared with the database lock, the lock is more stable, and by acquiring the distributed lock from the coordinator cluster, the situation that deadlock is easy to occur in a high concurrency environment is avoided; in addition, since the associated information of the actuator cluster is stored in the memory of the scheduler, the scheduling efficiency can be improved compared with the case that the associated information is stored in the database.
Description
Technical Field
The present disclosure relates to the field of task scheduling technologies, and in particular, to a task scheduling method and apparatus, an electronic device, and a storage medium.
Background
With the development of internet technology, whether internet application or enterprise-level application, many business scenarios need to do a certain task at a certain time, such as 16-point-per-day statistics of sales data of the current day, and therefore a task scheduling system is needed to solve the problem.
At present, a cluster-based task scheduling architecture is usually used to execute corresponding tasks, that is, multiple schedulers are used to schedule target executors to execute target tasks. In order to avoid the situation that a plurality of schedulers conflict in the process of triggering the scheduling task, the scheduler which has successfully preempted can take charge of the scheduling right of the task in a mode of preempting the distributed lock. Such as an XXL-JOB task scheduling platform, the process of preempting a distributed lock by multiple schedulers is realized through a Database (DB) lock, and task information is stored in the Database. However, when there are many types and data of tasks and many actuators, the scheduling concurrency increases, which causes deadlock to easily occur when the scheduler acquires the database lock, and further affects the scheduling work of the entire scheduling platform.
Disclosure of Invention
The embodiment of the disclosure at least provides a task scheduling method, a task scheduling device, electronic equipment and a computer-readable storage medium.
In a first aspect, an embodiment of the present disclosure provides a task scheduling method, including:
under the condition that the target task needs to be executed, controlling a plurality of schedulers in the scheduler cluster to respectively acquire distributed locks from the coordinator cluster; the scheduler stores the associated information of the actuator cluster; the associated information comprises identity information of a plurality of actuators in the actuator cluster and task information required to be executed by each actuator;
reading the association information in the first scheduler of the distributed lock, and determining a target actuator from the actuator cluster according to the target task and the association information;
and controlling the first scheduler to schedule the target executor to execute the target task.
In the embodiment of the disclosure, because the coordinator cluster is used to replace the database in the prior art, that is, the lock data is cached in the memory of the coordinator cluster, the lock is more stable than the database lock, and by acquiring the distributed lock from the coordinator cluster, the situation that deadlock is easy to occur in a high concurrency environment is avoided; in addition, since the associated information of the actuator cluster is stored in the memory of the scheduler, the scheduling efficiency can be improved compared with the case that the associated information is stored in the database.
In a possible implementation form according to the first aspect, the identity information of the executor comprises an internet protocol address IP of the executor and/or a name of the executor; the task information comprises at least one of execution content of the task, execution time of the task and task identification number ID.
According to the first aspect, in a possible implementation manner, the determining a target executor from the executor cluster according to the target task and the associated information includes:
determining a plurality of associated actuators from the actuator cluster according to the target task and the associated information;
and determining the target actuator from the plurality of associated actuators according to a preset scheduling rule.
In the embodiment of the disclosure, the target executor is determined from the multiple executors according to the preset scheduling rule, so that the multiple executors can be prevented from generating conflict when executing the target task, and the scheduling efficiency is further improved.
According to the first aspect, in one possible implementation, the determining that the target task needs to be performed includes:
determining whether the target task needs to be executed or not based on preset task scheduling information; the task scheduling information comprises a preset time node, a preset time interval or a preset task scheduling frequency.
According to the first aspect, in a possible implementation, before the determining that the target task needs to be performed, the method further comprises:
storing the association information to a second scheduler in the scheduler cluster;
controlling the second scheduler to send the association information to the coordinator cluster;
and sending the associated information to other schedulers except the second scheduler in the scheduler cluster for storage through the coordinator cluster.
In the embodiment of the disclosure, the coordinator cluster stores the associated information into the memories of all schedulers of the scheduler cluster, instead of storing the associated information in the database in the existing algorithm, so that the scheduling efficiency is improved.
According to the first aspect, in one possible implementation, the method further comprises:
when the task information is changed, storing the task change information to a third scheduler in the scheduler cluster;
controlling the third scheduler to send the task change information to the coordinator cluster;
and sending the task change information to other schedulers except the third scheduler in the scheduler cluster for storage through the coordinator cluster.
In the embodiment of the disclosure, the task change information is stored in the memories of all the schedulers of the scheduler cluster through the coordinator cluster, so that the scheduling efficiency is improved.
In a possible implementation form according to the first aspect, the coordinator cluster comprises at least one zookeeper, at least one chubby, at least one redis, or at least one memcache.
In a second aspect, an embodiment of the present disclosure further provides a task scheduling apparatus, including:
the acquisition module is used for controlling a plurality of schedulers in the scheduler cluster to respectively acquire the distributed locks from the coordinator cluster under the condition that the target task needs to be executed; the scheduler stores the associated information of the actuator cluster; the associated information comprises identity information of a plurality of actuators in the actuator cluster and task information required to be executed by each actuator;
a determining module, configured to read the associated information in the first scheduler that obtains the distributed lock, and determine a target actuator from the actuator cluster according to the target task and the associated information;
and the execution module is used for controlling the first scheduler to schedule the target executor to execute the target task.
According to the second aspect, in one possible embodiment, the identity information of the executor comprises an internet protocol address IP of the executor and/or a name of the executor; the task information comprises at least one of execution content of the task, execution time of the task and task identification number ID.
According to the second aspect, in a possible implementation manner, the determining module is specifically configured to:
determining a plurality of associated actuators from the actuator cluster according to the target task and the associated information;
and determining the target actuator from the plurality of associated actuators according to a preset scheduling rule.
According to the second aspect, in a possible implementation manner, the obtaining module is specifically configured to:
determining whether the target task needs to be executed or not based on preset task scheduling information; the task scheduling information comprises a preset time node, a preset time interval or a preset task scheduling frequency.
According to a second aspect, in a possible implementation, the apparatus further comprises:
a storage module to store the association information to a second scheduler in the scheduler cluster;
a first sending module, configured to control the second scheduler to send the association information to the coordinator cluster;
and a second sending module, configured to send, by the coordinator cluster, the association information to other schedulers in the scheduler cluster except for the second scheduler for storage.
According to the second aspect, in a possible implementation, the storage module is further configured to:
when the task information is changed, storing the task change information to a third scheduler in the scheduler cluster;
the first sending module is further configured to:
controlling the third scheduler to send the task change information to the coordinator cluster;
the second sending module is further configured to:
and sending the task change information to other schedulers except the third scheduler in the scheduler cluster for storage through the coordinator cluster.
According to a second aspect, in one possible implementation, the coordinator cluster comprises at least one zookeeper, at least one chubby, at least one redis, or at least one memcache.
In a third aspect, an embodiment of the present disclosure further provides an electronic device, including: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, the processor and the memory communicate with each other via the bus when the electronic device runs, and the machine-readable instructions are executed by the processor to perform the task scheduling method according to the first aspect or any one of the possible embodiments of the first aspect.
In a fourth aspect, this disclosed embodiment further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program performs the task scheduling method described in the above first aspect, or any possible implementation manner of the first aspect.
In order to make the aforementioned objects, features and advantages of the present disclosure more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the embodiments will be briefly described below, and the drawings herein incorporated in and forming a part of the specification illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the technical solutions of the present disclosure. It is appreciated that the following drawings depict only certain embodiments of the disclosure and are therefore not to be considered limiting of its scope, for those skilled in the art will be able to derive additional related drawings therefrom without the benefit of the inventive faculty.
Fig. 1 is a flowchart illustrating a task scheduling method provided by an embodiment of the present disclosure;
FIG. 2 is a schematic diagram illustrating an architecture of a task scheduling platform according to an embodiment of the present disclosure;
FIG. 3 is a flowchart illustrating a method for determining a target actuator from the actuator cluster according to an embodiment of the disclosure;
FIG. 4 is a flow chart illustrating another task scheduling method provided by an embodiment of the present disclosure;
FIG. 5 is a flowchart illustrating a method for storing task change information according to an embodiment of the disclosure;
fig. 6 is a schematic structural diagram illustrating a task scheduling apparatus according to an embodiment of the present disclosure;
FIG. 7 is a schematic structural diagram of another task scheduling apparatus provided in the embodiment of the present disclosure;
fig. 8 shows a schematic diagram of an electronic device provided by an embodiment of the present disclosure.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions of the embodiments of the present disclosure will be described clearly and completely with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are only a part of the embodiments of the present disclosure, not all of the embodiments. The components of the embodiments of the present disclosure, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present disclosure, presented in the figures, is not intended to limit the scope of the claimed disclosure, but is merely representative of selected embodiments of the disclosure. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the disclosure without making creative efforts, shall fall within the protection scope of the disclosure.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The term "and/or" herein merely describes an associative relationship, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, C, and may mean including any one or more elements selected from the group consisting of A, B and C.
With the development of internet technology, whether internet application or enterprise-level application, many business scenarios need to do a certain task at a certain time, such as 16-point-per-day statistics of sales data of the current day, and therefore a task scheduling system is needed to solve the problem.
At present, a cluster-based task scheduling architecture is usually used to execute corresponding tasks, that is, multiple schedulers are used to schedule target executors to execute target tasks. In order to avoid the situation that a plurality of schedulers conflict in the process of triggering the scheduling task, the scheduler which has successfully preempted can take charge of the scheduling right of the task in a mode of preempting the distributed lock. Such as an XXL-JOB task scheduling platform, the process of preempting a distributed lock by multiple schedulers is realized through a Database (DB) lock, and task information is stored in the Database.
Research shows that when the number of types and data of tasks is large and the number of actuators is large, the scheduling concurrency is increased, so that deadlock is easily caused when a scheduler acquires a database lock, and the scheduling work of the whole scheduling platform is influenced.
Based on the above research, the present disclosure provides a task scheduling method, which may control a plurality of schedulers in a scheduler cluster to respectively acquire a distributed lock from a coordinator cluster under the condition that it is determined that a target task needs to be executed, then read the associated information in a first scheduler that acquires the distributed lock, determine a target executor from the executor cluster according to the target task and the associated information, and then control the first scheduler to schedule the target executor to execute the target task. In the method, because the coordinator cluster is adopted to replace a database in the prior art, namely, the lock data is cached in the memory of the coordinator cluster, the method is more stable compared with the database lock, and the condition that deadlock is easy to occur in a high concurrency environment is avoided by acquiring the distributed lock from the coordinator cluster; in addition, since the associated information of the actuator cluster is stored in the memory of the scheduler, the scheduling efficiency can be improved compared with the case that the associated information is stored in the database.
The above-mentioned drawbacks are the results of the inventor after practical and careful study, and therefore, the discovery process of the above-mentioned problems and the solutions proposed by the present disclosure to the above-mentioned problems should be the contribution of the inventor in the process of the present disclosure.
To facilitate understanding of the present embodiment, first, a task scheduling method disclosed in the embodiments of the present disclosure is described in detail, where an execution subject of the task scheduling method provided in the embodiments of the present disclosure is generally an electronic device with certain computing capability, and the electronic device includes, for example: a terminal device, which may be a mobile device, a user terminal, a handheld device, a computing device, a vehicle device, a wearable device, or the like, or a server or other processing device. In some possible implementations, the task scheduling method may be implemented by a processor calling computer readable instructions stored in a memory.
Referring to fig. 1, a flowchart of a task scheduling method provided by the embodiment of the present disclosure is shown, where the method may be applied to the electronic device, or applied to a local or cloud server. The task scheduling method shown in fig. 1 includes the following S101 to S103:
s101, under the condition that a target task needs to be executed, controlling a plurality of schedulers in a scheduler cluster to respectively acquire distributed locks from a coordinator cluster; the scheduler stores the associated information of the actuator cluster; the associated information includes identity information of a plurality of actuators in the actuator cluster and task information that each actuator needs to execute.
The target tasks are a large number of batch processing tasks existing in the business scene of some internet applications or enterprise-level applications, and the running of the tasks has certain periodicity, such as number 1 sales data of each month in statistics of the month, or 9: 00 send coupons or push messages to users, which requires a task scheduling platform to perform the target task.
In some embodiments, whether the target task needs to be executed may be determined based on preset task scheduling information. The task scheduling information may be a preset time node, for example, a service scenario may be that the payment system performs a one-day clearing at 1 am every day, or performs a last-month clearing at 1 # every month, or sends an email to the user at 9 # every day, which is not limited herein.
The scheduling information of the task may also be a preset time interval, for example, the service scenario may be that a user of an e-commerce may perform coupon rush-purchase every 1 hour interval, or an electronic ticket-purchasing system does not successfully pay an order for more than 30 minutes, performs recycling processing, and the like, which is not limited herein.
The task scheduling information may also be a preset number of task scheduling times, for example, a service scenario may be that a certain news software pushes hot news to a user twice a day, or that a certain payment software gives a chance that a user inputs a correct password three times, and the user is prompted to re-input every time an error is input, and the like, which is not limited herein. It is to be understood that, in other embodiments, the scheduling information may further include other preset events, which are not described in detail herein.
For example, referring to fig. 2, the task scheduling platform is an open-source distributed task scheduling platform, and includes a scheduler cluster, an executor cluster, and a coordinator cluster, where the scheduler cluster includes a plurality of schedulers, and each scheduler is responsible for managing scheduling information and sending a scheduling request according to scheduling configuration to schedule an executor in the executor cluster to execute a corresponding target task; the executor cluster comprises a plurality of executors, and each executor is responsible for receiving a scheduling request of a scheduler to execute a target task; the coordinator cluster comprises a plurality of coordinators, each coordinator capable of providing a coordination service, in particular to coordinate the execution of scheduling work by the schedulers in the scheduler cluster by providing a distributed lock service. The specific scheduling method will be described in detail in the following embodiments.
The distributed lock can be understood as a mark bit, in a distributed system, when a plurality of threads access a shared resource at the same time, in order to avoid conflict among the threads and ensure consistency, the thread accessing the resource firstly can make a mark, each thread can see the mark, and other subsequent threads can try to set the mark after waiting for the marked thread to end and cancel the mark when finding that the mark exists. The following will be described in detail with specific service scenarios:
for example, company a performs "18 a day: the task of 'data of sales reports on the day' is counted at 00 and executed by an actuator in the actuator cluster, but because the actuator cluster contains a plurality of actuators, the same task can be executed by only one actuator, and in order to avoid repetition, a scheduler needs to schedule a certain actuator to execute the task. Since the scheduler cluster contains a plurality of schedulers, only one scheduler can execute the scheduling task, and in order to avoid conflict, the scheduler acquiring the distributed lock executes the scheduling task by the way that the plurality of schedulers acquire the distributed lock from the coordinator cluster.
When the scheduler 1, the scheduler 2 and the scheduler 3 acquire the distributed lock, the default value of the flag bit is "0000" to indicate that the current lock is available, then 3 schedulers access the flag bit to read the value of the flag bit, and if the scheduler 1 reads the flag bit first, the value of the flag bit is set to "0001" to indicate that the lock is occupied, then the scheduler 1 executes the scheduling task, and if the value read by the subsequent schedulers 2 and 3 is "0001", the lock is not acquired, and the scheduling task is not executed. When the scheduled task of scheduler 1 is finished, the value of the flag bit is changed from "0001" to "0000", which indicates that the lock is released to satisfy the execution of the subsequent scheduled task.
For example, the coordinator cluster may include at least one distributed application coordination system such as a zookeeper or chubby, and may also include at least one distributed cache system such as a redis or a memcache, which is not limited herein.
For example, the scheduler stores associated information of an actuator cluster, where the associated information may be identity information of a plurality of actuators, such as IP addresses of the actuators, names of the actuators, and the number of the actuators, which is not limited herein. The name of the actuator may be "actuator a" or "actuator 1", and the number of the actuators may be 3 or 10, which are not limited herein.
The associated information may also include task information that the executor needs to execute, for example, the task information may include execution content of the task, execution time of the task, ID of the task, and the like, which is not limited herein. The execution content of the task can be ' statistical sales data ' or ' pushing message to user ', and the execution time of the task can be ' 8: 00' may also be "No. 1 per month", which is not limited herein. The task ID distinguishes the tasks in batches, and is used for recording the identification number of the tasks.
S102, reading the obtained associated information in the first scheduler of the distributed lock, and determining a target actuator from the actuator cluster according to the target task and the associated information.
And the first scheduler is a scheduler which acquires the distributed lock in the scheduler cluster, and the first scheduler starts to execute scheduling work after acquiring the distributed lock. Because the executor cluster includes a plurality of executors, and one of the executors needs to be scheduled to execute a target task, at this time, the associated information such as the executor identity information and the task information stored in the first scheduler needs to be read, and the target executor is determined from the plurality of executors according to the target task and the associated information.
S103, controlling the first scheduler to schedule the target executor and execute the target task.
After the target executor is determined, the first scheduler which acquires the distributed lock schedules the target executor to execute the target task.
It should be noted that most of the current task scheduling platforms are based on a distributed cluster architecture, that is, the task scheduling platform includes a plurality of schedulers, a plurality of actuators, and a plurality of coordinators, so as to prevent one of the nodes from affecting the normal operation of the entire task scheduling system after a fault or a downtime occurs. And aiming at one target task, only one scheduler is needed to schedule one actuator to execute the target task, so that the task scheduling method disclosed by the invention solves the problem in order to avoid conflict.
In the embodiment of the disclosure, because the coordinator cluster is used to replace the database in the prior art, that is, the lock data is cached in the memory of the coordinator cluster, the lock is more stable than the database lock, and by acquiring the distributed lock from the coordinator cluster, the situation that deadlock is easy to occur in a high concurrency environment is avoided; in addition, since the associated information of the actuator cluster is stored in the memory of the scheduler, the scheduling efficiency can be improved compared with the case that the associated information is stored in the database.
Referring to the above S102, referring to fig. 3, a flowchart of a method for determining a target actuator from the actuator cluster is shown, where the method includes the following S1021 to S1022:
s1021, determining a plurality of associated actuators from the actuator cluster according to the target task and the associated information.
For example, an actuator cluster includes an actuator a, an actuator B, an actuator C, an actuator D, and an actuator E, and the current target task is "18: 00 statistics of sales data of the current day ", the first scheduler determines that the executor a, the executor B, and the executor E can execute" 18: 00 for calculating the target task of the current sales data, the executor A, the executor B and the executor E are the associated executors.
S1022, determining the target actuator from the plurality of associated actuators according to a preset scheduling rule.
For example, the preset scheduling rule may be a routing policy preset by the task scheduling platform, and the scheduler selects one executor to execute the target task based on the routing policy. For example, if the routing policy is "always the first executor executes the task", the scheduler schedules the executor a to execute the target task each time; if the routing strategy is 'polling execution', the dispatcher dispatches the executor A, the executor B, the executor C, the executor D and the executor E in turn according to the sequence to execute the target task; if the routing strategy is 'random execution', the scheduler randomly schedules one of the five executors to execute the target task; if the routing strategy is 'fault transfer', sequentially carrying out heartbeat detection according to the sequence, namely judging whether the five actuators are in a normal working state, if one actuator fails, transferring to the next actuator, and if the heartbeat detection is successful, selecting the actuator as a target actuator and initiating scheduling; and if the routing strategy is 'busy transfer', sequentially carrying out idle detection according to the sequence, if one executor is in a busy state, transferring to the next executor, and if the idle detection is successful, selecting the executor as a target executor and initiating scheduling.
It is to be understood that, in other embodiments, the routing policy is not limited to the routing policy mentioned in the above step, and the preset scheduling rule is not limited to the routing policy, and may also be a scheduling rule in other manners, which are not limited herein.
In the embodiment of the disclosure, the target executor is determined from the multiple executors according to the preset scheduling rule, so that the multiple executors can be prevented from generating conflict when executing the target task, and the scheduling efficiency is further improved.
Referring to fig. 4, which is a flowchart of another task scheduling method provided in the embodiment of the present disclosure, the task scheduling method includes the following steps S201 to S206:
s201, storing the related information to a second scheduler in the scheduler cluster.
Specifically, before the target task is determined to need to be executed, when the actuator is started, the associated information is randomly stored in a memory of any scheduler in the scheduler cluster, that is, a memory of the second scheduler, in advance, so that the scheduler which performs subsequent processing on the distributed lock can immediately read the associated information when executing the scheduling task.
S202, controlling the second scheduler to send the associated information to the coordinator cluster.
It can be understood that, in the step S201, the association information is stored in the memory of the second scheduler in the scheduler cluster, and in the process of acquiring the distributed lock, it is uncertain which scheduler will rob the lock, and in order to ensure that each scheduler can read the association information, the association information stored in the second scheduler needs to be synchronized to other schedulers, so that the synchronization of the association information of all schedulers is realized through the coordinator cluster, that is, the second scheduler sends the association information to the coordinator cluster.
S203, sending the associated information to other schedulers except the second scheduler in the scheduler cluster for storage through the coordinator cluster.
In the embodiment of the present disclosure, the coordinator cluster has a function of event notification in addition to a function of providing a distributed lock service, and can issue the received information to all nodes.
For example, the current scheduler cluster has three schedulers, namely a scheduler a, a scheduler B and a scheduler C, and the executor stores the associated information into the memory of the scheduler B, then the scheduler B sends the associated information to the coordinator cluster, and the coordinator cluster sends the associated information to the scheduler a and the scheduler C, and the scheduler a and the scheduler C respectively store the associated information into the memory.
S204, under the condition that the target task needs to be executed, controlling a plurality of schedulers in the scheduler cluster to respectively acquire the distributed locks from the coordinator cluster.
S205, reading the obtained associated information in the first scheduler of the distributed lock, and determining a target actuator from the actuator cluster according to the target task and the associated information.
S206, reading the obtained associated information in the first scheduler of the distributed lock, and determining a target actuator from the actuator cluster according to the target task and the associated information.
Steps S204 to S206 are similar to steps S101 to S103 in fig. 1, and are not described in detail here.
In the embodiment of the disclosure, the coordinator cluster stores the associated information into the memories of all schedulers of the scheduler cluster, instead of storing the associated information in the database in the existing algorithm, so that the scheduling efficiency is improved.
In some embodiments, when the task scheduling platform needs to add, modify, and delete a task, referring to fig. 5, a flowchart of a method for storing task change information is shown, which includes the following steps S301 to S303:
and S301, storing task change information to a third scheduler in the scheduler cluster when the task information is changed.
Specifically, in the case that a new task, a modification task, and a deletion task are required, similar to the step of storing the associated information in fig. 4, the task change information is randomly stored in the memory of any scheduler in the scheduler cluster, that is, the memory of the third scheduler. The third scheduler and the second scheduler in the method of fig. 4 are both any one scheduler in a scheduler cluster, and because the stored information is different, different names are defined for distinguishing, and the third scheduler and the second scheduler may be the same scheduler or different schedulers.
S302, controlling the third scheduler to send the task change information to the coordinator cluster.
This step is similar to S202, except that the associated information is changed into task change information, and is not described herein again.
And S303, sending the task change information to other schedulers except the third scheduler in the scheduler cluster for storage through the coordinator cluster.
Illustratively, such as the current scheduler cluster having three schedulers, scheduler D, scheduler E and scheduler F, the task scheduling platform will originally "18 per day: 00 statistics of sales data for the day "the task was changed to" 19: 00, counting sales data of the current day ", the executor stores the changed task change information into the memory of the scheduler D, then the scheduler D sends the task change information to the coordinator cluster, the coordinator cluster sends the task change information to the scheduler E and the scheduler F, and the scheduler E and the scheduler F respectively store the task change information into the memory.
In the embodiment of the disclosure, the task change information is stored in the memories of all the schedulers of the scheduler cluster through the coordinator cluster, so that the scheduling efficiency is improved.
It will be understood by those skilled in the art that in the method of the present invention, the order of writing the steps does not imply a strict order of execution and any limitations on the implementation, and the specific order of execution of the steps should be determined by their function and possible inherent logic.
Based on the same technical concept, a task scheduling device corresponding to the task scheduling method is also provided in the embodiments of the present disclosure, and because the principle of solving the problem of the device in the embodiments of the present disclosure is similar to the task scheduling method in the embodiments of the present disclosure, the implementation of the device may refer to the implementation of the method, and repeated details are not repeated.
Referring to fig. 6, a schematic structural diagram of a task scheduling apparatus provided in an embodiment of the present disclosure is shown, where the apparatus 500 includes:
an obtaining module 501, configured to control multiple schedulers in a scheduler cluster to obtain distributed locks from a coordinator cluster respectively under a condition that it is determined that a target task needs to be executed; the scheduler stores the associated information of the actuator cluster; the associated information comprises identity information of a plurality of actuators in the actuator cluster and task information required to be executed by each actuator;
a determining module 502, configured to read the obtained associated information in the first scheduler of the distributed lock, and determine a target actuator from the actuator cluster according to the target task and the associated information;
an executing module 503, configured to control the first scheduler to schedule the target executor to execute the target task.
In a possible embodiment, the identity information of the actuator includes an internet protocol address IP of the actuator and/or a name of the actuator; the task information comprises at least one of execution content of the task, execution time of the task and task identification number ID.
In a possible implementation, the determining module 502 is specifically configured to:
determining a plurality of associated actuators from the actuator cluster according to the target task and the associated information;
and determining the target actuator from the plurality of associated actuators according to a preset scheduling rule.
In a possible implementation manner, the obtaining module 501 is specifically configured to:
determining whether the target task needs to be executed or not based on preset task scheduling information; the task scheduling information comprises a preset time node, a preset time interval or a preset task scheduling frequency.
Referring to fig. 7, which is a schematic structural diagram of another task scheduling apparatus provided in an embodiment of the present disclosure, in a possible implementation manner, the apparatus 500 further includes:
a storage module 504 for storing the association information to a second scheduler in the scheduler cluster;
a first sending module 505, configured to control the second scheduler to send the association information to the coordinator cluster;
a second sending module 506, configured to send, by the coordinator cluster, the association information to other schedulers in the scheduler cluster except for the second scheduler for storage.
In a possible implementation, the storage module 504 is further configured to:
when the task information is changed, storing the task change information to a third scheduler in the scheduler cluster;
the first sending module 505 is further configured to:
controlling the third scheduler to send the task change information to the coordinator cluster;
the second sending module 506 is further configured to:
and sending the task change information to other schedulers except the third scheduler in the scheduler cluster for storage through the coordinator cluster.
According to a second aspect, in one possible implementation, the coordinator cluster comprises at least one zookeeper, at least one chubby, at least one redis, or at least one memcache.
The description of the processing flow of each module in the device and the interaction flow between the modules may refer to the related description in the above method embodiments, and will not be described in detail here.
Based on the same technical concept, the embodiment of the disclosure also provides an electronic device. Referring to fig. 7, a schematic structural diagram of an electronic device 700 provided in the embodiment of the present disclosure includes a processor 701, a memory 702, and a bus 703. The memory 702 is used for storing execution instructions and includes a memory 7021 and an external memory 7022; the memory 7021 is also referred to as an internal memory and temporarily stores operation data in the processor 701 and data exchanged with an external memory 7022 such as a hard disk, and the processor 701 exchanges data with the external memory 7022 via the memory 7021.
In this embodiment, the memory 702 is specifically configured to store application program codes for executing the scheme of the present application, and is controlled by the processor 701 to execute. That is, when the electronic device 700 is operated, the processor 701 and the memory 702 communicate with each other via the bus 703, so that the processor 701 executes the application program code stored in the memory 702 to perform the method disclosed in any of the foregoing embodiments.
The Memory 702 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Read-Only Memory (EPROM), an electrically Erasable Read-Only Memory (EEPROM), and the like.
The processor 701 may be an integrated circuit chip having signal processing capabilities. The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
It is to be understood that the illustrated structure of the embodiment of the present application does not specifically limit the electronic device 700. In other embodiments of the present application, the electronic device 700 may include more or fewer components than shown, or combine certain components, or split certain components, or a different arrangement of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
The embodiment of the present disclosure also provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program performs the task scheduling method in the above method embodiment. The storage medium may be a volatile or non-volatile computer-readable storage medium.
The embodiments of the present disclosure also provide a computer program product, where the computer program product carries a program code, and instructions included in the program code may be used to execute the task scheduling method in the foregoing method embodiments, which may be referred to specifically for the foregoing method embodiments, and are not described herein again.
The computer program product may be implemented by hardware, software or a combination thereof. In an alternative embodiment, the computer program product is embodied in a computer storage medium, and in another alternative embodiment, the computer program product is embodied in a Software product, such as a Software Development Kit (SDK), or the like.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, 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.
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 disclosure 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 functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present disclosure may be embodied in the form of a software product, which is stored in a storage medium and includes several 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 disclosure. 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.
Finally, it should be noted that: the above-mentioned embodiments are merely specific embodiments of the present disclosure, which are used for illustrating the technical solutions of the present disclosure and not for limiting the same, and the scope of the present disclosure is not limited thereto, and although the present disclosure is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive of the technical solutions described in the foregoing embodiments or equivalent technical features thereof within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present disclosure, and should be construed as being included therein. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.
Claims (10)
1. A method for task scheduling, comprising:
under the condition that the target task needs to be executed, controlling a plurality of schedulers in the scheduler cluster to respectively acquire distributed locks from the coordinator cluster; the scheduler stores the associated information of the actuator cluster; the associated information comprises identity information of a plurality of actuators in the actuator cluster and task information required to be executed by each actuator;
reading the association information in the first scheduler of the distributed lock, and determining a target actuator from the actuator cluster according to the target task and the association information;
and controlling the first scheduler to schedule the target executor to execute the target task.
2. The method of claim 1, wherein the identity information of the actuator comprises an internet protocol address, IP, of the actuator and/or a name of the actuator; the task information comprises at least one of execution content of the task, execution time of the task and task identification number ID.
3. The method of claim 1, wherein determining a target actuator from the actuator cluster based on the target task and the associated information comprises:
determining a plurality of associated actuators from the actuator cluster according to the target task and the associated information;
and determining the target actuator from the plurality of associated actuators according to a preset scheduling rule.
4. The method of claim 1, wherein determining that a target task needs to be performed comprises:
determining whether the target task needs to be executed or not based on preset task scheduling information; the task scheduling information comprises a preset time node, a preset time interval or a preset task scheduling frequency.
5. The method of claim 1, wherein prior to the determining that the target task needs to be performed, the method further comprises:
storing the association information to a second scheduler in the scheduler cluster;
controlling the second scheduler to send the association information to the coordinator cluster;
and sending the associated information to other schedulers except the second scheduler in the scheduler cluster for storage through the coordinator cluster.
6. The method of claim 1, further comprising:
when the task information is changed, storing the task change information to a third scheduler in the scheduler cluster;
controlling the third scheduler to send the task change information to the coordinator cluster;
and sending the task change information to other schedulers except the third scheduler in the scheduler cluster for storage through the coordinator cluster.
7. The method of claim 1, wherein the coordinator cluster comprises at least one zookeeper, at least one chubby, at least one redis, or at least one memcache.
8. A task scheduling apparatus, comprising:
the acquisition module is used for controlling a plurality of schedulers in the scheduler cluster to respectively acquire the distributed locks from the coordinator cluster under the condition that the target task needs to be executed; the scheduler stores the associated information of the actuator cluster; the associated information comprises identity information of a plurality of actuators in the actuator cluster and task information required to be executed by each actuator;
a determining module, configured to read the associated information in the first scheduler that obtains the distributed lock, and determine a target actuator from the actuator cluster according to the target task and the associated information;
and the execution module is used for controlling the first scheduler to schedule the target executor to execute the target task.
9. An electronic device, comprising: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating via the bus when the electronic device is operating, the machine-readable instructions when executed by the processor performing the task scheduling method of any one of claims 1 to 7.
10. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out a method of task scheduling according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111106267.5A CN113778652A (en) | 2021-09-22 | 2021-09-22 | Task scheduling method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111106267.5A CN113778652A (en) | 2021-09-22 | 2021-09-22 | Task scheduling method and device, electronic equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113778652A true CN113778652A (en) | 2021-12-10 |
Family
ID=78852396
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111106267.5A Pending CN113778652A (en) | 2021-09-22 | 2021-09-22 | Task scheduling method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113778652A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115809133A (en) * | 2022-12-13 | 2023-03-17 | 北京领雁科技股份有限公司 | Distributed scheduling system, method, electronic device, and computer-readable medium |
CN116185044A (en) * | 2023-04-26 | 2023-05-30 | 威康(深圳)智能有限公司 | Control method, device, equipment and system of robot cluster system |
TWI821033B (en) * | 2022-10-26 | 2023-11-01 | 大陸商鼎捷軟件股份有限公司 | Related data automatic processing system and method thereof |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2017167398A1 (en) * | 2016-04-01 | 2017-10-05 | Intel Corporation | Method and apparatus for time and event aligned multilayer multiagent performance monitoring |
CN110018893A (en) * | 2019-03-12 | 2019-07-16 | 平安普惠企业管理有限公司 | A kind of method for scheduling task and relevant device based on data processing |
CN111163145A (en) * | 2019-12-23 | 2020-05-15 | 北京数衍科技有限公司 | Distributed data timing and uniform sending method and device and electronic equipment |
CN112380183A (en) * | 2020-11-13 | 2021-02-19 | 深圳市和讯华谷信息技术有限公司 | Distributed file synchronization method and device, computer equipment and storage medium |
CN113032125A (en) * | 2021-04-02 | 2021-06-25 | 京东数字科技控股股份有限公司 | Job scheduling method, device, computer system and computer-readable storage medium |
-
2021
- 2021-09-22 CN CN202111106267.5A patent/CN113778652A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2017167398A1 (en) * | 2016-04-01 | 2017-10-05 | Intel Corporation | Method and apparatus for time and event aligned multilayer multiagent performance monitoring |
CN110018893A (en) * | 2019-03-12 | 2019-07-16 | 平安普惠企业管理有限公司 | A kind of method for scheduling task and relevant device based on data processing |
CN111163145A (en) * | 2019-12-23 | 2020-05-15 | 北京数衍科技有限公司 | Distributed data timing and uniform sending method and device and electronic equipment |
CN112380183A (en) * | 2020-11-13 | 2021-02-19 | 深圳市和讯华谷信息技术有限公司 | Distributed file synchronization method and device, computer equipment and storage medium |
CN113032125A (en) * | 2021-04-02 | 2021-06-25 | 京东数字科技控股股份有限公司 | Job scheduling method, device, computer system and computer-readable storage medium |
Non-Patent Citations (1)
Title |
---|
江显群等: "农业痕量灌溉关键技术研究", 31 August 2020, 海洋出版社, pages: 45 - 46 * |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TWI821033B (en) * | 2022-10-26 | 2023-11-01 | 大陸商鼎捷軟件股份有限公司 | Related data automatic processing system and method thereof |
CN115809133A (en) * | 2022-12-13 | 2023-03-17 | 北京领雁科技股份有限公司 | Distributed scheduling system, method, electronic device, and computer-readable medium |
CN116185044A (en) * | 2023-04-26 | 2023-05-30 | 威康(深圳)智能有限公司 | Control method, device, equipment and system of robot cluster system |
CN116185044B (en) * | 2023-04-26 | 2023-06-27 | 威康(深圳)智能有限公司 | Control method, device, equipment and system of robot cluster system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113778652A (en) | Task scheduling method and device, electronic equipment and storage medium | |
US20210203751A1 (en) | Methods, systems, and devices for electronic note identifier allocation and electronic note generation | |
CN108776934B (en) | Distributed data calculation method and device, computer equipment and readable storage medium | |
CN111522641B (en) | Task scheduling method, device, computer equipment and storage medium | |
CN107392623B (en) | Service execution method and device | |
CN110069346B (en) | Method and device for sharing resources among multiple processes and electronic equipment | |
CN110008031B (en) | Device operation method, cluster system, electronic device and readable storage medium | |
CN109152061B (en) | Channel allocation method, device, server and storage medium | |
CN111698315B (en) | Data processing method and device for block and computer equipment | |
CN110543448A (en) | data synchronization method, device, equipment and computer readable storage medium | |
CN112261115B (en) | Resource allocation method, device and computer storage medium | |
CN111767128A (en) | Method and device for executing timing task | |
CN109218385B (en) | Method and device for processing data | |
CN111784318A (en) | Data processing method and device, electronic equipment and storage medium | |
CN108833584B (en) | Message pushing method, terminal, server and computer storage medium | |
CN113886069A (en) | Resource allocation method and device, electronic equipment and storage medium | |
CN114237852A (en) | Task scheduling method, device, server and storage medium | |
CN114048033A (en) | Load balancing method and device for batch running task and computer equipment | |
CN115757611A (en) | Big data cluster switching method and device, electronic equipment and storage medium | |
CN113946427A (en) | Task processing method, processor and storage medium for multi-operating system | |
CN112685157B (en) | Task processing method, device, computer equipment and storage medium | |
CN111857995B (en) | Process scheduling method and device, storage medium and electronic device | |
CN111737274A (en) | Transaction data processing method and device and server | |
US20150120607A1 (en) | System and method for customer event email consolidation and delivery | |
CN110290215B (en) | Signal transmission method and device |
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 |