Disclosure of Invention
The application provides a task management method and device based on Agent, which are used for solving the problems that the task processing speed is slow because the existing task management process can only manage the tasks written by a certain programming language and does not support the management of tasks of multiple languages, and the method and device based on Agent provide the following technical scheme:
a task management method based on Agent adds Agent in task node in advance, the method includes:
receiving at least one task to be processed, wherein the type of the task to be processed is any one of preset types, and acquiring a starting command, CPU occupation information, memory occupation information and a task executable file in the task to be processed;
receiving idle CPU information and idle memory information of each task node;
determining a target task node based on each idle CPU information and corresponding idle memory information, the CPU occupation information and the memory occupation information;
and sending the task feasibility file to the target task node so as to enable the target task node to execute the task feasibility file.
Optionally, the method for determining a target task node based on each idle CPU information and idle memory information, the CPU occupation information, and the memory occupation information includes:
traversing each idle CPU information and corresponding idle memory information, and comparing the CPU occupation information and the memory occupation information with each idle CPU information and corresponding idle memory information;
and taking the task node with idle CPU information more than or equal to the CPU occupation information and corresponding idle memory information more than or equal to the memory occupation information as the target task node.
The above method, optionally, further includes:
and storing the task to be processed, the idle CPU information and the corresponding idle memory information.
The above method, optionally, further includes:
receiving an execution result of the task to be processed fed back by the target task node;
and marking the execution result.
The above method, optionally, further includes:
counting the failure times of executing failed tasks to be processed in the tasks to be processed at intervals of preset time;
comparing the failure times with a preset failure time threshold;
and giving up the processing of the tasks to be processed with the failure times reaching the preset failure threshold value.
An Agent-based task management device, which adds an Agent in a task node in advance, the device comprising:
the system comprises a receiving and obtaining module, a task execution module and a task execution module, wherein the receiving and obtaining module is used for receiving at least one task to be processed, the type of the task to be processed is any one of preset types, and a starting command, CPU occupation information, memory occupation information and a task executable file in the task to be processed are obtained;
the receiving module is used for receiving idle CPU information and idle memory information of each task node;
the determining module is used for determining a target task node based on each piece of idle CPU information and corresponding idle memory information, the CPU occupation information and the memory occupation information;
and the sending and executing module is used for sending the task feasibility file to the target task node so as to enable the target task node to execute the task feasibility file.
The above apparatus, optionally, the determining module includes:
the comparison unit is used for traversing each idle CPU information and the corresponding idle memory information thereof, and comparing the CPU occupation information and the memory occupation information with each idle CPU information and the corresponding idle memory information;
and the determining unit is used for taking the task node of which the idle CPU information is more than or equal to the CPU occupation information and the corresponding idle memory information is more than or equal to the memory occupation information as the target task node.
The above apparatus, optionally, further comprises:
and the storage module is used for storing the task to be processed, each piece of idle CPU information and corresponding idle memory information.
The above apparatus, optionally, further comprises:
the receiving module is used for receiving the execution result of the task to be processed fed back by the target task node;
and the marking module is used for marking the execution result.
The above apparatus, optionally, further comprises:
the counting module is used for counting the failure times of executing failed tasks to be processed in the tasks to be processed at intervals of preset time;
the comparison module is used for comparing the failure times with a preset failure time threshold;
and the abandoning module is used for abandoning the processing of the tasks to be processed with the failure times reaching the preset failure threshold value.
The invention discloses a task management method based on Agent, which adds Agent in task node in advance, comprising: receiving at least one task to be processed, wherein the type of the task to be processed is any one of preset types, and the task to be processed comprises the following steps: starting a command, CPU occupation information, memory occupation information and a task executable file; receiving idle CPU information and idle memory information of each task node; determining a target task node based on each idle CPU information and corresponding idle memory information, CPU occupation information and memory occupation information; and sending the task feasibility file to the target task node so that the target task node executes the task feasibility file. According to the method, the Agent is added into the task node, the to-be-processed task is executed through the Agent, the type of the to-be-processed task is not limited, the management of various types of to-be-processed tasks is achieved, and the processing speed is improved.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
The invention discloses an Agent-based task management method and device, which are applied to the management process of different types of tasks, wherein the different types of tasks can be written based on Shell scripts, Java programs and Go programs, the execution main body of the method can be a processor or a controller and the like, preferably, the processor or the controller is a task management center, the task management center is connected with a plurality of task nodes, the Agent is added in advance for each task node, and the execution flow of the management method is shown in figure 1 and comprises the following steps:
s101, receiving at least one task to be processed, wherein the type of the task to be processed is any one of preset types, and acquiring a starting command, CPU occupation information, memory occupation information and a task executable file in the task to be processed;
in the embodiment of the invention, at least one task to be processed is received, the type of the task to be processed is any one of various preset types, the preset types are based on Shell scripts, Java programs, Go programs and the like, and in the embodiment of the invention, the preset types are not limited, the starting command, the CPU occupation information, the memory occupation information and the task executable file in the task to be processed are obtained, wherein the start command is used for executing the task executable file, the task executable file is a specific task to be executed in the tasks to be processed, the CPU occupation information is the processing amount of the CPU occupied by processing the task to be processed, the memory usage information is memory amount occupied by processing a coarse waist in the task to be processed, and the task to be processed further includes: and preferably, acquiring the task to be processed through a Rest interface.
Further, after receiving the task to be processed, storing the task name, the task type, the start command, the CPU occupation information and the memory occupation information in the task to be processed into a database, and storing the task execution file into a file server.
S102, receiving idle CPU information and idle memory information of each task node;
in the embodiment of the present invention, each task node sends idle CPU information and idle memory information to the task management center in real time, and the task management center receives the idle CPU information and the idle memory information of each task node, where the idle CPU information may be a processing amount of a task in the task node, and the idle memory information may be a specific idle memory amount.
Preferably, the idle CPU information of each task node and the idle memory information corresponding to the idle CPU information are stored, and may be stored in a database together with a task name, a task type, a start command, CPU occupation information, and memory occupation information in the to-be-processed information, or may be stored in other designated locations.
S103, determining a target task node based on each idle CPU information and corresponding idle memory information, the CPU occupation information and the memory occupation information;
in the embodiment of the present invention, each idle CPU information and its corresponding idle memory information in the database are traversed, each idle CPU information and its corresponding idle memory information are compared with the CPU occupancy information and the memory occupancy information, and it is determined whether there is a task node where the idle CPU information is greater than or equal to the CPU occupancy information and its corresponding idle memory information is greater than or equal to the memory occupancy information, where in the determination process, the CPU occupancy information may be compared first or the memory occupancy information may be compared first, and in the embodiment of the present invention, no specific limitation is made, and a task node where the idle CPU information is greater than or equal to the CPU occupancy information and its corresponding idle memory information is greater than or equal to the memory occupancy information is used as the target task node, and further, if there are a plurality of task nodes satisfying the above requirements in each task node, the first task node meeting the requirement can be used as a target task node, and the node with the largest idle CPU information or idle memory information in each node meeting the requirement can also be used as the target task node.
Preferably, after the target task node is determined, the corresponding relationship between the task to be processed and the target task node is stored, so that the target task node corresponding to the task to be processed is conveniently queried at a subsequent task execution stage, and the target task node processes the task to be processed.
And S104, sending the task feasibility file to the target task node so as to enable the target task node to execute the task feasibility file.
In the embodiment of the present invention, for each task node, a task to be processed of the task node is pulled to the task management center at intervals of a preset duration, where a pulling principle may be to directly assign a corresponding task to be processed to the task management center or the task node actively acquires the corresponding task to be processed based on a correspondence between the task to be processed and the target task node.
The processing process of the target task node executing the task executable file is as follows: and acquiring a starting command in the task to be processed, calling the starting command to enable the task executable file to execute, and preferably, feeding back an execution result to the task management center.
The task management center receives the execution result and marks the task to be processed, for example, the task to be processed may be marked as processing completion.
The invention discloses a task management method based on Agent, which adds Agent in task node in advance, comprising: receiving at least one task to be processed, wherein the type of the task to be processed is any one of preset types, and the task to be processed comprises the following steps: starting a command, CPU occupation information, memory occupation information and a task executable file; receiving idle CPU information and idle memory information of each task node; determining a target task node based on each idle CPU information and corresponding idle memory information, CPU occupation information and memory occupation information; and sending the task feasibility file to the target task node so that the target task node executes the task feasibility file. According to the method, the Agent is added into the task node, the to-be-processed task is executed through the Agent, the type of the to-be-processed task is not limited, the management of various types of to-be-processed tasks is achieved, and the processing speed is improved.
In the embodiment of the present invention, a schematic diagram for the above process is shown in fig. 2, and includes a task management center, a database, a file service, and task nodes, where the task management center receives a task to be processed, stores a start command, CPU occupation information, memory occupation information, a task name, and a task type in the task to be processed in the database, and robustly stores a file in the file service, the file management center receives the idle CPU information and the idle memory information of each task node, stores each idle CPU information and the corresponding idle memory information into a database, and determining a target task node based on each piece of idle CPU information and corresponding idle memory information, the CPU occupation information and the memory occupation information, and sending the task feasibility file to the target task node so as to enable the target task node to execute the task feasible file. The specific processing procedure is the same as that described in S103 and S104, and is not described herein again.
Further, counting the failure times of executing failed tasks to be processed in the tasks to be processed at intervals of preset time, comparing the failure times with a preset failure time threshold value, and comparing the failure times with a preset failure time threshold value; and giving up the processing of the tasks to be processed with the failure times reaching the preset failure threshold value. The preset failure threshold may be set based on experience or specific conditions, and in the embodiment of the present invention, specific values of the preset failure number threshold are not limited. Preferably, the information for abandoning the process may be fed back.
Based on the above Agent-based task management method, in an embodiment of the present invention, an Agent-based task management device is further provided, and a structural block diagram of the management device is shown in fig. 3, where the management device includes:
a receiving and acquiring module 201, a receiving module 202, a determining module 203 and a sending and executing module 204.
Wherein,
the receiving and acquiring module 201 is configured to receive at least one to-be-processed task, where the to-be-processed task is any one of preset types, and acquire a start command, CPU occupation information, memory occupation information, and a task executable file in the to-be-processed task;
the receiving module 202 is configured to receive idle CPU information and idle memory information of each task node;
the determining module 203 is configured to determine a target task node based on each idle CPU information and corresponding idle memory information, the CPU occupation information, and the memory occupation information;
the sending and executing module 204 is configured to send the task feasibility file to the target task node, so that the target task node executes the task feasibility file.
The invention discloses a task management device based on Agent, which adds Agent in task node in advance, comprising: receiving at least one task to be processed, wherein the type of the task to be processed is any one of preset types, and the task to be processed comprises the following steps: starting a command, CPU occupation information, memory occupation information and a task executable file; receiving idle CPU information and idle memory information of each task node; determining a target task node based on each idle CPU information and corresponding idle memory information, CPU occupation information and memory occupation information; and sending the task feasibility file to the target task node so that the target task node executes the task feasibility file. According to the device, the Agents are added into the task nodes, the tasks to be processed are executed through the Agens, the types of the tasks to be processed are not limited, the management of various types of the tasks to be processed is realized, and the processing speed is improved.
In this embodiment of the present invention, the determining module 203 includes:
a comparison unit 205 and a determination unit 206.
Wherein,
the comparing unit 205 is configured to traverse each idle CPU information and its corresponding idle memory information, and compare the CPU occupancy information and the memory occupancy information with each idle CPU information and corresponding idle memory information;
the determining unit 206 is configured to use a task node whose idle CPU information is greater than or equal to the CPU occupation information and whose corresponding idle memory information is greater than or equal to the memory occupation information as the target task node.
In this embodiment of the present invention, the management apparatus further includes: a storage module 207.
The storage module 207 is configured to store the to-be-processed task, the idle CPU information and the corresponding idle memory information.
In this embodiment of the present invention, the management apparatus further includes:
a receiving module 208 and a marking module 209.
Wherein,
the receiving module 208 is configured to receive an execution result of the task to be processed, which is fed back by the target task node;
the marking module 209 is configured to mark the execution result.
In this embodiment of the present invention, the management apparatus further includes:
a statistics module 210, a comparison module 211, and a discard module 212.
Wherein,
the counting module 210 is configured to count failure times of executing a failed to-be-processed task in the to-be-processed tasks at intervals of a preset time length;
the comparing module 211 is configured to compare the failure times with a preset failure time threshold;
the abandoning module 212 is configured to abandon the processing of the to-be-processed task whose failure frequency reaches the preset failure threshold.
It should be noted that the message pushing apparatus may include a processor and a memory, and the receiving and acquiring module 201, the receiving module 202, the determining module 203, and the sending and executing module 204, etc. are all stored in the memory as program units, and the processor executes the program units stored in the memory to implement corresponding functions.
The processor may include a kernel, which calls the corresponding program unit from the memory. The number of the kernels can be one or more, agents are added into the task nodes by adjusting kernel parameters, the tasks to be processed are executed through the agents, the types of the tasks to be processed are not limited, the management of various types of the tasks to be processed is realized, and the processing speed is improved.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
The embodiment of the application provides a computer readable medium, wherein a computer program is stored on the computer readable medium, and when the computer program is executed by a processor, the Agent-based task management method described in the embodiment of the method is realized.
The embodiment of the application provides a processor, wherein the processor is used for running a program, and the program realizes the Agent-based task management method described in the above method embodiment when running.
The embodiment of the application provides equipment, which comprises a processor, a memory and a program which is stored on the memory and can run on the processor, wherein when the processor executes the program, the Agent-based task management method described in the embodiment of the method is realized.
The present application also provides a computer program product which, when executed on a data processing device, causes the data processing device to implement the Agent-based task management method described in the above method embodiments. The management method adds an Agent in a task node in advance, and comprises the following steps:
receiving at least one task to be processed, wherein the type of the task to be processed is any one of preset types, and acquiring a starting command, CPU occupation information, memory occupation information and a task executable file in the task to be processed;
receiving idle CPU information and idle memory information of each task node;
determining a target task node based on each idle CPU information and corresponding idle memory information, the CPU occupation information and the memory occupation information;
and sending the task feasibility file to the target task node so as to enable the target task node to execute the task feasibility file.
Optionally, the method for determining a target task node based on each idle CPU information and idle memory information, the CPU occupation information, and the memory occupation information includes:
traversing each idle CPU information and corresponding idle memory information, and comparing the CPU occupation information and the memory occupation information with each idle CPU information and corresponding idle memory information;
and taking the task node with idle CPU information more than or equal to the CPU occupation information and corresponding idle memory information more than or equal to the memory occupation information as the target task node.
The above method, optionally, further includes:
and storing the task to be processed, the idle CPU information and the corresponding idle memory information.
The above method, optionally, further includes:
receiving an execution result of the task to be processed fed back by the target task node;
and marking the execution result.
The above method, optionally, further includes:
counting the failure times of executing failed tasks to be processed in the tasks to be processed at intervals of preset time;
comparing the failure times with a preset failure time threshold;
and giving up the processing of the tasks to be processed with the failure times reaching the preset failure threshold value.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above description is only for the purpose of illustrating the preferred embodiments of the present application and the technical principles applied, and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. The scope of the invention according to the present application is not limited to the specific combinations of the above-described features, and may also cover other embodiments in which the above-described features or their equivalents are arbitrarily combined without departing from the spirit of the invention. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.