Task processing method, apparatus, device, and computer storage medium
By introducing monitoring tasks into the task scheduling system and using the output redirection mechanism to obtain the execution information of "black box" tasks such as Shell tasks, the problem of real-time acquisition of task execution information is solved, and real-time monitoring of task execution information and low-impact querying in high-concurrency scenarios are realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ALIBABA (CHINA) CO LTD
- Filing Date
- 2022-01-30
- Publication Date
- 2026-04-14
AI Technical Summary
In existing technologies, task scheduling systems cannot obtain execution information of "black box" tasks such as Shell tasks in real time, resulting in a poor user experience while waiting.
By introducing a monitoring task between the task scheduling device and the execution device, and utilizing the output redirection mechanism, task execution information is obtained from the task's output redirection file and stored in the storage space for querying, thus achieving asynchronous monitoring and reducing the impact on the monitored task.
It enables real-time acquisition of task execution information during task execution, reduces the impact on the monitored task, is suitable for high-concurrency scenarios, and reduces the performance load on the database.
Smart Images

Figure CN114579395B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of computer application technology, and more particularly to task processing methods, apparatus, devices, and computer storage media. Background Technology
[0002] With the advancement of automated operations and maintenance (O&M), many task scripts, such as O&M scripts and test scripts, can be scheduled and executed by task scheduling systems. However, the execution of these scripts usually takes a considerable amount of time, during which the task scheduling system cannot obtain task execution information, such as task progress or real-time task output. For users, waiting for task results for a long time without being able to obtain task execution information is obviously a poor user experience.
[0003] Since a task has the most accurate understanding of its own execution progress, it's possible to output task execution information by rewriting commands in the task script. However, for "black box" tasks like Shell tasks, which do not support command rewriting, there is currently no good way to obtain task execution information. Summary of the Invention
[0004] In view of this, one or more embodiments of this specification describe a task processing method, apparatus, device, and computer storage medium for acquiring task execution information during task execution.
[0005] According to a first aspect, a task processing method is provided, executed by a task scheduling device, the method comprising:
[0006] The monitored tasks are distributed to the task execution devices;
[0007] During the execution of the monitored task, a monitoring task is sent to the task execution device for the monitored task;
[0008] The monitoring task is used to obtain the task execution information of the monitored task from the output redirection file of the monitored task, and store the task execution information in the storage space for querying.
[0009] According to one embodiment, the storage space includes a first storage space; the method further includes: when creating the monitored task, providing the task identifier of the monitored task to the task monitoring process, and the task monitoring process storing the task identifier in the monitoring task list of the first storage space;
[0010] The task monitoring process executes the step of issuing monitoring tasks to the monitored task based on the monitoring task list.
[0011] According to one embodiment, issuing a monitoring task for the monitored task includes:
[0012] Monitoring tasks are periodically issued for the monitored task.
[0013] According to one embodiment, the task execution information includes task output information and / or task progress information.
[0014] According to one embodiment, the method further includes:
[0015] The task scheduling device actively or in response to a request from the user terminal queries the task execution information of the monitored task from the storage space and sends the task execution information to the user terminal.
[0016] According to one embodiment, the storage space includes a second storage space and a third storage space;
[0017] Querying the task execution information of the monitored task from the storage space includes:
[0018] The task execution information of the monitored task is queried from the second storage space. If the information is found, the queried task execution information is obtained; otherwise, the task execution information of the monitored task is queried from the third storage space.
[0019] The second storage space is located in the cache device, and the third storage space is located in the database device.
[0020] According to the second aspect, a task processing method is also provided, executed by a task execution device, the method comprising:
[0021] Acquire and execute the monitored tasks issued by the task scheduling device;
[0022] During the execution of the monitored task, the monitoring task issued by the task scheduling device for the monitored task is acquired;
[0023] The monitoring task is performed, which includes: obtaining the task execution information of the monitored task from the output redirection file of the monitored task, and storing the task execution information in the storage space for querying.
[0024] According to one embodiment, when the monitored task is executed, it writes the task output information into the output redirection file;
[0025] Obtaining the task execution information of the monitored task from the output redirection file of the monitored task includes:
[0026] Read task output information from the output redirection file; or...
[0027] Read task output information from the output redirection file and determine the task progress information of the monitored task based on the task output information.
[0028] According to one embodiment, the storage space includes a first storage space; the method further includes:
[0029] After the monitored task is completed, the task identifier of the monitored task is deleted from the monitoring task list in the first storage space; wherein the monitoring task list is used by the task scheduling device to issue monitoring tasks for the monitored task.
[0030] According to one embodiment, the storage space includes a second storage space and a third storage space;
[0031] The step of storing the task execution information in the storage space includes:
[0032] During the execution of the monitored task, the task execution information of the monitored task is stored in the second storage space; after the monitored task is completed, the task execution information of the monitored task is stored in the third storage space.
[0033] The second storage space is located in the cache device, and the third storage space is located in the database device.
[0034] According to a third aspect, a task processing apparatus is provided, disposed in a task scheduling device, comprising:
[0035] The first task dispatching unit is configured to dispatch the monitored tasks to the task execution devices;
[0036] The second task issuing unit is configured to issue a monitoring task to the task execution device during the execution of the monitored task.
[0037] The monitoring task is used to obtain the task execution information of the monitored task from the output redirection file of the monitored task, and store the task execution information in the storage space for querying.
[0038] According to the fourth aspect, a task processing apparatus is also provided, disposed in a task execution device, comprising:
[0039] The first task execution unit is configured to acquire and execute the monitored tasks issued by the task scheduling device;
[0040] The second task execution unit is configured to acquire the monitoring task issued by the task scheduling device for the monitored task during the execution of the monitored task.
[0041] The monitoring task is performed, which includes: obtaining the task execution information of the monitored task from the output redirection file of the monitored task, and storing the task execution information in the storage space for querying.
[0042] According to a fifth aspect, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in any one of the first and second aspects above.
[0043] According to a sixth aspect, an electronic device is provided, comprising:
[0044] One or more processors; and
[0045] A memory associated with the one or more processors, the memory being used to store program instructions that, when read and executed by the one or more processors, perform the method described in any one of the first and second aspects above.
[0046] According to the specific embodiments provided in this application, the following technical effects can be achieved:
[0047] 1) This application achieves the acquisition of task execution information during the execution of the monitored task by issuing a monitoring task to the monitored task, reading the execution information of the monitored task from the output redirection file of the monitored task, and storing it in the storage space for query.
[0048] 2) This application adopts a "non-intrusive" (i.e., no command rewriting is required for the monitored task) method to obtain task execution information, which will not affect the execution logic of the monitored task itself.
[0049] 3) In this application, the monitored task and the monitoring task are separated. This asynchronous monitoring method results in low coupling between the two tasks, further reducing the impact of the monitoring task on the monitored task. For example, an abnormality or failure of the monitoring task will not affect the monitored task.
[0050] 4) In the process of querying task execution information, the task scheduling device prioritizes querying task execution information from the cache device, which can greatly reduce the performance impact on the database device.
[0051] 5) The user client establishes a session with the task scheduling device, and the processing of task execution information query is asynchronous with the monitored task and the monitoring task. On the one hand, it will not affect the execution of the monitored task. On the other hand, the user client does not need to establish any session with the task execution device, which reduces the performance impact on the task execution device. Therefore, it can be applied to high-concurrency scenarios.
[0052] Of course, any product implementing this application does not necessarily need to achieve all of the advantages described above at the same time. Attached Figure Description
[0053] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0054] Figure 1 The system architecture diagram on which the embodiments of this application are based is shown;
[0055] Figure 2 A flowchart of a task processing method according to one embodiment is shown;
[0056] Figure 3 A flowchart of a task processing method according to another embodiment is shown;
[0057] Figure 4 A schematic diagram of a system collaboration process according to one embodiment of a task processing method is shown;
[0058] Figure 5 A schematic diagram of the system collaboration process according to one embodiment of the progress query method is shown;
[0059] Figure 6 A schematic block diagram of a task processing apparatus according to one embodiment is shown;
[0060] Figure 7 A schematic block diagram of another task processing apparatus according to one embodiment is shown;
[0061] Figure 8 A schematic architecture diagram of an electronic device provided in an embodiment of this application is shown. Detailed Implementation
[0062] The solution provided in this specification will now be described with reference to the accompanying drawings.
[0063] To facilitate understanding of the technical solutions provided in this specification, the system architecture on which these solutions are based will be introduced first. For example... Figure 1 As shown, the system mainly includes a task scheduling device 110, a task execution device 120, and a storage space 130, and may also include a device 140 where the user terminal is located.
[0064] Storage space 130 may include a first storage space 131, a second storage space 132, and a third storage space 133. The specific content stored in each storage space will be described in detail in subsequent embodiments. Each storage space can be independent of the others, or it can be located on different devices or take different forms. In subsequent embodiments, the first storage space 131 and the third storage space 133 are set on a cache server as an example, and the second storage space 132 is set as a database as an example.
[0065] The aforementioned task scheduling device 110 is mainly used for task scheduling and distributing tasks to the task execution device 120. The task execution device 120 is the device that executes specific tasks. The aforementioned task scheduling device 110 and task execution device 120 are usually located on the server side, and therefore can take the form of a server, server group, cloud server (also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of high management difficulty and weak scalability in traditional physical hosts and virtual private servers), etc. However, this application is not limited to these, and can also be set as other device types besides servers.
[0066] The user terminal device 140 can interact with the task scheduling device 110, allowing the user to query and obtain task execution information from the task scheduling device 110 through the user terminal. The user terminal device can be various types of user devices, including but not limited to smart mobile terminals, smart home devices, wearable devices, and PCs (personal computers). Smart mobile devices can include devices such as mobile phones, tablets, laptops, PDAs (personal digital assistants), and connected cars. Smart home devices can include devices such as smart TVs. Wearable devices can include devices such as smartwatches, smart glasses, virtual reality devices, augmented reality devices, and mixed reality devices (i.e., devices that support both virtual reality and augmented reality).
[0067] Figure 2 A flowchart illustrating a task processing method according to one embodiment is shown. The method comprises... Figure 1 The task scheduling device shown executes the task. For example... Figure 2 As shown, the method may include the following steps:
[0068] Step 201: The monitored task is sent to the task execution device.
[0069] Step 202: During the execution of the monitored task, a monitoring task is periodically sent to the task execution device for the monitored task. The task monitoring task is used to obtain the execution information of the monitored task from the output redirection file of the monitored task and store the task execution information in the storage space for querying.
[0070] As can be seen from the steps provided in this embodiment, by issuing a monitoring task to the monitored task, the execution information of the monitored task is read from its output redirection file and stored in storage space for later retrieval. On the one hand, this "non-intrusive" (i.e., without rewriting instructions for the monitored task) method of obtaining task execution information does not affect the monitored task; on the other hand, the separation of the monitored task and the monitoring task, and this asynchronous monitoring method, results in low coupling between the two tasks, further reducing the impact of the monitoring task on the monitored task. For example, an anomaly in the monitoring task will not affect the monitored task.
[0071] To enable users to obtain task execution information, the method may further include:
[0072] Step 203: The task scheduling device actively or in response to a request from the user terminal queries the task execution information of the monitored task from the storage space and sends the task execution information to the user terminal.
[0073] The steps performed by the task scheduling device are described in detail below. First, step 201, namely "distributing the monitored task to the task execution device," will be described in detail.
[0074] It is understandable that the task scheduling device is responsible for creating and issuing tasks, while the task execution device is responsible for executing tasks. After creating a monitored task, the task scheduling device generates a task ID (identifier) for the monitored task and issues the monitored task to the task execution device for execution.
[0075] The monitored task can be any task whose execution information needs to be obtained. Since this application primarily addresses "black box" tasks such as Shell tasks, the monitored task can be a "black box" task such as a shell task. A shell task refers to a system maintenance script in a Unix-like (including Linux) system or a program called from the shell (computer shell). Shell tasks typically do not support command rewriting, or command rewriting is very difficult, therefore they belong to the "black box" task category.
[0076] When issuing monitored tasks, the task scheduling device can write the task ID of the monitored task into the task list. It then issues specific tasks based on the task list. This part is the same as the existing implementation; the task scheduling device issues the tasks in the task list to the task execution device for execution.
[0077] As one possible approach, the task scheduling device can run a task monitoring process, which can either start when the task scheduling device boots up, or be triggered by a specific event, such as when the first task is created after the task scheduling device starts up, and so on.
[0078] After creating a monitored task, the task scheduling device can register the monitored task with the task monitoring process. This involves providing the task ID of the monitored task to the task monitoring process, which then writes the task ID into the monitored task list. This monitored task list can be stored in [location missing]. Figure 1 The first storage space involved in the architecture shown can be, for example, storage space in a cache server.
[0079] The monitoring task list is a list set in the embodiments of this application, and the monitoring tasks are created and issued for the tasks in the task list mentioned above.
[0080] Furthermore, the task scheduling equipment can also store the basic information of the monitored tasks in [location missing]. Figure 1 The third storage space in the illustrated architecture. The basic information of the monitored task may include the task ID, and may also include information such as task type, task publisher, and the task group from which it originated. This third storage space stores the final task execution result (i.e., the final task output) after the monitored task is completed. This execution result can be stored in a database in association with the task's basic information for easy retrieval. This part will be described in detail in subsequent embodiments.
[0081] The following describes step 202, namely "during the execution of the monitored task, a monitoring task is sent to the task execution device for the monitored task", in detail with reference to the embodiments.
[0082] In this step, since the monitored tasks have already been registered with the task monitoring process, the task monitoring process actually issues monitoring tasks to the registered tasks. Specifically, the task monitoring process issues monitoring tasks to each monitored task in the task monitoring list.
[0083] One possible approach is for the task scheduling server to issue a monitoring task upon receiving a query request for the monitored task. For example, if a user needs to query the execution information of a specific task, they can send a query request to the task scheduling server through their client. The task monitoring process in the task scheduling server can check if the requested task ID is in the task monitoring list. If it is, the server issues a monitoring task for the monitored task corresponding to that task ID. If it is not, the task may have already been completed, and the server can directly query the task execution information corresponding to that task ID from the storage space.
[0084] As another possible approach, the task scheduling server can periodically issue monitoring tasks for the monitored tasks, for example, issuing a monitoring task every 2 seconds.
[0085] Since the monitored task is deregistered after completion (i.e., removed from the monitoring task list – the deregistration process will be detailed in subsequent embodiments involving task execution devices), the task monitoring process only needs to issue monitoring tasks according to the task monitoring list. If a monitored task is not included in the monitoring task list, it means that the monitored task has been completed, and there is no need to issue a monitoring task for it.
[0086] Figure 3 A flowchart illustrating a task processing method according to another embodiment is shown. The method is... Figure 1 The task execution device shown is used for execution. For example... Figure 3 As shown, the method may include the following steps:
[0087] Step 301: Obtain and execute the monitored task issued by the task scheduling device.
[0088] Step 302: During the execution of the monitored task, obtain the monitoring task issued by the task scheduling device for the monitored task.
[0089] Step 303: Execute a monitoring task, which includes obtaining the task execution information of the monitored task from the output redirection file of the monitored task and storing the task execution information in the storage space for querying.
[0090] For the task execution device, after receiving the various tasks issued by the task scheduling device, it simply executes them according to the task content. The following section focuses on a detailed description of step 303 above.
[0091] For "black box" tasks such as Shell tasks, although command rewriting is not supported, I(input) / O(output) redirection mechanisms are supported. In this embodiment, the output redirection mechanism is utilized, that is, while retaining the original output of the monitored task, the output is redirected to a specified file, which is called the output redirection file.
[0092] Taking Shell tasks as an example, the task scheduling device can redirect the output of Shell tasks, for instance, by adding an extra redirection function "|tee uuid.txt". The "tee" command copies the original output of the Shell task to a file named after the UUID (Universally Unique Identifier) of the monitored task, without affecting the original output. This file is usually a temporary file, which may have an expiration time or be deleted after the monitored task has finished executing.
[0093] The output of the Shell task mentioned above may include stdout (standard output) and stderr (standard error output).
[0094] It should be noted that the output redirection mechanism of the above-mentioned Shell task will not affect the execution of the Shell task, nor is it necessary to rewrite the Shell task command; it is only necessary to execute an additional redirection command.
[0095] The task parameters of the monitoring task include the task identifier (e.g., UUID) of the monitored task. When the monitoring task is executed, it obtains file execution information from the output redirection file of the monitored task mentioned above.
[0096] In one implementation, the file execution information mentioned above can include task output information, that is, the information output in real time by the monitored task. In this implementation, the monitoring task simply reads the latest task output information from the output redirection file and then writes the task output information to the storage space.
[0097] As another implementation, the aforementioned file execution information may include task progress information. In this implementation, after the monitoring task reads the task output information from the redirection file of the monitored task, it can further analyze the task output information to obtain the task progress information of the monitored task, and then write the task progress information into the storage space.
[0098] For a specific monitored task, the output information is typically different and has certain characteristics at different stages of task execution. These characteristics are usually represented by strings. For example, when the monitored task outputs string 1, it means that the monitored task has been completed to 20%; when the monitored task outputs strings 2 and 3, it means that the monitored task has been completed to 50%; and so on. The progress information of the monitored task can be analyzed by matching string features. Besides string feature matching, other methods can also be used to analyze task progress information, which will not be exhaustively listed here.
[0099] As another implementation, the aforementioned file execution information can include task output information and task progress information. That is, after the monitoring task reads the task output information from the redirection file of the monitored task, it can further analyze the task output information to obtain the task progress information of the monitored task, and then write both the task output information and the task progress information into the storage space.
[0100] Since the monitoring task is issued by the task scheduling server during the execution of the monitored task, as one implementation method, the monitoring task can store the acquired task execution information in... Figure 1 The second storage space in the illustrated architecture can be located in a cache server. Thus, the periodic execution of the monitoring task ensures that the second storage space contains task execution information at preset intervals (e.g., 2 seconds). The second storage space can store all task execution information acquired by the monitoring task, identified by the write time. Alternatively, it can store only the most recently acquired task execution information.
[0101] Additionally, an aging time can be set for the task execution information stored in the second storage space, such as one hour. This aging time must be at least longer than the execution duration of the monitored task. The specific duration can be uniformly set based on experimental or empirical values. When the aging time is reached, the corresponding task execution information will be deleted from the second storage space.
[0102] After the monitored task is completed, the task execution device will store the execution result, i.e., the final output, of the monitored task. Figure 1 The architecture shown includes a third storage space. This third storage space can be in the form of a database, where the execution results of the monitored tasks are associated with and stored along with the basic information of the tasks, facilitating retrieval. At this point, the task progress is actually 100% complete.
[0103] Since the most important execution result of the monitored task is written to the third storage space, and the monitoring task and the monitored task are executed asynchronously, even if the monitoring task encounters an error, it will not affect the monitored task, and the output result of the monitored task can be obtained after the monitored task is completed.
[0104] In addition, after the monitored task is completed, the task execution device will deregister the monitored task. Specifically, the task identifier of the monitored task can be deleted from the monitored task list in the first storage space. In this way, the task scheduling device will no longer issue monitoring tasks for that monitored task. Alternatively, other deregistration methods can be used, such as the task execution device sending information about the completion of the monitored task to the task scheduling device, and the task monitoring process in the task scheduling device deregistering the task identifier of the monitored task from the monitored task list in the first storage space. However, this method requires additional interaction with the task scheduling device, so the former method is preferred.
[0105] If the task execution device stores the task execution information obtained during the execution of the monitored task in the second storage space, and stores the task result obtained after the completion of the monitored task in the third storage space, then in the above embodiment... Figure 2 In the illustrated process, step 203, when the task scheduling device queries task execution information, can first query the task execution information of the monitored task from the second storage space. If found, the queried task execution information is obtained and sent to the user terminal. If not found, the task execution information of the monitored task is queried from the third storage space and sent to the user terminal. This query method is the preferred method because in most scenarios, users will pay attention to task execution information during task execution, such as wanting to know the task execution progress or wanting to know the real-time output of the task.
[0106] To facilitate understanding of the collaboration between the task scheduling and execution devices, the following description uses a Shell task as the monitored task, with both the task scheduling and execution devices operating as servers, the first and second storage spaces housed in a cache server, and the third storage space configured as a database. This example illustrates the collaboration process of the entire system. Figure 4 As shown, the process may include the following steps:
[0107] Step 401: The task scheduling server creates a Shell task, generates a UUID for the Shell task, and registers the Shell task with the task monitoring process.
[0108] Step 402: The task scheduling server distributes the Shell task to the task execution server.
[0109] After the task scheduling server creates a Shell task, it stores the Shell task's UUID in the task list of the cache server. Based on the task list, the Shell task is then dispatched to the task execution server. This part is consistent with existing technology.
[0110] Step 403: The task execution server executes the Shell task, during which the Shell task's stdout (standard output) and stderr (standard error output) are redirected to the output redirection file.
[0111] The output redirection file can be a temporary file identified by a UUID.
[0112] Step 404: The task monitoring process of the task scheduling server stores the UUID of the Shell task into the monitoring task list in the cache server.
[0113] Step 405: The task scheduling server stores the basic task information of the Shell task in the database.
[0114] It should be noted that, in addition to the above execution order, the processing of the task scheduling server in steps 402, 404 and 405 can be executed simultaneously or in other orders, and this application does not impose any restrictions on this.
[0115] Step 406: The task monitoring process of the task scheduling server periodically (e.g., every 2 seconds) sends monitoring tasks (with the UUID of the Shell task included in the task parameters) to the task execution server based on the monitoring task list in the cache server.
[0116] Step 407: The task execution server executes a monitoring task, reads the task output information of the Shell task from the aforementioned redirection file (i.e., a temporary file identified by the UUID of the Shell task), and determines the task progress information of the Shell task based on the task output information.
[0117] Since the redirection file stores the real-time output of the shell task, task progress information can be analyzed from the task output information. For example, a string feature matching method can be used, that is, the string features corresponding to different task progress are determined in advance, and the corresponding task progress information is determined based on the string features of the task output information.
[0118] Step 408: The task execution server stores the task progress information of the Shell task in the cache server.
[0119] This embodiment uses task progress information as an example for description. In addition to task progress information, task output information can also be stored in a cache server. The cache server only stores the latest task progress information; that is, the stored task progress information is replaced with the new task progress information each time.
[0120] Step 409: After the Shell task is completed, the task execution server triggers the deregistration of the Shell task and removes the Shell task's UUID from the monitoring task list in the cache server.
[0121] Step 410: After the Shell task is completed, the task execution server stores the execution result of the Shell task in the database.
[0122] The execution result of a Shell task is actually the final output, which means that the task execution progress is now 100% complete.
[0123] When the task scheduling server queries the task progress, the execution flow can be as follows: Figure 5 As shown, the steps include:
[0124] Step 501: The client sends a task progress query request to the task scheduling server through the session connection established with the task scheduling server. The task scheduling query request carries information about the Shell task to be queried.
[0125] Step 502: The task scheduling server queries the cache server for the task progress information of the Shell task. If the information is found, proceed to step 504; otherwise, proceed to step 503.
[0126] Step 503: The task scheduling server queries the database for the task progress information of the Shell task. If the information is found, proceed to step 504; otherwise, it can return information that no task progress was found to the client.
[0127] Step 504: The task scheduling server returns the queried task progress information to the user.
[0128] In the above task progress query process, the task scheduling server prioritizes querying task progress information from the cache server, which can greatly reduce the performance impact on the database.
[0129] In addition, from Figure 5As shown in the task progress query process, users establish a session with the task scheduling server through the client. The query processing is executed asynchronously with the monitored task and the monitoring task. On the one hand, it will not affect the execution of the monitored task. On the other hand, the client does not need to establish any session with the task execution server, which reduces the performance impact on the task execution server. Therefore, it is suitable for high-concurrency scenarios.
[0130] It should be noted here that the above Figure 4 and Figure 5 In the embodiment shown, the first storage space and the second storage space are set on the cache server, and the third storage space is set as the database. This is only a preferred implementation provided by the embodiments of this application, and it does not exclude the possibility of using other forms or setting it as a single storage space.
[0131] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0132] According to another embodiment, a task processing apparatus is provided. Figure 6 A schematic block diagram of the task processing apparatus according to one embodiment is shown, the apparatus being disposed in Figure 1 The task scheduling device in the architecture shown. For example... Figure 6 As shown, the device 600 includes: a first task issuing unit 601 and a second task issuing unit 602, and may further include a task creation unit 603 and a user terminal interaction unit 604. The main functions of each component are as follows:
[0133] The first task dispatching unit 601 is configured to dispatch the monitored task to the task execution device.
[0134] When issuing monitored tasks, the first task issuing unit 601 can write the task ID of the monitored task into the task list. Specific tasks are then issued based on the task list. This part is the same as in existing implementations; the first task issuing unit 601 issues the tasks from the task list to the task execution device for execution.
[0135] The second task issuing unit 602 is configured to issue a monitoring task to the task execution device during the execution of the monitored task.
[0136] The monitoring task is used to obtain the task execution information of the monitored task from the output redirection file of the monitored task, and store the task execution information in the storage space for querying.
[0137] As one possible implementation, the aforementioned storage space may include a first storage space. This first storage space may be located in a caching device, such as a caching server.
[0138] The task creation unit 603 is configured to provide the task identifier of the monitored task to the task monitoring process when creating the monitored task. That is, the second task issuing unit 602 is implemented in the form of a task monitoring process, which stores the task identifier in the monitoring task list in the first storage space, and executes the operation of issuing monitoring tasks to the monitored task according to the monitoring task list.
[0139] The task scheduling device can run a task monitoring process, which can start when the task scheduling device starts, or it can be triggered by a specific event, such as when the first task is created after the task scheduling device starts, and so on.
[0140] Furthermore, the task creation unit 603 can also store the basic information of the monitored task in a third storage space. This basic information may include a task ID, as well as details such as task type, task publisher, and the task group from which it originated. This third storage space stores the final task execution result (i.e., the final task output) after the monitored task is completed. This execution result can be stored in a database in association with the task's basic information for easy retrieval.
[0141] In a preferred embodiment, the second task issuing unit 602 described above can periodically issue monitoring tasks for the monitored task.
[0142] The user-end interaction unit 604 is configured to proactively or in response to a request from the user end, query the task execution information of the monitored task from the storage space, and send the task execution information to the user end. The task execution information may include task output information and / or task progress information.
[0143] As one preferred embodiment, the storage space may include a second storage space and a third storage space.
[0144] The user-side interaction unit 604 can be specifically configured to: query the task execution information of the monitored task from the second storage space; if the information is found, obtain the queried task execution information; otherwise, query the task execution information of the monitored task from the third storage space; wherein the second storage space is located in the cache device and the third storage space is located in the database device.
[0145] According to another embodiment, a task processing apparatus is also provided. Figure 7 A schematic block diagram of the task processing apparatus according to one embodiment is shown, the apparatus being disposed in Figure 1 The task execution device in the architecture shown. For example... Figure 7 As shown, the device 700 includes: a first task execution unit 701 and a second task execution unit 702, and may further include a task cancellation unit 703. The main functions of each component are as follows:
[0146] The first task execution unit 701 is configured to acquire and execute the monitored task issued by the task scheduling device.
[0147] The second task execution unit 702 is configured to, during the execution of the monitored task, obtain the monitoring task issued by the task scheduling device for the monitored task; execute the monitoring task, which includes: obtaining the task execution information of the monitored task from the output redirection file of the monitored task, and storing the task execution information in the storage space for querying.
[0148] In this embodiment, an output redirection mechanism is used, which retains the original output of the monitored task while redirecting the output to a specified file, called the output redirection file. When the monitored task is executed, it writes its output information to the output redirection file.
[0149] When executing a monitoring task, the second task execution unit 702 can read task output information from the output redirection file; or, it can read task output information from the output redirection file and determine the task progress information of the monitored task based on the task output information.
[0150] As one possible implementation, the storage space includes a first storage space. The task deregistration unit 703 is configured to remove the task identifier of the monitored task from the monitoring task list in the first storage space after the monitored task has been executed; wherein the monitoring task list is used by the task scheduling device to issue monitoring tasks for the monitored task.
[0151] In one preferred embodiment, the monitoring task is periodically issued by the task scheduling device. Correspondingly, the second task execution unit 702 also periodically executes the corresponding monitoring task during the execution of the monitored task.
[0152] As one preferred embodiment, the storage space includes a second storage space and a third storage space.
[0153] When storing the task execution information in the storage space, the second task execution unit 702 is specifically configured as follows:
[0154] During the execution of the monitored task, the task execution information of the monitored task is stored in the second storage space; after the monitored task is completed, the task execution information of the monitored task is stored in the third storage space; wherein the second storage space is located in the cache device and the third storage space is located in the database device.
[0155] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for system or system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and relevant parts can be referred to the descriptions in the method embodiments. The systems and system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0156] It should be noted that the embodiments of this application may involve the use of user data. In practical applications, user-specific personal data may be used in the scheme described herein within the scope permitted by applicable laws and regulations, provided that it complies with the applicable laws and regulations of the country (e.g., with the user's explicit consent, with the user being properly notified, etc.).
[0157] In addition, embodiments of this application also provide a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the method described in any of the foregoing method embodiments.
[0158] And an electronic device, comprising:
[0159] One or more processors; and
[0160] A memory associated with the one or more processors, the memory being used to store program instructions that, when read and executed by the one or more processors, perform the steps of the method described in any of the foregoing method embodiments.
[0161] in, Figure 8An exemplary architecture of an electronic device is shown, which may include a processor 810, a video display adapter 811, a disk drive 812, an input / output interface 813, a network interface 814, and a memory 820. The processor 810, video display adapter 811, disk drive 812, input / output interface 813, network interface 814, and memory 820 can communicate with each other via a communication bus 830.
[0162] The processor 810 can be implemented using a general-purpose CPU, microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits to execute relevant programs and implement the technical solution provided in this application.
[0163] The memory 820 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 820 can store the operating system 821 for controlling the operation of the electronic device 800, and the basic input / output system (BIOS) 822 for controlling the low-level operations of the electronic device 800. Additionally, it can store a web browser 823, a data storage management system 824, and a task processing device 825, etc. The aforementioned task processing device 825 can be the application program that specifically implements the aforementioned steps in this embodiment. In summary, when the technical solution provided in this application is implemented through software or firmware, the relevant program code is stored in the memory 820 and is called and executed by the processor 810.
[0164] The input / output interface 813 is used to connect input / output modules to enable information input and output. Input / output modules can be configured as components within the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Input devices may include keyboards, mice, touchscreens, microphones, various sensors, etc., while output devices may include displays, speakers, vibrators, indicator lights, etc.
[0165] Network interface 814 is used to connect a communication module (not shown in the figure) to enable communication between this device and other devices. The communication module can communicate via wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0166] Bus 830 includes a pathway for transmitting information between various components of the device, such as processor 810, video display adapter 811, disk drive 812, input / output interface 813, network interface 814, and memory 820.
[0167] It should be noted that although the above-described device only shows the processor 810, video display adapter 811, disk drive 812, input / output interface 813, network interface 814, memory 820, bus 830, etc., in specific implementations, the device may also include other components necessary for normal operation. Furthermore, those skilled in the art will understand that the above-described device may only include the components necessary for implementing the solution of this application, and does not necessarily include all the components shown in the figures.
[0168] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of this application.
[0169] The task processing method provided in this application has been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and its core ideas. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.
[0170] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made on the basis of the technical solution of the present invention should be included within the scope of protection of the present invention.
Claims
1. A task processing method, executed by a task scheduling device, the method comprising: The monitored task is sent to the task execution device. The monitored task is a Shell task, which refers to a system maintenance script in a Unix-like system or a program called from the Shell. During the execution of the monitored task, a monitoring task is sent to the task execution device for the monitored task; When the monitored task is executed, the task output information is redirected to a redirection file through an I / O redirection mechanism; The monitoring task is used to read task output information from the output redirection file, and based on the pre-determined string features corresponding to different task progresses, determine the task progress information corresponding to the monitored task according to the string features of the task output information, so as to obtain the task execution information of the monitored task, and store the task execution information in the storage space for querying; the task output information is a string, and different strings correspond to different task progress information; the storage space includes a second storage space and a third storage space; wherein, the second storage space is located in a cache device and stores the task execution information when the monitored task is executed; the third storage space is located in a database device and stores the execution result of the monitored task after the monitored task is completed; Actively or in response to a user's request, the system queries the second storage space for the task execution information of the monitored task. If the information is found, the system obtains the retrieved task execution information; otherwise, the system queries the third storage space for the task execution information of the monitored task. The task execution information is sent to the user terminal.
2. The method according to claim 1, wherein, The storage space includes a first storage space; the method further includes: when creating the monitored task, providing the task identifier of the monitored task to the task monitoring process, and the task monitoring process storing the task identifier in the monitoring task list of the first storage space; The task monitoring process executes the step of issuing monitoring tasks to the monitored task based on the monitoring task list.
3. The method according to claim 1 or 2, wherein, The monitoring tasks issued for the monitored tasks include: Monitoring tasks are periodically issued for the monitored task.
4. The method according to claim 1, wherein, The task execution information includes task output information and / or task progress information.
5. A task processing method, executed by a task execution device, the method comprising: The monitored task is obtained and executed by the task scheduling device. The monitored task is a Shell task, which refers to a system maintenance script in a Unix-like system or a program called from the Shell. During the execution of the monitored task, the monitoring task issued by the task scheduling device for the monitored task is acquired; The monitoring task includes: obtaining the task execution information of the monitored task from the output redirection file of the monitored task, and storing the task execution information in the storage space for querying; When the monitored task is executed, the task output information is redirected to the output redirection file through an I / O redirection mechanism; the task output information is a string, and different strings correspond to different task progress information; Obtaining the task execution information of the monitored task from the output redirection file of the monitored task includes: Read task output information from the output redirection file, and determine the task progress information corresponding to the monitored task based on the string features corresponding to different task progresses in a predetermined manner, in order to obtain the task execution information. The storage space includes a second storage space and a third storage space; wherein, the second storage space is located in a cache device; and the third storage space is located in a database device. The step of storing the task execution information in the storage space includes: During the execution of the monitored task, the task execution information of the monitored task is stored in the second storage space; after the monitored task is completed, the task execution information of the monitored task is stored in the third storage space.
6. The method according to claim 5, wherein the storage space includes a first storage space; The method further includes: After the monitored task is completed, the task identifier of the monitored task is deleted from the monitoring task list of the first storage space; The monitoring task list is used by the task scheduling device to issue monitoring tasks for the monitored task.
7. A task processing device, installed in the task scheduling equipment, comprising: The first task dispatching unit is configured to dispatch the monitored task to the task execution device. The monitored task is a Shell task, which refers to a system maintenance script in a Unix-like system or a program called from the Shell. The second task issuing unit is configured to issue a monitoring task to the task execution device during the execution of the monitored task. When the monitored task is executed, the task output information is redirected to a redirection file through an I / O redirection mechanism; The monitoring task is used to read task output information from the output redirection file, and based on the pre-determined string features corresponding to different task progresses, determine the task progress information corresponding to the monitored task according to the string features of the task output information, so as to obtain the task execution information of the monitored task, and store the task execution information in the storage space for querying; the task output information is a string, and different strings correspond to different task progress information; the storage space includes a second storage space and a third storage space; wherein, the second storage space is located in a cache device and stores the task execution information when the monitored task is executed; the third storage space is located in a database device and stores the execution result of the monitored task after the monitored task is completed; Actively or in response to a user's request, the system queries the second storage space for the task execution information of the monitored task. If the information is found, the system obtains the retrieved task execution information; otherwise, the system queries the third storage space for the task execution information of the monitored task. The task execution information is sent to the user terminal.
8. A task processing device, disposed in a task execution device, comprising: The first task execution unit is configured to acquire and execute the monitored task issued by the task scheduling device. The monitored task is a Shell task, which refers to a system maintenance script under a Unix-like system or a program called from the Shell. The second task execution unit is configured to acquire the monitoring task issued by the task scheduling device for the monitored task during the execution of the monitored task. The monitoring task includes: obtaining the task execution information of the monitored task from the output redirection file of the monitored task, and storing the task execution information in the storage space for querying; When the monitored task is executed, the task output information is redirected to the output redirection file through an I / O redirection mechanism; the task output information is a string, and different strings correspond to different task progress information; Read task output information from the output redirection file, and determine the task progress information corresponding to the monitored task based on the string features corresponding to different task progresses in a predetermined manner, in order to obtain the task execution information. The storage space includes a second storage space and a third storage space; wherein, the second storage space is located in a cache device; and the third storage space is located in a database device. The second task execution unit is specifically configured to store the task execution information of the monitored task in the second storage space during the execution of the monitored task; and to store the task execution information of the monitored task in the third storage space after the monitored task is completed.
9. A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 6.
10. An electronic device, comprising: One or more processors; as well as A memory associated with the one or more processors, the memory being used to store program instructions that, when read and executed by the one or more processors, perform the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Fault monitoring method and routing equipment
CN110190992A