CN107807815B - Method and apparatus for distributed processing tasks - Google Patents
Method and apparatus for distributed processing tasks Download PDFInfo
- Publication number
- CN107807815B CN107807815B CN201710976299.8A CN201710976299A CN107807815B CN 107807815 B CN107807815 B CN 107807815B CN 201710976299 A CN201710976299 A CN 201710976299A CN 107807815 B CN107807815 B CN 107807815B
- Authority
- CN
- China
- Prior art keywords
- task
- compilation
- executed
- deployment
- request
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
- Multi Processors (AREA)
Abstract
本发明提供一种分布式处理任务的方法和装置,其中,该方法包括:接收待执行任务的任务请求;根据所述任务请求,选择执行所述待执行任务的任务编译部署节点,并将所述待执行任务发送至所述任务编译部署节点进行执行。本发明实施例提供的分布式处理任务的方法和装置,通过建立包含最大并发数量的任务编译部署节点的任务编译部署节点集合处理多个任务请求并且能够根据处理的任务数量实时创建任务编译部署节点以满足对大规模请求任务的处理需求,有效解决了单个任务编译部署节点的面对处理大规模任务时的瓶颈问题。
The present invention provides a method and device for distributed processing tasks, wherein the method includes: receiving a task request for a task to be executed; according to the task request, selecting a task compilation and deployment node that executes the to-be-executed task, and deploying the The to-be-executed task is sent to the task compilation and deployment node for execution. The method and device for distributed processing tasks provided by the embodiments of the present invention process multiple task requests by establishing a task compilation and deployment node set including the maximum concurrent task compilation and deployment nodes, and can create task compilation and deployment nodes in real time according to the number of processed tasks In order to meet the processing requirements of large-scale request tasks, it effectively solves the bottleneck problem of a single task compilation and deployment node when dealing with large-scale tasks.
Description
技术领域technical field
本发明涉及计算机技术领域,尤其涉及一种分布式处理任务的方法和装置。The present invention relates to the field of computer technology, and in particular, to a method and device for distributed processing tasks.
背景技术Background technique
持续集成工具可以用于监控持续重复的工作,包括:持续的软件版本发布/测试项目以及监控外部调用执行的工作。持续集成工具中各任务编译部署节点可以用来实现大规模的部署编译任务的处理。在持续集成工具构建的分布式任务编译部署系统中,任务编译部署节点在处理大规模部署编译任务时容易陷入性能瓶颈或者单个任务编译部署节点上任务压力过大的问题。Continuous integration tools can be used to monitor ongoing repetitive work, including: continuous software release/testing projects and monitoring work performed by external calls. Each task compilation and deployment node in the continuous integration tool can be used to realize the processing of large-scale deployment and compilation tasks. In a distributed task compilation and deployment system built by continuous integration tools, task compilation and deployment nodes are prone to fall into performance bottlenecks when processing large-scale deployment and compilation tasks, or the task pressure on a single task compilation and deployment node is too large.
以Jenkins为例,Jenkins是基于Java开发的一种持续集成工具。Jenkins的分布式构建的整套环境需要一个中心服务器(Jenkins Master节点)和若干测试机器(Slave节点)组成,其中,Jenkins Master节点负责任务的调度以及元数据和调度结果的保存,JenkinsSlave节点负责任务的具体执行,并将结果返回给Jenkins Master节点,从而能够让同一套代码或项目在不同的环境中编译、部署等。Take Jenkins as an example, Jenkins is a continuous integration tool developed based on Java. The entire environment of Jenkins' distributed construction requires a central server (Jenkins Master node) and several test machines (Slave nodes). Among them, the Jenkins Master node is responsible for task scheduling and the preservation of metadata and scheduling results, and the Jenkins Slave node is responsible for task scheduling. Specific execution, and the result is returned to the Jenkins Master node, so that the same set of code or project can be compiled and deployed in different environments.
关于Jenkins的架构,在现有技术中存在以下三种形式:Regarding the architecture of Jenkins, there are the following three forms in the prior art:
(一)Jenkins单机模式(1) Jenkins stand-alone mode
如图1所示,该模式是指部署的Jenkins服务器不仅是Jenkins Master节点也是Jenkins Slave节点,Jenkins服务器在接收到构建或者部署请求时就会在本机执行这些任务。As shown in Figure 1, this mode means that the deployed Jenkins server is not only a Jenkins Master node but also a Jenkins Slave node. The Jenkins server will execute these tasks locally when it receives a build or deployment request.
(二)结合单个Jenkins Master和静态多个Jenkins Slave模式(2) Combine a single Jenkins Master and static multiple Jenkins Slave modes
如图2所示,该模式是指部署一个Jenkins Master节点和多个Jenkins Slave节点,这些Jenkins Slave节点是事先创建好,并注册到Jenkins Master节点上供JenkinsMaster调度使用。当Jenkins Master收到请求时,会选择Jenkins Slave,并将任务调度到Jenkins Slave上执行,执行完成后,任务的元数据和结果保存在Jenkins Master上。As shown in Figure 2, this mode refers to deploying a Jenkins Master node and multiple Jenkins Slave nodes. These Jenkins Slave nodes are created in advance and registered on the Jenkins Master node for JenkinsMaster scheduling. When the Jenkins Master receives the request, it will select the Jenkins Slave and schedule the task to be executed on the Jenkins Slave. After the execution is completed, the metadata and results of the task are saved on the Jenkins Master.
(三)结合单个Jenkins Master和动态多个Jenkins Slave模式(3) Combining a single Jenkins Master and dynamic multiple Jenkins Slave modes
如图3所示,该模式是指部署一个Jenkins Master节点和多个动态Jenkins Slave节点,Jenkins Slave节点是执行任务的时候创建的,并动态的注册到Jenkins Master节点上供Jenkins Master调度使用。当Jenkins Master收到请求时,会通过K8s插件创建合适的Jenkins Slave节点,并将任务调度到Jenkins Slave节点上执行,执行完成后,JenkinsSlave节点会被销毁,任务的元数据和结果保存在Jenkins Master上。As shown in Figure 3, this mode refers to deploying a Jenkins Master node and multiple dynamic Jenkins Slave nodes. The Jenkins Slave node is created when a task is executed, and is dynamically registered on the Jenkins Master node for Jenkins Master scheduling. When the Jenkins Master receives the request, it will create a suitable Jenkins Slave node through the K8s plug-in, and schedule the task to the Jenkins Slave node for execution. After the execution is completed, the Jenkins Slave node will be destroyed, and the metadata and results of the task will be saved in the Jenkins Master. superior.
然而,现有技术中存在以下缺点:However, there are the following disadvantages in the prior art:
(1)关于Jenkins单机模式(1) About Jenkins stand-alone mode
由于Jenkins单机模式只适合处理小规模的任务,因此当任务数量增加时,所有的待处理任务将在一台机器上执行,由此增加了机器负载,最终导致服务器崩溃。Since Jenkins single-machine mode is only suitable for processing small-scale tasks, when the number of tasks increases, all pending tasks will be executed on one machine, thereby increasing the machine load and eventually causing the server to crash.
(2)关于结合单个Master和静态多个Jenkins Slave模式(2) About combining a single Master and static multiple Jenkins Slave modes
虽然,静态Slave模式可以避免前述单机模式中的大量任务在同一台机器执行的问题,但是Slave节点的个数仍然是确定的,而且每次增加Slave节点都需要手动注册,因此操作非常麻烦,并且当任务超过一定规模时,Master节点上的压力会非常大。Although the static slave mode can avoid the problem of executing a large number of tasks on the same machine in the aforementioned single-machine mode, the number of slave nodes is still determined, and manual registration is required every time a slave node is added, so the operation is very troublesome, and When the task exceeds a certain scale, the pressure on the Master node will be very large.
(3)关于集合单个Master和动态多个Jenkins Slave模式(3) About the collection of a single Master and dynamic multiple Jenkins Slave modes
虽然动态创建Jenkins Slave模式可以省去手动注册的麻烦,并且Jenkins Slave节点无需始终存在,只需在有任务请求时才需要,但是这种方式仍然无法解决处理大规模任务的问题,即当任务规模超出处理能力时(例如,超过10000),此时单个Jenkins Master的性能会非常差,从而直接导致Jenkins Master节点无法工作。Although the dynamic creation of Jenkins Slave mode can save the trouble of manual registration, and the Jenkins Slave node does not need to exist all the time, only when there is a task request, but this method still cannot solve the problem of processing large-scale tasks, that is, when the task scale When the processing capacity is exceeded (for example, more than 10,000), the performance of a single Jenkins Master will be very poor, which directly causes the Jenkins Master node to fail to work.
发明内容SUMMARY OF THE INVENTION
有鉴于此,本发明实施例提供一种分布式处理任务的方法和装置,以解决现有技术中单个任务编译部署节点面对处理大规模任务时的瓶颈问题。In view of this, embodiments of the present invention provide a method and apparatus for distributed processing tasks, so as to solve the bottleneck problem in the prior art when a single task compilation and deployment node faces large-scale tasks.
为实现上述目的,根据本发明实施例的一个方面,提供了一种分布式处理任务的方法,该方法包括:In order to achieve the above object, according to an aspect of the embodiments of the present invention, a method for distributed processing tasks is provided, and the method includes:
接收待执行任务的任务请求;Receive task requests for tasks to be executed;
根据所述任务请求,选择执行所述待执行任务的任务编译部署节点,并将所述待执行任务发送至所述任务编译部署节点进行执行。According to the task request, a task compilation and deployment node that executes the to-be-executed task is selected, and the to-be-executed task is sent to the task compilation and deployment node for execution.
可选地,该方法还包括:在接收待执行任务的任务请求之前,创建预设数量的任务编译部署节点,其中,所述预设数量是指不小于所述待执行任务的最大并发数的数量。Optionally, the method further includes: before receiving a task request for a task to be executed, creating a preset number of task compilation and deployment nodes, wherein the preset number refers to a maximum number of concurrent tasks not less than the maximum number of tasks to be executed. quantity.
可选地,在创建预设数量的任务编译部署节点的步骤中,包括:通过集群管理系统创建包含预设数量的所述任务编译部署节点的任务编译部署节点集合。Optionally, in the step of creating a preset number of task compilation and deployment nodes, the method includes: creating, by a cluster management system, a task compilation and deployment node set including a preset number of the task compilation and deployment nodes.
可选地,该方法还包括:在创建所述预设数量的任务编译部署节点之后,将所述任务编译部署节点的信息保存至数据库中,其中,所述信息包括以下至少一项内容:每个任务编译部署节点的服务器的IP地址、运行状态、已经执行完成任务的任务数量,其中所述运行状态包括空闲状态和工作状态。Optionally, the method further includes: after creating the preset number of task compilation and deployment nodes, saving the information of the task compilation and deployment nodes in a database, where the information includes at least one of the following: each The IP address of the server of each task compilation and deployment node, the running state, and the number of tasks that have been executed to complete the task, wherein the running state includes an idle state and a working state.
可选地,根据所述任务请求,选择执行所述待执行任务的任务编译部署节点,并将所述待执行任务发送至所述任务编译部署节点进行执行包括:Optionally, according to the task request, selecting a task compilation and deployment node that executes the to-be-executed task, and sending the to-be-executed task to the task compilation and deployment node for execution includes:
在接收到待执行任务为编译任务的任务请求之后,将所述编译任务的任务请求信息保存至所述数据库中,并根据所述编译任务的任务请求从所述数据库中选择符合预设条件的任务编译部署节点,然后将所述编译任务的任务请求发送至所述符合预设条件的任务编译部署节点进行执行。After receiving the task request that the task to be executed is a compilation task, save the task request information of the compilation task in the database, and select the task request that meets the preset conditions from the database according to the task request of the compilation task. The task compilation and deployment node sends the task request of the compilation task to the task compilation and deployment node that meets the preset conditions for execution.
可选地,根据所述任务请求,选择执行所述待执行任务的任务编译部署节点,并将所述待执行任务发送至所述任务编译部署节点进行执行还包括:Optionally, according to the task request, selecting a task compilation and deployment node that executes the to-be-executed task, and sending the to-be-executed task to the task compilation and deployment node for execution further includes:
在接收到待执行任务为编译任务的任务请求之前,根据接收到的创建任务的任务请求,将所述创建任务的任务请求信息保存至所述数据库中。Before receiving the task request that the task to be executed is the compilation task, according to the received task request of creating the task, the task request information of the creating task is stored in the database.
可选地,根据所述编译任务的任务请求从所述数据库中选择符合预设条件的任务编译部署节点包括:Optionally, selecting a task compilation and deployment node that meets preset conditions from the database according to the task request of the compilation task includes:
获取所述数据库中保存的运行状态为空闲状态的任务编译部署节点的列表,并从所述列表中选择已经执行完成任务的任务数量最少的任务编译部署节点;以及Obtaining a list of task compilation and deployment nodes whose running state is the idle state saved in the database, and selecting the task compilation and deployment node with the least number of tasks that have completed the task from the list; and
如果所述数据库中没有运行状态为空闲状态的任务编译部署节点,则通过所述集群管理系统创建一个新的任务编译部署节点作为执行所述编译任务的任务编译部署节点。If there is no task compilation and deployment node whose running state is idle state in the database, a new task compilation and deployment node is created by the cluster management system as the task compilation and deployment node for executing the compilation task.
可选地,该方法还包括:在选择执行所述待执行任务的任务编译部署节点之后,将所述任务编译部署节点的运行状态设置为工作状态;以及Optionally, the method further includes: after selecting a task compilation and deployment node that executes the task to be executed, setting the running state of the task compilation and deployment node to a working state; and
在所述待执行任务执行完毕之后,保存所述待执行任务的结果信息,并将所述任务编译部署节点的运行状态设置为空闲状态。After the execution of the to-be-executed task is completed, the result information of the to-be-executed task is saved, and the running state of the task compilation and deployment node is set to an idle state.
本发明实施例的一个方面,提供了一种分布式处理任务的装置,该装置包括:In one aspect of the embodiments of the present invention, an apparatus for distributed processing tasks is provided, and the apparatus includes:
接收模块,用于接收待执行任务的任务请求;The receiving module is used to receive the task request of the task to be executed;
执行模块,用于根据所述任务请求,选择执行所述待执行任务的任务编译部署节点,并将所述待执行任务发送至所述任务编译部署节点进行执行。The execution module is configured to select, according to the task request, a task compilation and deployment node that executes the to-be-executed task, and send the to-be-executed task to the task compilation and deployment node for execution.
可选地,该装置还包括:创建模块,用于在接收待执行任务的任务请求之前,创建预设数量的任务编译部署节点,其中,所述预设数量是指不小于所述待执行任务的最大并发数的数量。Optionally, the device further includes: a creation module, configured to create a preset number of task compilation and deployment nodes before receiving a task request for a task to be executed, wherein the preset number refers to not less than the task to be executed. The maximum number of concurrency.
可选地,所述创建模块还用于:通过集群管理系统创建包含预设数量的所述任务编译部署节点的任务编译部署节集合。Optionally, the creating module is further configured to: create a task compilation and deployment section set including a preset number of the task compilation and deployment nodes through the cluster management system.
可选地,该装置还包括:存储模块,用于在创建所述预设数量的任务编译部署节点之后,将所述任务编译部署节点的信息保存至数据库中,其中,所述信息包括以下至少一项内容:每个所述任务编译部署节点的服务器的IP地址、运行状态、已经执行完成任务的任务数量,其中所述运行状态包括空闲状态和工作状态。Optionally, the apparatus further includes: a storage module, configured to save the information of the task compilation and deployment nodes in a database after the preset number of task compilation and deployment nodes are created, wherein the information includes at least the following: One item: the IP address of the server of each task compilation and deployment node, the running state, and the number of tasks that have completed the task, wherein the running state includes an idle state and a working state.
可选地,所述执行模块还用于:将所述编译任务的任务请求信息保存至所述数据库中,并根据所述编译任务的任务请求从所述数据库中选择符合预设条件的任务编译部署节点,然后将所述编译任务的任务请求发送至所述符合预设条件的任务编译部署节点进行执行。Optionally, the execution module is further configured to: save the task request information of the compilation task in the database, and select a task compilation that meets preset conditions from the database according to the task request of the compilation task. The deployment node, and then send the task request of the compilation task to the task compilation and deployment node that meets the preset conditions for execution.
可选地,所述执行模块还用于:在接收到待执行任务为编译任务的任务请求之前,根据接收到的创建任务的任务请求,将所述创建任务的任务请求信息保存至所述数据库中。Optionally, the execution module is further configured to: before receiving the task request that the task to be executed is the compilation task, according to the received task request for creating the task, save the task request information of the creating task to the database middle.
可选地,所述执行模块还用于:获取所述数据库中保存的运行状态为空闲状态的任务编译部署节点的列表,并从所述列表中选择已经执行完成任务的任务数量最少的任务编译部署节点;以及Optionally, the execution module is further configured to: obtain a list of task compilation and deployment nodes that are stored in the database and whose running state is an idle state, and select a task compilation with the least number of tasks that have completed tasks from the list. deploying nodes; and
如果所述数据库中没有运行状态为空闲状态的任务编译部署节点,则通过所述集群管理系统创建一个新的任务编译部署节点作为执行所述编译任务的任务编译部署节点。If there is no task compilation and deployment node whose running state is idle state in the database, a new task compilation and deployment node is created by the cluster management system as the task compilation and deployment node for executing the compilation task.
可选地,该装置还包括:设置模块,用于在选择执行所述待执行任务的任务编译部署节点之后,将所述任务编译部署节点的运行状态设置为工作状态;以及在所述待执行任务执行完毕之后,保存所述待执行任务的结果信息,并将所述任务编译部署节点的运行状态设置为空闲状态。Optionally, the device further includes: a setting module, configured to set the running state of the task compiling and deploying node to a working state after selecting the task compiling and deploying node that executes the to-be-executed task; After the task is executed, the result information of the to-be-executed task is saved, and the running state of the task compilation and deployment node is set to an idle state.
本发明实施例还提供一种分布式处理任务的终端设备,包括:一个或多个处理器;存储装置,用于存储一个或多个程序,当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如本发明实施例的分布式处理任务的方法。An embodiment of the present invention further provides a terminal device for distributed processing tasks, including: one or more processors; and a storage device for storing one or more programs, when the one or more programs are executed by the one or more programs A plurality of processors execute, such that the one or more processors implement the method for distributing processing tasks according to an embodiment of the present invention.
本发明实施例还提供一种计算机可读介质,其上存储有计算机程序,所述程序被处理器执行时实现如本发明实施例的分布式处理任务的方法。Embodiments of the present invention further provide a computer-readable medium, on which a computer program is stored, and when the program is executed by a processor, implements the method for distributed processing tasks according to the embodiments of the present invention.
本发明实施例提供的分布式处理任务的方法和装置,能够解决了单个任务编译部署节点的面对处理大规模任务时的瓶颈问题;通过创建包含最大并发数量的任务编译部署节点的任务编译部署节点集合,从而能够使得该分布式系统能够具有多个任务编译部署节点以便于处理多个任务请求;通过将创建的任务编译部署节点的信息保存至数据库中,从而能够处理根据待执行任务的处理需求便于选择任务编译部署节点执行待处理任务;通过根据所述编译任务的任务请求从数据库中选择符合预设条件的任务编译部署节点,然后将编译任务的任务请求发送至符合预设条件的任务编译部署节点进行执行,从而能够选择满足条件的任务编译部署节点执行相应的待执行任务;通过将任务编译部署节点的信息保存至数据库中,从而实现对任务编译部署节点信息的数据持久化,以便后续处理时可以方便的获取数据和/或随时查看数据;通过获取数据库中保存的运行状态为空闲状态的任务编译部署节点的列表,并从列表中选择已经执行完成任务的任务数量最少的任务编译部署节点;以及如果数据库中没有运行状态为空闲状态的任务编译部署节点,则通过集群管理系统创建一个新的任务编译部署节点作为执行所述编译任务的任务编译部署节点,从而能够选择出满足预设条件的任务编译部署节点执行待处理任务。The method and device for distributed processing tasks provided by the embodiments of the present invention can solve the bottleneck problem of a single task compiling and deploying node when dealing with large-scale tasks; by creating a task compiling and deploying node that includes the maximum concurrent number of task compiling and deploying nodes A set of nodes, so that the distributed system can have multiple task compilation and deployment nodes so as to process multiple task requests; by saving the information of the created task compilation and deployment nodes in the database, the processing according to the tasks to be executed can be processed. The requirement is convenient to select the task compilation and deployment node to execute the pending task; select the task compilation and deployment node that meets the preset conditions from the database according to the task request of the compilation task, and then send the task request of the compilation task to the task that meets the preset conditions. Compile and deploy nodes for execution, so that the task compilation and deployment nodes that meet the conditions can be selected to execute the corresponding tasks to be executed; by saving the information of the task compilation and deployment nodes in the database, the data persistence of the task compilation and deployment node information is realized, so that Data can be easily obtained and/or viewed at any time during subsequent processing; the list of deployment nodes can be compiled and deployed by obtaining the tasks saved in the database whose running state is idle, and the task compilation with the least number of tasks that have completed tasks is selected from the list. deployment node; and if there is no task compilation deployment node whose running state is an idle state in the database, a new task compilation deployment node is created by the cluster management system as the task compilation deployment node for executing the compilation task, so that a task compilation deployment node that satisfies the predetermined requirements can be selected. Conditional tasks compile and deploy nodes to execute pending tasks.
上述的非惯用的可选方式所具有的进一步效果将在下文中结合具体实施方式加以说明。Further effects of the above non-conventional alternatives will be described below in conjunction with specific embodiments.
附图说明Description of drawings
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。在附图中:In order to illustrate the technical solutions in the embodiments of the present invention more clearly, the following briefly introduces the accompanying drawings used in the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained from these drawings without creative effort. In the attached image:
图1是现有技术中关于Jenkins的架构中的Jenkins单机模式的示意图;Fig. 1 is the schematic diagram of the Jenkins stand-alone mode in the architecture of Jenkins in the prior art;
图2是现有技术中关于Jenkins的架构中的结合单个Master和静态多个Slave模式的示意图;Fig. 2 is a schematic diagram of combining a single Master and static multiple slave modes in the architecture of Jenkins in the prior art;
图3是现有技术中关于Jenkins的架构中的结合单个Master和动态多个Slave模式的示意图;3 is a schematic diagram of combining a single Master and dynamic multiple slave modes in the architecture of Jenkins in the prior art;
图4是根据本发明实施例的分布式处理任务的方法的主要流程的示意图;4 is a schematic diagram of a main flow of a method for distributed processing tasks according to an embodiment of the present invention;
图5是根据本发明实施例的分布式处理任务的装置的主要模块的示意图;5 is a schematic diagram of main modules of an apparatus for distributed processing tasks according to an embodiment of the present invention;
图6是适于用来实现本发明实施例的终端设备的计算机系统的结构示意图。FIG. 6 is a schematic structural diagram of a computer system suitable for implementing a terminal device according to an embodiment of the present invention.
具体实施方式Detailed ways
以下结合附图对本发明的示范性实施例做出说明,其中包括本发明实施例的各种细节以助于理解,应当将它们认为仅仅是示范性的。因此,本领域普通技术人员应当认识到,可以对这里描述的实施例做出各种改变和修改,而不会背离本发明的范围和精神。同样,为了清楚和简明,以下的描述中省略了对公知功能和结构的描述。Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, which include various details of the embodiments of the present invention to facilitate understanding and should be considered as exemplary only. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted from the following description for clarity and conciseness.
在本文中,需要理解的是,所涉及的术语中:In this article, it is to be understood that among the terms involved:
Jenkins:是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能。Jenkins: It is an open source software project and a continuous integration tool developed based on Java to monitor continuous repetitive work. It aims to provide an open and easy-to-use software platform to make continuous software integration possible.
Kubernetes:简称为k8s,是自动化容器操作的开源平台,是一种用于实现容器化应用集群管理的系统,这些操作包括部署,调度和节点集群间扩展。Kubernetes不仅仅支持Docker,还支持Rocket,这是另一种容器技术。Kubernetes: referred to as k8s, is an open source platform for automating container operations. It is a system for implementing cluster management of containerized applications, including deployment, scheduling, and scaling between node clusters. Kubernetes not only supports Docker, but also Rocket, another container technology.
MySQL:是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle旗下产品。MySQL是最流行的关系型数据库管理系统之一,在WEB应用方面,MySQL是最好的RDBMS(Relational Database Management System,关系数据库管理系统)应用软件。MySQL: It is a relational database management system, developed by the Swedish MySQL AB company, and is currently a product of Oracle. MySQL is one of the most popular relational database management systems. In terms of WEB applications, MySQL is the best RDBMS (Relational Database Management System) application software.
示例性方法Exemplary method
如图4所示,提供了一种分布式处理任务的方法,该方法包括:As shown in Figure 4, a method for distributed processing tasks is provided, and the method includes:
步骤S401:接收待执行任务的任务请求;Step S401: receiving a task request for a task to be executed;
步骤S402:根据所述任务请求,选择执行所述待执行任务的任务编译部署节点Jenkins Master,并将所述待执行任务发送至所述任务编译部署节点进行执行。本发明实施例中,任务编译部署节点可以但不限于是Jenkins持续集成工具中的Jenkins Master。以下以Jenkins Master为例,进行任务编译部署节点的创建和任务处理的说明。Step S402: According to the task request, select a task compilation and deployment node Jenkins Master that executes the task to be performed, and send the to-be-executed task to the task compilation and deployment node for execution. In the embodiment of the present invention, the task compilation and deployment node may be, but is not limited to, the Jenkins Master in the Jenkins continuous integration tool. The following takes Jenkins Master as an example to describe the creation of task compilation and deployment nodes and task processing.
可选地,该方法还包括:在接收待执行任务的任务请求之前,创建预设数量的Jenkins Master,其中,所述预设数量是指不小于所述待执行任务的最大并发数的数量。Optionally, the method further includes: before receiving the task request for the task to be executed, creating a preset number of Jenkins Masters, where the preset number refers to a number that is not less than the maximum concurrent number of the to-be-executed task.
可选地,在创建预设数量的Jenkins Master的步骤中,包括:Optionally, in the step of creating a preset number of Jenkins Masters, including:
通过Kubernetes系统创建包含预设数量的所述Jenkins Master的JenkinsMaster集合。A JenkinsMaster collection containing a preset number of said Jenkins Masters is created by the Kubernetes system.
可选地,该方法还包括:在创建所述预设数量的Jenkins Master之后,将所述Jenkins Master的信息保存至数据库中,其中,所述信息包括以下至少一项内容:每个Jenkins Master的服务器的IP地址、运行状态、已经执行完成任务的任务数量,其中所述运行状态包括空闲状态和工作状态。Optionally, the method further includes: after creating the preset number of Jenkins Masters, saving the information of the Jenkins Master into a database, wherein the information includes at least one of the following: The IP address of the server, the running status, and the number of tasks that have been executed and completed, wherein the running status includes an idle status and a working status.
可选地,根据所述任务请求,选择执行所述待执行任务的Jenkins Master,并将所述待执行任务发送至所述Jenkins Master进行执行包括:在接收到待执行任务为编译任务的任务请求之后,将所述编译任务的任务请求信息保存至所述数据库中,并根据所述编译任务的任务请求从所述数据库中选择符合预设条件的Jenkins Master,然后将所述编译任务的任务请求发送至所述符合预设条件的Jenkins Master进行执行。Optionally, according to the task request, selecting the Jenkins Master that executes the task to be executed, and sending the task to be executed to the Jenkins Master for execution includes: receiving a task request that the task to be executed is a compilation task After that, the task request information of the compilation task is saved in the database, and a Jenkins Master that meets the preset conditions is selected from the database according to the task request of the compilation task, and then the task request of the compilation task is selected from the database. Send it to the Jenkins Master that meets the preset conditions for execution.
可选地,根据所述任务请求,选择执行所述待执行任务的Jenkins Master,并将所述待执行任务发送至所述Jenkins Master进行执行还包括:Optionally, according to the task request, selecting the Jenkins Master that executes the task to be executed, and sending the task to be executed to the Jenkins Master for execution further includes:
在接收到待执行任务为编译任务的任务请求之前,根据接收到的创建任务的任务请求,将所述创建任务的任务请求信息保存至所述数据库中。Before receiving the task request that the task to be executed is the compilation task, according to the received task request of creating the task, the task request information of the creating task is stored in the database.
可选地,根据所述编译任务的任务请求从所述数据库中选择符合预设条件的Jenkins Master包括:Optionally, selecting a Jenkins Master that meets preset conditions from the database according to the task request of the compilation task includes:
获取所述数据库中保存的运行状态为空闲状态的Jenkins Master的列表,并从所述列表中选择已经执行完成任务的任务数量最少的Jenkins Master;以及Acquiring a list of Jenkins Masters whose running states are idle states saved in the database, and selecting from the list the Jenkins Master that has the least number of tasks that have completed tasks; and
如果所述数据库中没有运行状态为空闲状态的Jenkins Master,则通过所述Kubernetes系统创建一个新的Jenkins Master作为执行所述编译任务的Jenkins Master。If there is no Jenkins Master whose running state is in the idle state in the database, a new Jenkins Master is created through the Kubernetes system as the Jenkins Master that executes the compilation task.
可选地,该方法还包括:在选择执行所述待执行任务的Jenkins Master之后,将所述Jenkins Master的运行状态设置为工作状态;以及Optionally, the method further includes: after selecting the Jenkins Master that executes the task to be executed, setting the running state of the Jenkins Master to a working state; and
在所述待执行任务执行完毕之后,保存所述待执行任务的结果信息,并将所述Jenkins Master的运行状态设置为空闲状态。After the execution of the to-be-executed task is completed, the result information of the to-be-executed task is saved, and the running state of the Jenkins Master is set to an idle state.
实施例Example
下面结合一个具体实施例对本发明进行具体描述,然而值得注意的是该具体实施例仅是为了更好地描述本发明,并不构成对本发明的不当限定。The present invention will be specifically described below with reference to a specific embodiment, however, it should be noted that the specific embodiment is only for better describing the present invention, and does not constitute an improper limitation of the present invention.
首先,根据任务的处理需求,通过Kubernetes系统创建包含预设数量的JenkinsMaster的Jenkins Master集合(Jenkins Master Pool),将该Jenkins Master集合中的每个Jenkins Master的信息保存到Mysql数据库的Server表中,其中,Server表中记录的信息至少包括:每个Master的服务器的IP地址、该Master的状态是否为空闲以及该Master已经执行完成任务的个数中的一个或多个。First, according to the processing requirements of the task, a Jenkins Master pool (Jenkins Master Pool) containing a preset number of JenkinsMasters is created through the Kubernetes system, and the information of each Jenkins Master in the Jenkins Master collection is saved to the Server table of the Mysql database. The information recorded in the Server table includes at least one or more of the IP address of the server of each Master, whether the status of the Master is idle, and the number of tasks that the Master has performed.
然后,在应用程序接口(API)接收到任务请求之后,判断该任务请求的请求类型。Then, after the application program interface (API) receives the task request, the request type of the task request is determined.
如果该任务请求为“创建任务”的任务请求,则向Mysql数据库中的Job表中插入一条记录。具体来说,由于原生的Jenkins会将任务通过文本的方式保存在本地,因此只有本地的Jenkins才会查询并获取这个任务,而在本发明实施例中插入记录的目的在于将这条任务信息保存至数据库,以便于将来对该任务进行编译的时候可以从该数据库中获取该任务,再从Jenkins Master集合(Jenkins Master Pool)中选择一台Jenkins Master执行该任务;If the task request is a "create task" task request, insert a record into the Job table in the Mysql database. Specifically, since the native Jenkins will save the task locally in the form of text, only the local Jenkins will query and obtain this task, and the purpose of inserting a record in the embodiment of the present invention is to save this task information To the database, so that the task can be obtained from the database when the task is compiled in the future, and then select a Jenkins Master from the Jenkins Master collection (Jenkins Master Pool) to execute the task;
如果该任务请求为“编译任务”的请求时,首先向Mysql数据库中的Build表插入一条构建的记录。具体来说,将构建记录保存到Mysql数据库的目的在于为了方便用户以后查看这些记录,即使当时执行这条构建记录的Jenkins Master被销毁了,我们依然可以从Mysql数据库中查看这条记录。然后,再从Server表中选择一个满足预设条件的Master来处理该任务。具体来说,该预设条件如下:If the task request is a "compile task" request, first insert a build record into the Build table in the Mysql database. Specifically, the purpose of saving the build record to the Mysql database is to facilitate users to view these records in the future. Even if the Jenkins Master that executed the build record at that time is destroyed, we can still view this record from the Mysql database. Then, select a Master that satisfies the preset conditions from the Server table to process the task. Specifically, the preset conditions are as follows:
第一,从Server表中筛选出空闲的Master列表;First, filter out the idle Master list from the Server table;
第二,针对空闲的Jenkins Master列表中,按照已经执行完成任务的个数排序,从中选择已经执行完成任务的个数最小的Jenkins Master作为满足预设条件的JenkinsMaster;Second, in the list of idle Jenkins Masters, sort them according to the number of completed tasks, and select the Jenkins Master with the smallest number of completed tasks as the JenkinsMaster that meets the preset conditions;
第三,如果Server表中没有空闲的Jenkins Master,则通过Kubernetes系统动态创建一个新的Jenkins Master,将该新的Jenkins Master来处理该任务,并在Server表中插入这条新的Jenkins Master记录。Third, if there is no idle Jenkins Master in the Server table, a new Jenkins Master is dynamically created through the Kubernetes system, the new Jenkins Master handles the task, and the new Jenkins Master record is inserted into the Server table.
也就是说,当接收的所述任务请求包含所述待执行任务的任务数量大于所述预设数量时,则通过所述Kubernetes系统在所述Jenkins Master集合中继续创建所述任务数量与所述预设数量之差数量的所述Jenkins Master。That is to say, when the received task request includes the task to be executed and the number of tasks is greater than the preset number, the Kubernetes system continues to create the number of tasks and the number of tasks in the Jenkins Master set through the Kubernetes system. The difference between the preset number of said Jenkins Masters.
最后,待找到满足预设条件的Jenkins Master之后,将Server表中该Master记录信息中的状态设置为“工作状态”,并待该任务执行完毕之后,将该任务的结果信息保存到Build表中,再将该Jenkins Master的状态设置为“空闲状态”,以供后续使用。Finally, after finding a Jenkins Master that satisfies the preset conditions, set the status in the record information of the Master in the Server table to "working status", and after the task is executed, save the result information of the task to the Build table , and then set the state of the Jenkins Master to "idle state" for subsequent use.
通过本发明实施例提供的分布式处理任务的方法能够将大规模的任务由单个Jenkins Master节点前置到数据库中,然后将这些任务均匀的调度到各个Jenkins Master节点上,将单个Jenkins Master节点处理大规模任务的形式转换为多个Jenkins Master节点同时处理小规模的任务,有效解决了单个Jenkins Master节点处理多任务时遇到的瓶颈问题。The method for distributed processing tasks provided by the embodiments of the present invention can prepend large-scale tasks to the database from a single Jenkins Master node, and then evenly schedule these tasks to each Jenkins Master node, and process the single Jenkins Master node. The form of large-scale tasks is converted into multiple Jenkins Master nodes to process small-scale tasks at the same time, which effectively solves the bottleneck problem encountered when a single Jenkins Master node handles multiple tasks.
此外,在执行“编译”或“部署”任务时,该分布式系统只需要处理接收到的相应请求即可,无需应对和判断提出待处理任务的来源,从而将待处理任务和Jenkins服务解耦。In addition, when performing a "compile" or "deployment" task, the distributed system only needs to process the corresponding request received, and does not need to respond and judge the source of the pending task, thereby decoupling the pending task from the Jenkins service .
如图5所示,是根据本发明实施例的分布式处理任务的装置的主要模块的示意图;其中,该装置包括:As shown in FIG. 5 , it is a schematic diagram of main modules of an apparatus for distributed processing tasks according to an embodiment of the present invention; wherein, the apparatus includes:
接收模块501,用于接收待执行任务的任务请求;A receiving
执行模块502,用于根据所述任务请求,选择执行所述待执行任务的JenkinsMaster,并将所述待执行任务发送至所述Jenkins Master进行执行。The
可选地,该装置还包括:创建模块,用于在接收待执行任务的任务请求之前,创建预设数量的Jenkins Master,其中,所述预设数量是指不小于所述待执行任务的最大并发数的数量。Optionally, the device further includes: a creation module for creating a preset number of Jenkins Masters before receiving a task request for a task to be executed, wherein the preset number refers to a maximum number of not less than the task to be executed The number of concurrent counts.
可选地,所述创建模块还用于:通过Kubernetes系统创建包含预设数量的所述Jenkins Master的Jenkins Master集合。Optionally, the creation module is further configured to: create a Jenkins Master set including a preset number of the Jenkins Master through the Kubernetes system.
可选地,该装置还包括:存储模块,用于在创建所述预设数量的Jenkins Master之后,将所述Jenkins Master的信息保存至数据库中,其中,所述信息包括以下至少一项内容:每个所述Jenkins Master的服务器的IP地址、运行状态、已经执行完成任务的任务数量,其中所述运行状态包括空闲状态和工作状态。Optionally, the device further includes: a storage module for saving the information of the Jenkins Master in a database after creating the preset number of Jenkins Masters, wherein the information includes at least one of the following: The IP address of the server of each of the Jenkins Master, the running status, and the number of tasks that have been executed to complete the task, wherein the running status includes an idle status and a working status.
可选地,所述执行模块还用于:将所述编译任务的任务请求信息保存至所述数据库中,并根据所述编译任务的任务请求从所述数据库中选择符合预设条件的JenkinsMaster,然后将所述编译任务的任务请求发送至所述符合预设条件的Jenkins Master进行执行。Optionally, the execution module is further configured to: save the task request information of the compilation task in the database, and select a JenkinsMaster that meets preset conditions from the database according to the task request of the compilation task, Then, the task request of the compilation task is sent to the Jenkins Master that meets the preset conditions for execution.
可选地,所述执行模块还用于:在接收到待执行任务为编译任务的任务请求之前,根据接收到的创建任务的任务请求,将所述创建任务的任务请求信息保存至所述数据库中。Optionally, the execution module is further configured to: before receiving the task request that the task to be executed is the compilation task, according to the received task request for creating the task, save the task request information of the creating task to the database middle.
可选地,所述执行模块还用于:获取所述数据库中保存的运行状态为空闲状态的Jenkins Master的列表,并从所述列表中选择已经执行完成任务的任务数量最少的Jenkins Master;以及Optionally, the execution module is further configured to: obtain a list of Jenkins Masters whose running states are idle states saved in the database, and select from the list the Jenkins Master that has performed the least number of tasks that have completed tasks; and
如果所述数据库中没有运行状态为空闲状态的Jenkins Master,则通过所述Kubernetes系统创建一个新的Jenkins Master作为执行所述编译任务的Jenkins Master。If there is no Jenkins Master whose running state is in the idle state in the database, a new Jenkins Master is created through the Kubernetes system as the Jenkins Master that executes the compilation task.
可选地,该装置还包括:设置模块,用于在选择执行所述待执行任务的JenkinsMaster之后,将所述Jenkins Master的运行状态设置为工作状态;以及在所述待执行任务执行完毕之后,保存所述待执行任务的结果信息,并将所述Jenkins Master的运行状态设置为空闲状态。Optionally, the device further includes: a setting module, configured to set the running state of the Jenkins Master to a working state after selecting the JenkinsMaster that executes the task to be executed; and after the execution of the task to be executed is completed, The result information of the to-be-executed task is saved, and the running state of the Jenkins Master is set to an idle state.
由于本发明提供的分布式处理任务的装置是上述方法对应的装置,故不在此赘述。Since the device for distributed processing tasks provided by the present invention is a device corresponding to the above method, it is not repeated here.
下面参考图6,其示出了适于用来实现本发明实施例的终端设备的计算机系统600的结构示意图。图6示出的终端设备仅仅是一个示例,不应对本发明实施例的功能和使用范围带来任何限制。Referring to FIG. 6 below, it shows a schematic structural diagram of a
如图6所示,计算机系统600包括中央处理单元(CPU)601,其可以根据存储在只读存储器(ROM)602中的程序或者从存储部分608加载到随机访问存储器(RAM)603中的程序而执行各种适当的动作和处理。在RAM 603中,还存储有系统600操作所需的各种程序和数据。CPU 601、ROM 602以及RAM 603通过总线604彼此相连。输入/输出(I/O)接口605也连接至总线604。As shown in FIG. 6, a
以下部件连接至I/O接口605:包括键盘、鼠标等的输入部分606;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分607;包括硬盘等的存储部分608;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分609。通信部分609经由诸如因特网的网络执行通信处理。驱动器610也根据需要连接至I/O接口605。可拆卸介质611,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器610上,以便于从其上读出的计算机程序根据需要被安装入存储部分608。The following components are connected to the I/O interface 605: an
特别地,根据本发明公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本发明公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分609从网络上被下载和安装,和/或从可拆卸介质611被安装。在该计算机程序被中央处理单元(CPU)601执行时,执行本发明的系统中限定的上述功能。In particular, the processes described above with reference to the flowcharts may be implemented as computer software programs in accordance with the disclosed embodiments of the present invention. For example, embodiments disclosed herein include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the method illustrated in the flowchart. In such an embodiment, the computer program may be downloaded and installed from the network via the
需要说明的是,本发明所示的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本发明中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本发明中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the above two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or a combination of any of the above. More specific examples of computer readable storage media may include, but are not limited to, electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read only memory (ROM), erasable Programmable read only memory (EPROM or flash memory), fiber optics, portable compact disk read only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing. In the present invention, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, however, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code therein. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device . Program code embodied on a computer readable medium may be transmitted using any suitable medium including, but not limited to, wireless, wireline, optical fiber cable, RF, 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 invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code that contains one or more logical functions for implementing the specified functions executable instructions. It should also be noted that, in some alternative implementations, the functions noted in the blocks 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 is also noted that each block of the block diagrams or flowchart illustrations, and combinations of blocks in the block diagrams or flowchart illustrations, can be implemented in special purpose hardware-based systems that perform the specified functions or operations, or can be implemented using A combination of dedicated hardware and computer instructions is implemented.
描述于本发明实施例中所涉及到的模块可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的模块也可以设置在处理器中,例如,可以描述为:一种处理器包括接收模块501、执行模块502。其中,这些模块的名称在某种情况下并不构成对该模块本身的限定。The modules involved in the embodiments of the present invention may be implemented in a software manner, and may also be implemented in a hardware manner. The described modules can also be set in the processor, for example, it can be described as: a processor includes a receiving
作为另一方面,本发明还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的设备中所包含的;也可以是单独存在,而未装配入该设备中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被一个该设备执行时,使得该设备包括:As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or may exist alone without being assembled into the device. The above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by a device, the device includes:
步骤S401:接收待执行任务的任务请求;Step S401: receiving a task request for a task to be executed;
步骤S402:根据所述任务请求,选择执行待执行任务的Jenkins Master,并将待执行任务发送至Jenkins Master进行执行。Step S402: According to the task request, select the Jenkins Master that executes the task to be executed, and send the task to be executed to the Jenkins Master for execution.
本发明实施例提供的分布式处理任务的方法和装置,能够解决了单个任务编译部署节点的面对处理大规模任务时的瓶颈问题;通过创建包含最大并发数量的任务编译部署节点的任务编译部署节点集合,从而能够使得该分布式系统能够具有多个任务编译部署节点以便于处理多个任务请求;通过将创建的任务编译部署节点的信息保存至数据库中,从而能够处理根据待执行任务的处理需求便于选择任务编译部署节点执行待处理任务;通过根据所述编译任务的任务请求从数据库中选择符合预设条件的任务编译部署节点,然后将编译任务的任务请求发送至符合预设条件的任务编译部署节点进行执行,从而能够选择满足条件的任务编译部署节点执行相应的待执行任务;通过将任务编译部署节点的信息保存至数据库中,从而实现对任务编译部署节点信息的数据持久化,以便后续处理时可以方便的获取数据和/或随时查看数据;通过获取数据库中保存的运行状态为空闲状态的任务编译部署节点的列表,并从列表中选择已经执行完成任务的任务数量最少的任务编译部署节点;以及如果数据库中没有运行状态为空闲状态的任务编译部署节点,则通过集群管理系统创建一个新的任务编译部署节点作为执行所述编译任务的任务编译部署节点,从而能够选择出满足预设条件的任务编译部署节点执行待处理任务。The method and device for distributed processing tasks provided by the embodiments of the present invention can solve the bottleneck problem of a single task compiling and deploying node when dealing with large-scale tasks; by creating a task compiling and deploying node that includes the maximum concurrent number of task compiling and deploying nodes A set of nodes, so that the distributed system can have multiple task compilation and deployment nodes so as to process multiple task requests; by saving the information of the created task compilation and deployment nodes in the database, the processing according to the tasks to be executed can be processed. The requirement is convenient to select the task compilation and deployment node to execute the pending task; select the task compilation and deployment node that meets the preset conditions from the database according to the task request of the compilation task, and then send the task request of the compilation task to the task that meets the preset conditions. Compile and deploy nodes for execution, so that the task compilation and deployment nodes that meet the conditions can be selected to execute the corresponding tasks to be executed; by saving the information of the task compilation and deployment nodes in the database, the data persistence of the task compilation and deployment node information is realized, so that Data can be easily obtained and/or viewed at any time during subsequent processing; the list of deployment nodes can be compiled and deployed by obtaining the tasks saved in the database whose running state is idle, and the task compilation with the least number of tasks that have completed tasks is selected from the list. deployment node; and if there is no task compilation deployment node whose running state is an idle state in the database, a new task compilation deployment node is created by the cluster management system as the task compilation deployment node for executing the compilation task, so that a task compilation deployment node that satisfies the predetermined requirements can be selected. Conditional tasks compile and deploy nodes to execute pending tasks.
上述具体实施方式,并不构成对本发明保护范围的限制。本领域技术人员应该明白的是,取决于设计要求和其他因素,可以发生各种各样的修改、组合、子组合和替代。任何在本发明的精神和原则之内所作的修改、等同替换和改进等,均应包含在本发明保护范围之内。The above-mentioned specific embodiments do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims (16)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201710976299.8A CN107807815B (en) | 2017-10-19 | 2017-10-19 | Method and apparatus for distributed processing tasks |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201710976299.8A CN107807815B (en) | 2017-10-19 | 2017-10-19 | Method and apparatus for distributed processing tasks |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN107807815A CN107807815A (en) | 2018-03-16 |
| CN107807815B true CN107807815B (en) | 2020-11-24 |
Family
ID=61592812
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201710976299.8A Active CN107807815B (en) | 2017-10-19 | 2017-10-19 | Method and apparatus for distributed processing tasks |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN107807815B (en) |
Families Citing this family (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108681777B (en) * | 2018-05-07 | 2021-07-20 | 北京京东尚科信息技术有限公司 | A method and apparatus for running a machine learning program based on a distributed system |
| CN109032784A (en) * | 2018-08-07 | 2018-12-18 | 郑州云海信息技术有限公司 | A kind of multi-task parallel construction method and device |
| CN109388405A (en) * | 2018-10-25 | 2019-02-26 | 北京大米未来科技有限公司 | A kind of task processing method, device, electronic equipment and medium |
| CN109947452A (en) * | 2019-03-26 | 2019-06-28 | 南京联创信息科技有限公司 | A kind of Kubernetes container platform application update method |
| CN112019581B (en) * | 2019-05-30 | 2022-02-25 | 华为技术有限公司 | Method and device for scheduling task processing entities |
| CN111736810A (en) * | 2020-08-18 | 2020-10-02 | 四川新网银行股份有限公司 | Method for dynamically creating node of docker container to execute task based on jenkins real-time task |
| CN112183053B (en) * | 2020-10-10 | 2024-11-08 | 湖南快乐阳光互动娱乐传媒有限公司 | A data processing method and device |
| CN112559022A (en) * | 2020-12-16 | 2021-03-26 | 同盾控股有限公司 | Jenkins high-availability system and method |
| CN114296930B (en) * | 2021-12-29 | 2024-08-27 | 北京天融信网络安全技术有限公司 | Distributed compiling method, system, electronic equipment and storage medium |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN104079630A (en) * | 2014-06-09 | 2014-10-01 | 中国建设银行股份有限公司 | Business server side load balancing method, client side, server side and system |
| CN105760459A (en) * | 2016-02-04 | 2016-07-13 | 四川嘉宝资产管理集团股份有限公司 | Distributed data processing system and method |
| CN106909451A (en) * | 2017-02-28 | 2017-06-30 | 郑州云海信息技术有限公司 | A kind of distributed task dispatching system and method |
| CN107026762A (en) * | 2017-05-24 | 2017-08-08 | 郑州云海信息技术有限公司 | A kind of disaster tolerance system and method based on distributed type assemblies |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8621446B2 (en) * | 2010-04-29 | 2013-12-31 | International Business Machines Corporation | Compiling software for a hierarchical distributed processing system |
| CN104794095B (en) * | 2014-01-16 | 2018-09-07 | 华为技术有限公司 | Distributed Calculation processing method and processing device |
| US10169100B2 (en) * | 2016-03-31 | 2019-01-01 | International Business Machines Corporation | Software-defined storage cluster unified frontend |
-
2017
- 2017-10-19 CN CN201710976299.8A patent/CN107807815B/en active Active
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN104079630A (en) * | 2014-06-09 | 2014-10-01 | 中国建设银行股份有限公司 | Business server side load balancing method, client side, server side and system |
| CN105760459A (en) * | 2016-02-04 | 2016-07-13 | 四川嘉宝资产管理集团股份有限公司 | Distributed data processing system and method |
| CN106909451A (en) * | 2017-02-28 | 2017-06-30 | 郑州云海信息技术有限公司 | A kind of distributed task dispatching system and method |
| CN107026762A (en) * | 2017-05-24 | 2017-08-08 | 郑州云海信息技术有限公司 | A kind of disaster tolerance system and method based on distributed type assemblies |
Also Published As
| Publication number | Publication date |
|---|---|
| CN107807815A (en) | 2018-03-16 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN107807815B (en) | Method and apparatus for distributed processing tasks | |
| US8984515B2 (en) | System and method for shared execution of mixed data flows | |
| CN106776280B (en) | Configurable performance test device | |
| US11620168B2 (en) | Managing metadata for a distributed processing system with manager agents and worker agents | |
| CN108510081A (en) | machine learning method and platform | |
| CN103810272A (en) | Data processing method and system | |
| CN108845954A (en) | Method for testing pressure, system and storage medium | |
| CN108563787A (en) | A kind of data interaction management system and method for data center's total management system | |
| CN111966558B (en) | Cluster resource monitoring method, device, cluster, equipment and medium | |
| CN115202818B (en) | Jenkins-based build task processing methods, devices, electronic equipment, and media | |
| CN107766497A (en) | The method and terminal of Data Collection based on container | |
| CN114185656B (en) | A test task processing method, apparatus, device and storage medium | |
| CN115766734A (en) | Visual detection method and system based on cloud service | |
| CN111488268A (en) | Scheduling method and scheduling device for automated testing | |
| CN111240998B (en) | Test case processing method and device | |
| CN112711522B (en) | Cloud testing method and system based on docker and electronic equipment | |
| CN114116509A (en) | Program analysis method, program analysis device, electronic device, and storage medium | |
| CN108259611A (en) | Cluster docker management methods, device, system and readable storage medium storing program for executing | |
| CN113672671A (en) | Method and device for realizing data processing | |
| CN112181937A (en) | Data transmission method and device | |
| CN105530140A (en) | Cloud scheduling system, method and device for removing tight coupling of use case and environment | |
| CN113067869B (en) | Node control method and device, node management method and device and distributed system | |
| CN104462484A (en) | Data processing method, data processor and system | |
| US20240411586A1 (en) | Dynamic request mode using smart request system | |
| CN103176846A (en) | Software and hardware sharing device and method based on production line |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |