Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the subject matter of the present disclosure can be practiced without one or more of the specific details, or with other methods, components, devices, steps, and so forth. In other instances, well-known methods, devices, implementations, or operations have not been shown or described in detail to avoid obscuring aspects of the disclosure.
The block diagrams shown in the figures are functional entities only and do not necessarily correspond to physically separate entities. I.e. these functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor means and/or microcontroller means.
The flow charts shown in the drawings are merely illustrative and do not necessarily include all of the contents and operations/steps, nor do they necessarily have to be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
Fig. 1 shows a schematic diagram of an exemplary system architecture to which the technical solutions of the embodiments of the present disclosure may be applied.
As shown in fig. 1, system architecture 100 may include a task management front end 101, a network 102, and a task management back end 103. The network 102 is used to provide a medium for a communication link between the task management front-end 101 and the task management back-end 103. Network 102 may include various connection types, such as wired communication links, wireless communication links, and so forth.
It should be understood that the number of task management front-ends, networks, and task management back-ends in FIG. 1 is merely illustrative. There may be any number of task management front ends, networks, and task management back ends, as desired. For example, the task management back end 103 may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a network service, cloud communication, a middleware service, a domain name service, a security service, a CDN, a big data and artificial intelligence platform, and the like. The task management front-end 101 may be a terminal device such as, but not limited to, a laptop, a tablet, a desktop computer, etc.
In one embodiment of the present disclosure, a user may enter task information in the task management front end 101 or send a task progress query request through the task management front end 101, and the task information and the task progress query request are sent to the task management back end 103 through the network 102. The task management back end 103 comprises a task management server, a task scheduling server and a task execution server, wherein the task scheduling server comprises a plurality of task scheduling services for managing and scheduling tasks of users; the task execution server comprises a plurality of task execution services for executing the received tasks of the user. After receiving the task issued by the task management front end 101, the task management server issues the task to the task scheduling server, schedules the task by the plurality of task scheduling services, and invokes the corresponding task execution service to execute each task. In the process of scheduling tasks by the task scheduling service, if a certain task scheduling service fails, the task scheduled by the failed task scheduling service can be taken over by the task scheduling service which does not fail based on the distributed coordination service system, so that the task is ensured not to be lost. In addition, when the task management server issues the tasks to the task scheduling server, the weight of the issued tasks can be dynamically adjusted according to the task amount in the task queue corresponding to each task scheduling service, and the tasks are guaranteed to be evenly distributed to each task scheduling service. According to the technical scheme of the embodiment of the invention, a plurality of task scheduling services and nodes corresponding to the task scheduling services can be arranged in the task management system to form the distributed task management system, a plurality of tasks can be executed in the distributed task management system at the same time, and the task execution efficiency is improved.
It should be noted that the task management method provided by the embodiment of the present disclosure is generally executed by a server, and accordingly, the task management device is generally disposed in the server. However, in other embodiments of the present disclosure, the task management method provided in the embodiments of the present disclosure may also be executed by a terminal device.
In the related art in the field, fig. 2 shows an architecture diagram of a conventional task management system, as shown in fig. 2, the conventional task management system includes a console 201, a task management server 202, a task execution server 203, and a database 204, and a specific task execution flow is as follows: a user issues a task to the task management server 202 through the console 201; the task management server 202 stores the task information in the database 204, and simultaneously issues the task to the task execution server 203; after receiving the task, the task execution server 203 starts to execute the task, and periodically updates the task execution progress to the database 204; the user sends a task progress query request to the task management server 202 through the console 201, and the task management server 202 responds to the task progress query request and displays the task execution state in the database 204 to the console 201 in real time for the user to browse.
However, the conventional task management system has a simple architecture, and is suitable for processing an atomic task, and if one task is composed of a plurality of sequential subtasks, and the subtasks are executed by a plurality of different task execution services, in order to make the task management system have high availability, the task management service needs to be set as a plurality of nodes, and the tasks are managed by different nodes. But there are problems accordingly, such as how to coordinate the assignment of tasks among the nodes, how to handle the tasks of a node when the node fails, and the like.
In view of the problems in the related art, the embodiments of the present disclosure provide a task management method, which is based on a Cloud technology, and the Cloud technology (Cloud technology) is based on a generic term of a network technology, an information technology, an integration technology, a management platform technology, an application technology, and the like applied in a Cloud computing business model, and can form a resource pool, be used as needed, and be flexible and convenient. Cloud computing technology will become an important support. Background services of the technical network system require a large amount of computing and storage resources, such as video websites, picture-like websites and more web portals. With the high development and application of the internet industry, each article may have its own identification mark and needs to be transmitted to a background system for logic processing, data in different levels are processed separately, and various industrial data need strong system background support and can only be realized through cloud computing.
Cloud computing (cloud computing) is a computing model that distributes computing tasks over a pool of resources formed by a large number of computers, enabling various application systems to obtain computing power, storage space, and information services as needed. The network that provides the resources is referred to as the "cloud". Resources in the "cloud" appear to the user as being infinitely expandable and available at any time, available on demand, expandable at any time, and paid for on-demand.
As a basic capability provider of cloud computing, a cloud computing resource pool (called as an ifas (Infrastructure as a Service) platform for short is established, and multiple types of virtual resources are deployed in the resource pool and are selectively used by external clients.
According to the logic function division, a PaaS (Platform as a Service) layer can be deployed on an IaaS (Infrastructure as a Service) layer, a SaaS (Software as a Service) layer is deployed on the PaaS layer, and the SaaS can be directly deployed on the IaaS. PaaS is a platform on which software runs, such as a database, a web container, etc. SaaS is a variety of business software, such as web portal, sms, and mass texting. Generally speaking, SaaS and PaaS are upper layers relative to IaaS.
Cloud processing is generally applied to the field of Big data, Big data (Big data) refers to a data set which cannot be captured, managed and processed by a conventional software tool within a certain time range, and is a massive, high-growth-rate and diversified information asset which can have stronger decision-making power, insight discovery power and flow optimization capability only by a new processing mode. With the advent of the cloud era, big data has attracted more and more attention, and the big data needs special technology to effectively process a large amount of data within a tolerance elapsed time. The method is suitable for the technology of big data, and comprises a large-scale parallel processing database, data mining, a distributed file system, a distributed database, a cloud computing platform, the Internet and an extensible storage system.
The disclosed embodiment provides a task management method first, and fig. 3 schematically shows a flowchart of the task management method according to an embodiment of the present disclosure, where the task management method may be executed by a task management front end and a task management back end, and specifically may be executed by a terminal device and a server, and in addition, the task management method is applied to a distributed task management system, where the distributed task management system includes a task scheduling server and nodes corresponding to a plurality of task scheduling services in the task scheduling server, where the task scheduling services are used to manage and schedule tasks of users. Referring to fig. 3, the task management method at least includes steps S310 to S330, which are described in detail as follows:
in step S310, each task scheduling service listens to a parent node corresponding to the node.
In an embodiment of the present disclosure, the task management system is a distributed task management system, and the distributed task management system includes a task scheduling server, where the task scheduling server includes a plurality of task scheduling services, the plurality of task scheduling services form a task scheduling cluster, and each task scheduling service is registered in the distributed coordination service system to form a node. Fig. 4 shows a schematic architecture diagram of a distributed task management system, as shown in fig. 4, a distributed task management system 400 includes a console 401, a task management server 402, a task scheduling server 403, a task execution server 404, and a data storage device 405, where the console 401 may specifically be a Web console, and is configured to respond to a trigger operation of a user to generate a task issuing instruction or a task progress query request, that is, the user may perform operations such as task issuing, task status monitoring, and task execution result query through the console; the task management server 402 is also called a task management background, serves a background of the console 401, is connected to the console 401, and is configured to issue a task in response to a task issuing instruction sent by the console 401 or to respond to a task progress query request sent by the console 401 to feed back task progress information to the console 401; the task scheduling server 403 is connected to the task management server 402, and includes a task scheduling service cluster, where the task scheduling service cluster includes a plurality of task scheduling services, where each task scheduling service is registered in a distributed coordination service framework to form a node, and each task scheduling service receives a task issued by the task management device 402 and is responsible for scheduling the whole life cycle of the task, and in addition, the task scheduling server 403 may also update the task execution progress to the data storage device 405 in real time; the task execution server 404 is connected to the task scheduling server 403, and includes a task execution service cluster, where the task execution service cluster includes a plurality of task execution services, each task execution service is an atomic computation task execution service, receives a sub-task execution request submitted by the task scheduling service, and executes a corresponding computation task; the data storage device 405 may be a hard disk or other media that can be used to store data, and is used to store data submitted by the task management server 402 and the task scheduling server 403. In the embodiment of the present disclosure, each task execution service has a different task type tag, a user may mark the type of each task when entering the task through the console 401, and when receiving the task, the task execution server 404 may match the type of the task with the task type tag of the task execution service to determine a task execution service matched therewith, and execute the task through the matched task execution service.
In an embodiment of the present disclosure, the task management server 402, the task scheduling server 403, and the task execution server 404 may be the same server or different servers, which is not specifically limited in this embodiment of the present disclosure.
In an embodiment of the present disclosure, the distributed task management system is constructed based on a distributed coordination service system, and nodes corresponding to each task scheduling service are formed by registering each task scheduling service in the distributed coordination service system, where each node corresponds to a different node number. In the embodiment of the present disclosure, the distributed coordination service system may specifically be a zookeeper, which is a sub-item of Apache Hadoop and is mainly used to solve some data management problems often encountered in distributed applications, such as: unified naming services, state synchronization services, cluster management, management of distributed application configuration items, and the like. The zookeeper has an event monitoring function, which allows a user to register some monitors on a designated node, and when some specific event is triggered, the zookeeper server will notify the interested client of the event. The structure of the zookeeper data model can be regarded as a tree as a whole, each node is referred to as a Znode, fig. 5 shows a distribution architecture diagram among task scheduling services in the distributed task management system, as shown in fig. 5, N task scheduling services Broker1, Broker2, … … and Broker N exist in the distributed task management system, each task scheduling service is registered in the zookeeper to form nodes corresponding to the respective task scheduling services, the nodes are/Broker/1,/Broker/2, … … and/Broker/N, and the nodes are child nodes of the nodes/brokers, that is, the/brokers is a parent node of the node corresponding to the respective task scheduling services. After the tree structure is formed, each task scheduling service can register a listener on a node of the task scheduling service to monitor a parent node/brokers, and when information in the parent node or a child node changes, a zookeeper can notify the change information to each task scheduling service.
In an embodiment of the present disclosure, the information of the task scheduling service and the corresponding node thereof may be stored in a database, that is, the data storage device 405, so that the task management server 402 can obtain the relevant information from the information, and in addition, when the task scheduling service updates the task progress, the node number of the task scheduling service itself may also be updated into the data storage device 405, as shown in fig. 6, a schematic structural diagram of the task information stored in the data storage device is shown, as shown in fig. 6, where there are a plurality of tasks, each task has a corresponding task ID, a task state, a task scheduling service identifier of the task scheduling service, and other information, for example, a task whose task ID is 1 corresponds to a task state of Step1, and a task scheduling service identifier of the task scheduling service is 1; the task state corresponding to the task with the task ID of 2 is Step2, and the task scheduling service of the task scheduling service is 2; the task state corresponding to the task with the task ID of 3 is Complete, and the task scheduling service of the task scheduling service is N. It should be noted that the task ID, the task status and the task scheduling service identifier may also be in other representations, including but not limited to the above examples, and the disclosed embodiments are not limited thereto.
In an embodiment of the present disclosure, when a task scheduling service is hung up due to a fault, a node of the faulty task scheduling service is automatically deleted, and a corresponding task may not be smoothly executed, thereby causing a task execution failure and reducing user experience.
In step S320, when it is monitored that there is a deleted first node in the nodes, a second node corresponding to the first node is created through a target task scheduling service, where the target task scheduling service corresponding to the second node is different from the task scheduling service corresponding to the first node.
In an embodiment of the present disclosure, in order to ensure that all tasks can be executed smoothly, when there is a task scheduling service suspended due to a failure, the task scheduling service working normally can take over its corresponding tasks, and execute all tasks in the task queue in sequence. The specific process of taking over the tasks of the task scheduling service which is hung up due to the fault comprises the following steps: when the deleted first node exists in the nodes, determining a target task scheduling service by the competition of other task scheduling services except the suspended task scheduling service; a second node corresponding to the first node is then created in the zookeeper by the target task scheduling service. The method for determining the target task scheduling service uniquely from the plurality of competing task scheduling services is a characteristic of zookeeper, and as to how to determine the target task scheduling service in a competing manner, details of the embodiment of the disclosure are not repeated herein. Fig. 7 shows a relationship diagram between task scheduling services when the task scheduling services fail, and as shown in fig. 7, the task scheduling service numbered/brokers/2 fails and hangs up, so the node numbered/brokers/2 is deleted. Then a new node may be registered by the target task scheduling service to generate a new node corresponding to the node numbered/brokers/2.
In an embodiment of the present disclosure, the number of the first node and the number of the second node may not be exactly the same, for example, the number of the second node may be set to/brokers/N-r, for example, if the task scheduling service corresponding to the node numbered/brokers/2 fails and is hung up, the node is deleted, then the target task scheduling service may take over the task of the task scheduling service, and register the node corresponding to/brokers/2 on the zookeeper, and the number of the newly registered node may be set to/brokers/2-r; the number of the second node may also be set in other forms based on the number of the first node, and of course, the number of the first node and the number of the second node may also be set in completely different forms, which is not specifically limited by the embodiment of the present disclosure.
In step S330, the target task scheduling service obtains task information corresponding to the first node from a database, and adds the task information to a task queue corresponding to the target task scheduling service.
In one embodiment of the present disclosure, after the second node corresponding to the first node is successfully created, task information corresponding to the first node may be acquired from the data storage device 405 through the target task scheduling service, and the task information is added to a task queue corresponding to the target task scheduling service. In the embodiment of the present disclosure, each task scheduling service corresponds to one task queue, and after receiving the task issued by the task management server 402, each task scheduling service may add the received task to the corresponding task queue, which may improve task processing efficiency and ensure high availability of the task processing system.
Further, after the task information is added to the task queue corresponding to the target task scheduling service, the task scheduling service identifier corresponding to the task information in the data storage device 405 may also be modified to the task scheduling service identifier corresponding to the target task scheduling service.
Continuing with the example in step S320, when other task scheduling services monitor that the node numbered/brokers/2 is deleted, a new node corresponding to the node numbered/brokers/2 is created in a competitive manner, and after the node numbered/brokers/2-r is successfully created, the target task scheduling service may obtain all task information of the Broker2 from the database, place the task information into its own task queue, and modify the task scheduling service identifier corresponding to the task information in the data storage device to the task scheduling service identifier corresponding to the target task scheduling service. FIG. 8 is a diagram illustrating the relationship between task scheduling services after task recovery, and as shown in FIG. 8, the task scheduling service Broker1 is a target task scheduling service determined after competition, and registers in the zookeeper to form a new node, which is numbered/brokers/2-r and corresponds to the deleted node numbered/brokers/2. Meanwhile, fig. 9 shows a schematic structural diagram of the recovered task information stored in the data storage device, and as shown in fig. 9, the task states corresponding to the tasks with the original task IDs of 1 and 3 both become Running, the task scheduling service identifier of the task scheduling service is not changed, the task state corresponding to the task with the original task ID of 2 becomes Running, and the task scheduling service identifier of the task scheduling service is changed from 2 to 1.
In an embodiment of the present disclosure, information such as task state information and a task scheduling service identifier corresponding to a task is updated to the data storage device at regular time, in addition, a new task scheduling service may be further created, and a corresponding node is registered in the zookeeper, and the task scheduling service identifier corresponding to the new task scheduling service and corresponding node information are also updated to the data storage device for the task management server to obtain.
In an embodiment of the present disclosure, based on the system architecture diagram of the distributed task management system shown in fig. 4, the task management server 402 may issue the to-be-executed task sent by the user to each task scheduling service in the task scheduling server 403, and after receiving the to-be-executed task sent by the task management server 402, the task scheduling service may form a task execution request according to the to-be-executed task, and then send the task execution request to a corresponding task execution service in the task execution server 404, so that the task execution service executes the task.
In an embodiment of the present disclosure, the execution flow of each task scheduling service is the same, and in order to make the technical solution of the present disclosure clearer, the following describes the execution flow of the task scheduling service by taking one task scheduling service as an example.
Fig. 10 is a schematic diagram illustrating an execution flow of a task scheduling service, and as shown in fig. 10, in step S1001, a task to be executed is added to a task queue corresponding to the task scheduling service, and it is determined whether an idle thread exists in a thread pool of the task scheduling service; in step S1002, when there is an idle thread, pulling a task to be executed from a task queue corresponding to the task scheduling service, and acquiring a subtask in the task to be executed; in step S1003, it is determined whether the subtask is a subtask to be executed; in step S1004, when it is determined that the subtask is a subtask to be executed, a task execution request is formed according to the subtask to be executed; in step S1005, matching the task type of the task to be executed in the task execution request with the task type tag to determine a target task execution service; in step S1006, a task execution request is sent to the target task execution service to cause the target task execution service to execute the task; in step S1007, it is queried whether the execution of the subtask to be executed is completed; in step S1008, if the execution of the to-be-executed subtask is completed, updating task progress information corresponding to the to-be-executed task in the database; in step S1009, if the execution of the to-be-executed subtask is not completed, the to-be-executed task is added to the task queue corresponding to the task scheduling service again; in step S1010, it is determined whether there is an unexecuted subtask in the task to be executed; in step S1011, if the task exists, the unexecuted subtask is executed when the unexecuted subtask is the to-be-executed subtask, until the unexecuted subtask does not exist in the to-be-executed task; in step S1012, if not, the task state information corresponding to the task to be executed in the data storage device is updated.
Before step S1001, after receiving the to-be-executed task, the task scheduling service may put the to-be-executed task into a task queue corresponding to the task scheduling service, where the to-be-executed tasks in the task queue may be sorted according to the sequence of the receiving time, the to-be-executed task with the earlier receiving time may be located at the front end of the task queue, and the to-be-executed task with the later receiving time may be located at the rear end of the task queue. In step S1003, after the idle thread in the task scheduling service acquires a scheduled to-be-executed task, the task scheduling service needs to acquire attribute information of the subtasks because the to-be-executed task includes a plurality of subtasks, and then forms a task execution request according to the attribute information of the subtasks and the subtasks, acquiring the attribute information of the subtasks specifically includes determining whether the pulled to-be-executed task includes a plurality of subtasks and whether the subtasks are to-be-executed subtasks, for example, a to-be-executed task includes 5 sequentially arranged subtasks, which are respectively No. 1, No. 2, No. 3, No. 4, and No. 5 subtasks, acquiring an execution state of the subtask when the task scheduling service pulls the subtask No. 1, and determining whether the to-be-executed subtask is according to the execution state of the subtask, for example, the subtask No. 1 and the subtask No. 2 in the to-be-executed tasks are, when the query of whether the execution of the subtask 2 is completed is finished, the task to be executed is put into the task queue again when the query result indicates that the execution is not completed, so that the execution state of the subtask 1 acquired by the task scheduling service is that the subtask 1 is executed, and accordingly, the subtask 1 is not the subtask to be executed, and then the execution states of the remaining subtasks can be sequentially judged to determine whether the subtasks are the subtasks to be executed. In step S1007, the query of the execution status of the to-be-executed subtask may be performed at a preset time point, for example, the query is performed immediately after the task execution service receives and executes the to-be-executed subtask, the query is performed at the executed 3S and 5S, and the like, and if the to-be-executed subtask execution status queried at the preset time point is that the execution is not completed, the to-be-executed task is placed back to the tail of the task queue for sorting. In Step S1008, the task progress information is the execution progress of the subtasks to be executed, for example, Step1, Step2, Running, etc. in fig. 5 and fig. 9 are all execution progress, so as to identify where the subtasks to be executed are executed; in step S1012, the task state information is the execution result of the task to be executed, such as Complete in fig. 5, and indicates that the task to be executed is completed, but other indications may also be used, such as successful execution, waiting for re-execution, and the like.
In one embodiment of the present disclosure, after the execution of the entire to-be-executed task is completed, the task execution result, i.e., the task state information, is updated to the data management device 405, and then the steps S1001 to S1012 are repeatedly performed to execute other to-be-executed tasks in the task queue.
In an embodiment of the disclosure, the task management server issues the tasks to the task scheduling services in the task scheduling server, and in order to ensure balanced distribution of the tasks, avoid that some task scheduling services have too high load and some task scheduling services have too low load, the task issuing amount of each task scheduling service can be dynamically adjusted according to the task amount corresponding to the task scheduling service. In order to obtain the task quantity corresponding to each task scheduling service, the task quantity in the node corresponding to each task scheduling service can be periodically updated according to the task quantity in each task queue through each task scheduling service, then the task management server can obtain the task quantity of all the nodes from zookeeper, determines task distribution weight according to the task quantity, and further executes task distribution based on the task distribution weight. For example, the task scheduling service cluster includes three task scheduling services A, B, C, the number of tasks stored in the node corresponding to the task scheduling service a is 10, the number of tasks stored in the node corresponding to the task scheduling service B is 5, and the number of tasks stored in the node corresponding to the task scheduling service C is 15, so that it can be determined that the task allocation weight corresponding to the task scheduling service B is the largest, the task allocation weight corresponding to the task scheduling service a is the second to the smallest, the specific task allocation weights are 5/12, 1/3 and 1/4, if the task management background needs to issue 60 to-be-executed tasks, 25 tasks can be allocated to the task scheduling service B, 20 tasks are allocated to the task scheduling service a, and 15 tasks are allocated to the task scheduling service C, so that it can be ensured that the task scheduling service a, B, C, and C are equal to 5/12, The number of tasks in the task scheduling service B and the task scheduling service C is 30, and balance of task allocation is guaranteed.
In an embodiment of the present disclosure, only the console 401 can be touched by the user, and the internal details of the distributed task management system 400 are invisible to the user, so that the user can only perform different triggering operations on the console to perform task issuing, task status monitoring, task execution result query, and the like. Specifically, the console 401 may enter a task to be executed in response to a first trigger operation of the user; or, the console 401 may generate a task progress query request in response to the second trigger operation of the user, and send the task progress query request to the task management server 402, and after receiving the task progress query request, the task management server 402 may obtain a task state of a task corresponding to a task ID in the task progress query request from the data storage device 405, and feed back and display the task state in a display interface of the console, so as to facilitate browsing by the user.
The task management method in the embodiment of the disclosure can be applied to a plurality of scenarios, in particular to computing tasks requiring longer execution time, such as offline speech recognition, big data statistics tasks, machine learning model training, and the like.
Taking a big data statistics task as an example, assuming that one task is to push advertisements to foreign visitors in a scenic spot, firstly, people in the scenic spot can be obtained, and specifically, the composition of people in the scenic spot, namely the visitors contained in the people, can be determined according to geographic coordinate data submitted by positioning equipment carried by the visitors and stored in a database; then, according to the information such as the page which is clicked and browsed recently by each tourist, the chat content, the position sharing information and the like, judging which tourists are the foreign tourists; then, aiming at the tourists identified as foreign tourists, constructing a user portrait according to the user information, browsing information and other information; finally, related advertisements can be pushed to each tourist based on the user image of each tourist, for example, if some users frequently browse a train and air ticket booking platform, advertisement information of the train and the air ticket can be pushed to the user, and if some users frequently browse a food recommendation platform, food advertisements can be pushed to the user, and the like. In the process of pushing the advertisement, three subtasks exist, wherein the first subtask is used for screening crowd data, the second subtask is used for constructing a user portrait of a foreign tourist, the third subtask is used for advertising based on the user portrait, and the three subtasks are different in type. When the task management system performs task management, even if part of the three subtasks are executed completely and the execution of part of the subtasks is not completed, only the incomplete subtasks can be executed when the task is executed repeatedly, the completed subtasks do not need to be executed repeatedly, and the task execution efficiency is improved.
In an embodiment of the present disclosure, the task management system is a distributed task management system, which can schedule a plurality of tasks through the task scheduling server, wherein each task scheduling service can completely schedule the whole life cycle of the plurality of tasks, thereby ensuring high availability of the task management system.
According to the task management method in the embodiment of the disclosure, the task management system is combined with the distributed coordination service system, the task management system is provided with a plurality of task scheduling services, each task scheduling service is registered in the distributed coordination service system to form a node, and then the multi-node distributed task management system is formed, each task scheduling service in the distributed task management system can completely schedule the whole life cycle of a plurality of tasks, when a fault occurs in an individual task scheduling service and is hung, other task scheduling services which normally work can compete to take over the corresponding task of the task scheduling service which has the fault and is hung, service self-registration and fault self-healing are realized, the task is ensured not to be lost, and the normal service of the whole distributed task management system is ensured. Meanwhile, a plurality of task scheduling services and a plurality of task execution services exist in the distributed task management system, and different task execution services can execute different tasks, so that the task execution efficiency is improved; in addition, the weighted task issuing of the distributed task management system can balance the load of each task scheduling service, prevent the task scheduling service fault caused by overhigh load of the individual task scheduling service, and further ensure the normal service of the distributed task management system.
The following describes an embodiment of an apparatus of the present disclosure, which may be used to perform the task management method in the foregoing embodiment of the present disclosure. For details that are not disclosed in the embodiments of the apparatus of the present disclosure, please refer to the task management method described above in the present disclosure.
FIG. 11 schematically shows a block diagram of a task management device according to one embodiment of the present disclosure.
Referring to fig. 11, a task management apparatus 1100 according to an embodiment of the present disclosure is applied to a distributed task management system including a task scheduling server and nodes corresponding to a plurality of task scheduling services in the task scheduling server, where the task scheduling services are used for managing and scheduling tasks of a user; the task management device 1100 includes: a listening module 1101, a node creation module 1102 and a task takeover module 1103.
The monitoring module 1101 is configured to monitor, by each task scheduling service, a parent node corresponding to the node; a node creating module 1102, configured to create, when it is monitored that a deleted first node exists in the nodes, a second node corresponding to the first node through a target task scheduling service, where the target task scheduling service corresponding to the second node is different from a task scheduling service corresponding to the first node; a task taking-over module 1103, configured to obtain, by the target task scheduling service, task information corresponding to the first node from a database, and add the task information to a task queue corresponding to the target task scheduling service.
In an embodiment of the present disclosure, the task management device 1100 further includes: and the registration module is used for registering in the distributed coordination service system through each task scheduling service so as to obtain nodes with different node numbers corresponding to each task scheduling service.
In an embodiment of the present disclosure, the task management device 1100 further includes: and the identification modification module is used for modifying the task scheduling service identification corresponding to the task information into the task scheduling service identification corresponding to the target task scheduling service.
In one embodiment of the present disclosure, the distributed task management system further includes a task management server and a task execution server; the task management device 1100 further includes: the request generation module is used for receiving the tasks to be executed sent by the task management server through the task scheduling server and forming task execution requests according to the tasks to be executed; and the task execution module is used for sending the task execution request to the task execution server so as to enable the task execution service in the task execution server to execute the task.
In one embodiment of the present disclosure, the request generation module includes: the task adding unit is used for adding the task to be executed to a task queue corresponding to the task scheduling service and judging whether an idle thread exists in a thread pool of the task scheduling service or not; the task pulling unit is used for pulling the task to be executed from the task queue corresponding to the task scheduling service and acquiring a subtask in the task to be executed when the idle thread exists; and the request generating unit is used for forming the task execution request according to the attribute information of the subtask and the subtask.
In one embodiment of the present disclosure, the request generation unit is configured to: judging whether the subtask is a subtask to be executed; and when the subtask is judged to be the subtask to be executed, forming the task execution request according to the subtask to be executed.
In one embodiment of the present disclosure, the number of the task execution services is multiple, and each of the task execution services has a different task type tag; the task execution module is configured to: matching the task type of the task to be executed in the task execution request with the task type label to determine a target task execution service; and sending the task execution request to the target task execution service so that the target task execution service executes the task.
In one embodiment of the present disclosure, the task management device 1100 is further configured to: inquiring whether the sub task to be executed is executed or not; if the execution of the subtask to be executed is completed, updating task progress information corresponding to the task to be executed in the database; and if the execution of the subtasks to be executed is not finished, adding the tasks to be executed into the task queues corresponding to the task scheduling services again.
In one embodiment of the present disclosure, the task management device 1100 is further configured to: judging whether the tasks to be executed have unexecuted subtasks or not; if the task exists, the unexecuted subtask is executed when the unexecuted subtask is a subtask to be executed until the unexecuted subtask does not exist in the task to be executed; and if not, updating the task state information corresponding to the task to be executed in the database.
In one embodiment of the present disclosure, the task management device 1100 is further configured to: each task scheduling service updates the task quantity in the node according to the task quantity in the task queue corresponding to each task scheduling service; and the task management server acquires the task quantity from each node, determines task distribution weight according to the task quantity, and executes task distribution based on the task distribution weight.
In one embodiment of the present disclosure, the distributed task management system further comprises a console; the task management device 1100 is further configured to: the console responds to a first trigger operation of a user to enter the task to be executed; or the console responds to a second trigger operation of the user to generate a task progress query request, and sends the task progress query request to the task management server to obtain task progress information.
FIG. 12 illustrates a schematic structural diagram of a computer system suitable for use in implementing the electronic device of an embodiment of the present disclosure.
It should be noted that the computer system 1200 of the electronic device shown in fig. 12 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 12, the computer system 1200 includes a Central Processing Unit (CPU)1201, which can perform various appropriate actions and processes according to a program stored in a Read-Only Memory (ROM) 1202 or a program loaded from a storage section 1208 into a Random Access Memory (RAM) 1203, and implements the image labeling method described in the above-described embodiment. In the RAM1203, various programs and data necessary for system operation are also stored. The CPU 1201, ROM 1202, and RAM1203 are connected to each other by a bus 1204. An Input/Output (I/O) interface 1205 is also connected to bus 1204.
The following components are connected to the I/O interface 1205: an input section 1206 including a keyboard, a mouse, and the like; an output section 1207 including a Display device such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and a speaker; a storage section 1208 including a hard disk and the like; and a communication section 1209 including a network interface card such as a LAN (Local area network) card, a modem, or the like. The communication section 1209 performs communication processing via a network such as the internet. A driver 1210 is also connected to the I/O interface 1205 as needed. A removable medium 1211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like, is mounted on the drive 1210 as necessary, so that a computer program read out therefrom is mounted into the storage section 1208 as necessary.
In particular, the processes described below with reference to the flowcharts may be implemented as computer software programs, according to embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 1209, and/or installed from the removable medium 1211. The computer program, when executed by a Central Processing Unit (CPU)1201, performs various functions defined in the system of the present disclosure.
It should be noted that the computer readable medium shown in the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a Read-Only Memory (ROM), an Erasable Programmable Read-Only Memory (EPROM), a flash Memory, an optical fiber, a portable Compact Disc Read-Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer-readable signal medium may include a propagated data signal with computer-readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software, or may be implemented by hardware, and the described units may also be disposed in a processor. Wherein the names of the elements do not in some way constitute a limitation on the elements themselves.
As another aspect, the present disclosure also provides a computer-readable medium, which may be included in the task management device described in the above embodiments; or may exist separately without being assembled into the electronic device. The computer readable medium carries one or more programs which, when executed by an electronic device, cause the electronic device to implement the method described in the above embodiments.
It should be noted that although in the above detailed description several modules or units of the device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit, according to embodiments of the present disclosure. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which may be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.