Resource allocation methods, devices, electronic equipment and storage media
By determining the status information of slave nodes in the continuous integration tool and assigning it to the master node, the problem of large resource investment and long cycle when reusing Jenkins slave node resources is solved, realizing convenient sharing of slave node resources and stability of the continuous integration tool.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-22
- Publication Date
- 2026-04-03
AI Technical Summary
In existing technologies, Jenkins requires a large amount of resources and has a long development cycle when reusing node resources, making it impossible to quickly achieve resource sharing.
By determining the status information of slave nodes in the continuous integration tool, allocable nodes are selected and assigned to the master node, and distributed locks are used to ensure the stability and efficiency of resource allocation.
It enables convenient sharing of node resources, shortens the software version release cycle, accelerates the iteration speed, and ensures the stability of continuous integration tools.
Smart Images

Figure CN114090249B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to a resource allocation method, apparatus, electronic device and storage medium. Background Technology
[0002] In related technologies, continuous integration shortens the release cycle of software versions and accelerates the iteration speed of software versions. The main continuous integration tool is Jenkins, which includes master nodes and slave nodes. By merging the slave node resources under each Jenkins master node to form a cluster or resource cloud, the purpose of resource sharing can be achieved. However, building a cluster or resource cloud depends on complex infrastructure construction and cannot quickly achieve the reuse of Jenkins slave node resources. Summary of the Invention
[0003] In view of this, embodiments of this application provide a resource allocation method, apparatus, electronic device, and storage medium to at least solve the problems of requiring a large amount of resources and a long development cycle when implementing Jenkins slave node resource reuse in related technologies.
[0004] The technical solution of this application embodiment is implemented as follows:
[0005] This application provides a resource allocation method, the method comprising:
[0006] First information of at least one first node is determined; the first information includes at least first status information of the first node; the first status information characterizes whether the first node can be assigned to each of at least one second node; the first node characterizes a slave node in the continuous integration tool; the second node characterizes a master node in the continuous integration tool.
[0007] The first node representing the first state of the first information is identified as at least one target node; the first state represents that the first node is an allocatable node.
[0008] Each of the at least one target node is assigned to one of the at least one second nodes.
[0009] In the above scheme, when determining the first information of at least one first node, the method includes:
[0010] Obtain at least one second state information of the first node; the second state information indicates whether the first node can be assigned to the second node corresponding to the first node;
[0011] The first state information of the first information of the first node is determined based on at least one second state information of the first node.
[0012] In the above scheme, obtaining at least one second state information of the first node includes:
[0013] A first label is determined in the configuration information of each of the at least one second node; the first label is used to mark the first node present in the second node;
[0014] Based on the first label, obtain at least one second state information of the first node corresponding to the first label.
[0015] In the above scheme, determining the first state information of the first information of the first node based on at least one second state information of the first node includes:
[0016] Perform a bitwise AND operation on each of the at least one second state information of the first node to determine the first state information of the first node.
[0017] In the above scheme, the first information also includes the first name information of the first node; when assigning each of the at least one target node to one of the at least one second node, the method includes:
[0018] The second information is determined from the first name information in the first information of the target node; the second information represents the name information corresponding to the target node under the assigned second node;
[0019] The second information is output to the second node assigned to the target node.
[0020] In the above scheme, before assigning each of the at least one target node to one of the at least one second node, the method further includes:
[0021] Obtain at least one second name information for each of the at least one first node; the second name information represents the name information of the first node under the corresponding second node;
[0022] Integrate at least one second name information of each of the at least one first node to determine the first name information of each of the at least one first node.
[0023] In the above scheme, after assigning each of the at least one target node to one of the at least one second node, the method further includes:
[0024] A second tag is added to the assigned target node, and the correspondence between the second tag and the assigned target node is stored in a set database; the second tag indicates that the assigned target node is in a second state; the second state indicates that the assigned target node is an unassignable node.
[0025] In the above scheme, before determining the first information of at least one first node, the method further includes:
[0026] Receive a first resource allocation request and set a distributed lock; the distributed lock is used to prevent the processing of other resource allocation requests besides the first resource allocation request; the first resource allocation request represents a request initiated by a second node in the continuous integration tool;
[0027] After assigning each of the at least one target node to one of the at least one second node, the method further includes:
[0028] Release the distributed lock.
[0029] This application also provides a resource allocation device, including:
[0030] A first determining unit is configured to determine first information of at least one first node; the first information includes at least first status information of the first node; the first status information characterizes whether the first node can be assigned to each of at least one second node; the first node characterizes a slave node in the continuous integration tool; and the second node characterizes a master node in the continuous integration tool.
[0031] The second determining unit is configured to determine the first node representing the first state of the first information as at least one target node; the first state represents the first node as an allocatable node.
[0032] An allocation unit is used to allocate each of the at least one target node to one of the at least one second nodes.
[0033] This application also provides an electronic device, including: a processor and a memory for storing a computer program capable of running on the processor.
[0034] When the processor runs the computer program, it executes the steps of any of the above methods.
[0035] This application also provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of any of the above methods.
[0036] In this embodiment of the application, by using the status information of the slave nodes participating in resource sharing under the continuous integration tool in each master node, an allocatable node is selected from the slave nodes and assigned to a master node. This can conveniently enable multiple master nodes to share slave node resources, and can ensure the stability of the continuous integration tool when allocating slave node resources. Attached Figure Description
[0037] Figure 1 This is a schematic diagram of a resource allocation architecture in related technologies;
[0038] Figure 2 This is a schematic diagram of another resource allocation architecture in related technologies;
[0039] Figure 3 This is a schematic diagram of another resource allocation architecture in related technologies;
[0040] Figure 4 A schematic diagram illustrating the implementation flow of a resource allocation method provided in an embodiment of this application;
[0041] Figure 5 A schematic diagram illustrating the implementation flow of a resource allocation method provided in another embodiment of this application;
[0042] Figure 6 A schematic diagram illustrating the implementation flow of a resource allocation method provided in another embodiment of this application;
[0043] Figure 7 Configuration information of the second node in a continuous integration tool provided in an embodiment of this application;
[0044] Figure 8 A schematic diagram illustrating the implementation flow of a resource allocation method provided in an embodiment of this application;
[0045] Figure 9 A schematic diagram illustrating the implementation flow of a resource allocation method provided in another embodiment of this application.
[0046] Figure 10 A schematic diagram of a resource allocation process provided for an application embodiment of this application;
[0047] Figure 11 This is a schematic diagram of the structure of a resource allocation device provided in an embodiment of this application;
[0048] Figure 12 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0049] The present application will now be described in further detail with reference to the accompanying drawings and specific embodiments.
[0050] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0051] It should be noted that the technical solutions described in the embodiments of this application can be combined arbitrarily without conflict.
[0052] In addition, in the embodiments of this application, "first," "second," etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0053] Additionally, the term "at least one" in this document means any combination of at least two of any one or more of a plurality, such as including at least one of A, B, and C, and may mean including any one or more elements selected from the set consisting of A, B, and C.
[0054] Before providing a detailed description of the technical solutions of the embodiments of this application, a brief explanation of the resource allocation architecture in related technologies will be given first.
[0055] Figure 1 This is a schematic diagram of a resource allocation architecture in related technologies. Figure 1 In this framework, different continuous integration (CI) tasks can be assigned corresponding master nodes. Each master node also hosts a batch of slave nodes running on that master node. For example, the slave nodes mounted on master node A are exclusively for master node A; master node B cannot access the slave nodes mounted on master node A. As CI tasks increase, the demand for slave node resources grows. However, due to the binding relationship between slave nodes and their corresponding master nodes, the utilization of slave node resources cannot be maximized. To improve slave node resource utilization, a solution is proposed... Figure 2 The diagram shows another resource allocation architecture. Figure 2 In this system, multiple master nodes can share slave node resources. Figure 2 Based on the schematic diagram of the resource allocation architecture shown, resource sharing can be achieved by merging the resources of slave nodes under each master node to form a cluster or resource cloud. Specifically, for example... Figure 3 The diagram illustrates a resource allocation architecture that utilizes frameworks such as Mesos to abstract and schedule the resources of all slave nodes. This allows master nodes to request resources from the Mesos service instead of directly allocating resources to slave nodes, without needing to consider the internal distribution of resources. Figure 3The resource allocation architecture relies on complex infrastructure construction, which makes it impossible to quickly meet the need for resource reuse from nodes.
[0056] Based on this, in various embodiments of this application, the reuse of slave node resources is achieved solely by relying on software, thereby quickly fulfilling the requirement for slave node resource reuse.
[0057] The present application will now be described in further detail with reference to the accompanying drawings and specific embodiments.
[0058] This application provides a resource allocation method. Figure 4 This is a schematic flowchart illustrating a resource allocation method according to an embodiment of this application. Figure 4 As shown, the method includes:
[0059] S401: Determine first information of at least one first node; the first information includes at least first status information of the first node; the first status information represents whether the first node can be assigned to each of at least one second node; the first node represents a slave node in the continuous integration tool; the second node represents a master node in the continuous integration tool.
[0060] Here, continuous integration tools can shorten the software release cycle and accelerate the iteration speed of software versions during continuous integration. In practical applications, different continuous integration tools exist, among which Jenkins is the mainstream continuous integration tool. In this embodiment, Jenkins is used as an example for illustration. Jenkins includes slave nodes (first node) and master nodes (second node). The master node provides an interface to the outside world, through which users can manage and configure the continuous integration process. The master node is also responsible for scheduling slave node resources. Slave nodes are mounted under the master node, providing the master node with resources such as memory and disk, and are responsible for executing the tasks dispatched by the master node.
[0061] The first information of at least one first node in the continuous integration tool is determined. This first information refers to the node information of the first node, such as its first status information. The first status information determines whether the first node can be assigned to any second node in the continuous integration tool. In practice, the first information of the first node can be obtained by calling the Jenkins REST API interface within the continuous integration tool.
[0062] In practical applications, when a second node in a continuous integration tool issues a resource allocation request, the first information of at least one first node can be determined.
[0063] In one embodiment, such as Figure 5As shown, when determining the first information of at least one first node, the method includes:
[0064] S501: Obtain at least one second state information of the first node; the second state information indicates whether the first node can be assigned to the second node corresponding to the first node.
[0065] Here, for a first node in a continuous integration tool, the second status information corresponding to the first node under each second node in the continuous integration tool is obtained. For example, when there are second nodes A and B, the second status information corresponding to the first node A indicates whether the first node A can be assigned to the second node B, and the other second status information corresponding to the first node A indicates whether the first node A can be assigned to the second node B.
[0066] In one embodiment, such as Figure 6 As shown, obtaining at least one second state information of the first node includes:
[0067] S601: Determine a first label in the configuration information of each of the at least one second node; the first label is used to mark the first node present in the second node.
[0068] Here, the configuration information about the second node is read from the continuous integration tool, such as... Figure 7 As shown, Figure 7 The configuration information for the second node in the continuous integration tool is shown. The configuration information includes the URL address and access method of the second node. The alias: J1 represents a second node. The first label is Node_Sharing_Label in the configuration information. The first label is used to define the label of the first node participating in resource sharing.
[0069] S602: Based on the first tag, obtain at least one second state information of the first node corresponding to the first tag.
[0070] Here, each second node in the continuous integration tool is traversed through the first label, and the second status information of the first node is read through the first label.
[0071] S502: Determine the first state information of the first information of the first node based on at least one second state information of the first node.
[0072] Here, by analyzing the second state information of each first node, it is determined whether the first node can be assigned to each second node in the continuous integration tool, and thus the first state information of the first node is determined.
[0073] In practical applications, all second nodes in a continuous integration tool can be traversed to obtain the node information of the corresponding first node under each second node. Each second node is configured with one or more first nodes within the continuous integration tool; that is, a first node may be configured by different second nodes. For example, assuming that second node A and second node B are both configured with first node A, when traversing second node A in the continuous integration tool, the following node information can be read:
[0074] Node 1:
[0075] Address information: 172.18.22.14
[0076] Second state information: True
[0077] Name information: Jenkins1_Node1
[0078] When traversing the second node B of the continuous integration tool, the following initial information can be read:
[0079] Node 1:
[0080] Address information: 172.18.22.14
[0081] Second state information: False
[0082] Name information: Jenkins2_Node1
[0083] The address information of the first node is usually the IP address of the first node, and the name information is the name of the first node under the corresponding second node. In practical applications, the information read from both the second node A and the second node B is the node information of the first node A. When there are multiple first nodes under the second node, it is necessary to distinguish between the multiple first nodes under different second nodes in order to determine the first state information based on at least one second state information of the first node. Different first nodes are distinguished by their address information. Nodes with the same address information are identified as the same first node. For example, in the node information obtained by traversing the second node A and the second node B, since the address information is the same, the node information obtained by traversing the second node A and the second node B can be identified as the node information of the same first node. Thus, the first state information of the first node is determined based on at least one second state information corresponding to the first node. In the above example, the second state information corresponding to the first node A under the second node A is True, indicating that the first node A can be assigned to the second node A. The second state information corresponding to the first node A under the second node B is False, indicating that the first node A cannot be assigned to the second node B. Thus, the first state information corresponding to the first node A is the first state.
[0084] In one embodiment, determining the first state information of the first information of the first node based on at least one second state information of the first node includes:
[0085] Perform a bitwise AND operation on each of the at least one second state information of the first node to determine the first state information of the first node.
[0086] Here, a bitwise AND operation is performed on each state information of the first node, and the result is determined as the first state information of the first node. The first state information of the first node is determined to be the first state only when each second state information of the first node is an allocatable state. When at least one second state information of the first node is an unallocable state, the first state information of the first node is determined to be the second state. For example, there are second nodes A and B. The first second state information corresponding to the first node A indicates that the first node A can be allocated to the second node A, and the other second state information corresponding to the first node indicates that the first node A can be allocated to the second node B. Thus, the first state information of the first node A can be obtained as the first state.
[0087] S402: The first node representing the first state of the first information is determined as at least one target node; the first state represents the first node as an allocatable node.
[0088] Here, based on the first state information, the first node can be divided into at least two types. When the first state information is in the first state, that is, the first node is in the first state, it indicates that the first node is an allocatable node and can be assigned to any second node in the continuous integration tool. The first node with the first state information in the first state is determined as the target node. When the first state information is in the second state, that is, the first node is in the second state, it indicates that the first node is an unallocable node and has already been assigned to a second node in the integration tool. The first node cannot be assigned to other second nodes.
[0089] S403: Assign each of the at least one target node to one of the at least one second nodes.
[0090] Here, the node assigned to one of the at least two second nodes in the continuous integration tool is determined among at least one target node. In practical applications, when a second node needs to acquire more slave node resources, it can issue a resource allocation request. Based on the resource allocation request of the second node, a target node is assigned to the second node. For example, there are target node A and target node B. It is possible to choose to assign target node A to the second node or to assign target node B to the second node.
[0091] In one embodiment, such as Figure 8 As shown, the first information also includes the first name information of the first node; when assigning each of the at least one target node to one of the at least one second node, the method includes:
[0092] S801: Determine second information from the first name information in the first information of the target node; the second information represents the name information corresponding to the target node under the assigned second node.
[0093] Here, the first information of the first node also includes the first name information of the first node, wherein the first name information represents the name information of the first node under each second node in the continuous integration tool.
[0094] After determining the target node assigned to at least one of the second nodes, the name information of the target node is returned to the second node so that the second node can call the relevant resources of the first node. In practical applications, different second nodes may have different configurations for the same first node. For example, the first node A may have two different names. The name information of the first node A under the second node A is Jenkins1_Node1, and the name information of the first node A under the second node B is Jenkins2_Node1. Therefore, when returning the name information of the target node, it is necessary to confirm the second node assigned to the target node, and then obtain the name information of the target node under the assigned second node. For example, if the first node A is the target node, and the first node A is assigned to the second node A, then the name information of the target node is Jenkins1_Node1.
[0095] S802: Output the second information to the second node assigned to the target node.
[0096] Here, after determining the name information of the target node under the assigned second node, the corresponding name information is returned to the second node assigned to the target node.
[0097] In one embodiment, such as Figure 9 As shown, before assigning each of the at least one target node to one of the at least one second node, the method further includes:
[0098] S901: Obtain at least one second name information for each of the at least one first node; the second name information represents the name information of the first node under the corresponding second node.
[0099] Here, during the process of traversing each second node in the continuous integration tool, the second name information of the first node can also be obtained. For example, during the process of traversing the second node A, the name information of the first node A under the second node A can be obtained.
[0100] S902: Integrate at least one second name information of each of the at least one first node to determine the first name information of each of the at least one first node.
[0101] Here, for a first node, at least one second name information of the first node is integrated to determine the name information of the first node under each second node. For example, the second name information corresponding to the first node A under the second node B is Jenkins1_Node1, and the second name information corresponding to the first node A under the second node B is Jenkins2_Node1. After integration, the first name information corresponding to the first node A is Jenkins1_Node1 and Jenkins2_Node1. In practical applications, the second name information of the same first node can be determined based on the address information in the node information of the first node, and then multiple second name information can be integrated.
[0102] In one embodiment, after assigning each of the at least one target node to one of the at least one second node, the method further includes:
[0103] A second tag is added to the assigned target node, and the correspondence between the second tag and the assigned target node is stored in a set database; the second tag indicates that the assigned target node is in a second state; the second state indicates that the assigned target node is an unassignable node.
[0104] Here, when target node A is assigned to one of at least one second node, it indicates that target node A has been occupied by the assigned second node. However, in practical applications, there may be delays in node state transitions. This means that when allocating resources for another resource allocation request, the state information corresponding to target node A may still show an allocable state. To avoid repeatedly assigning the same first node to different second nodes, the assigned target node is marked. A second tag can be added to the address information of the assigned target node. The second tag is used to mark the target node as an unallocable node. In practical applications, the correspondence between the second tag and the assigned target node can be stored in a designated database, where the second tag can be associated with the address information of the assigned target node. Furthermore, when a new resource allocation request is received, the correspondence stored in the designated database is queried, and the allocation of the first node carrying the second tag located in the designated database to the second node is abandoned.
[0105] In one embodiment, before determining the first information of at least one first node, the method further includes:
[0106] The system receives a first resource allocation request and sets a distributed lock; the distributed lock is used to prevent the processing of other resource allocation requests besides the first resource allocation request; the first resource allocation request represents a request initiated by a second node in the continuous integration tool.
[0107] Here, when a second node needs to acquire node resources from a first node, it will issue a first resource allocation request. Upon receiving the first resource allocation request, a distributed lock is set. The distributed lock can synchronize the operations of each second node in the continuous integration tool, thus the first state information of the first node obtained is inconsistent with the state information of the first node under each second node. After the distributed lock is set, resource allocation requests initiated by other second nodes will be processed only after the distributed lock is released, thereby preventing the simultaneous processing of resource allocation requests initiated by other second nodes.
[0108] After assigning each of the at least one target node to one of the at least one second node, the method further includes:
[0109] Release the distributed lock.
[0110] Here, after determining the target node for the second node, it means that the processing of the first resource allocation request has been completed. The distributed lock can be released, so that the corresponding target nodes can continue to be allocated to other second nodes.
[0111] In this embodiment of the invention, by using the status information of the slave nodes participating in resource sharing under the continuous integration tool in each master node, an allocatable node is selected from the slave nodes and assigned to a master node. This enables multiple master nodes to share slave node resources conveniently, and ensures the stability of the continuous integration tool when allocating slave node resources.
[0112] This application also provides an application example, such as Figure 10 As shown, Figure 10 A schematic diagram of a resource allocation process is shown. Figure 10In this process, an allocation module is used to allocate resources to the child nodes of the continuous integration tool. When the master node needs to acquire resources from a child node, it issues a resource allocation request. Upon receiving the resource allocation request, the allocation module sets a distributed lock, which is provided by a remote dictionary service (Redis). It reads the configuration information of the master node of the continuous integration tool. Based on the tags used to define the resources of the slave nodes in the configuration information, it iterates through and reads the node information of all slave nodes under the master node of the continuous integration tool. It then integrates the node information of all slave nodes, especially those with the same address information. Based on the integrated node information, it identifies the allocatable slave node as the target node, changes the status information of the target node to unallocable and stores it in Redis, releases the distributed lock, and returns the name information corresponding to the allocated target node to the master node that issued the resource allocation request.
[0113] In practical applications, it can be like Figure 10 The allocation process shown is encapsulated into a node allocation interface through the Shared Library in the continuous integration tool. When the master node requests resource allocation, the child nodes allocated to the master node can be obtained by calling the node allocation interface.
[0114] To implement the resource allocation method of this application, embodiments of this application also provide a resource allocation apparatus, such as... Figure 11 As shown, the resource allocation device includes:
[0115] The first determining unit 1101 is configured to determine first information of at least one first node; the first information includes at least first state information of the first node; the first state information characterizes whether the first node can be assigned to each of at least one second node; the first node characterizes a slave node in the continuous integration tool; and the second node characterizes a master node in the continuous integration tool.
[0116] The second determining unit 1102 is used to determine the first node representing the first state of the first information as at least one target node; the first state represents the first node as an allocatable node.
[0117] The allocation unit 1103 is used to allocate each of the at least one target node to one of the at least one second nodes.
[0118] In one embodiment, when determining the first information of at least one first node, the first determining unit 1101 is further configured to:
[0119] Obtain at least one second state information of the first node; the second state information indicates whether the first node can be assigned to the second node corresponding to the first node;
[0120] The first state information of the first information of the first node is determined based on at least one second state information of the first node.
[0121] In one embodiment, when the first determining unit 1101 acquires at least one second state information of the first node, it is further configured to:
[0122] A first label is determined in the configuration information of each of the at least one second node; the first label is used to mark the first node present in the second node;
[0123] Based on the first label, obtain at least one second state information of the first node corresponding to the first label.
[0124] In one embodiment, when the first determining unit 1101 determines the first state information of the first information of the first node based on at least one second state information of the first node, it is further configured to:
[0125] Perform a bitwise AND operation on each of the at least one second state information of the first node to determine the first state information of the first node.
[0126] In one embodiment, the first information further includes the first name information of the first node; when the allocation unit 1103 allocates each of the at least one target node to one of the at least one second node, it is further configured to:
[0127] The second information is determined from the first name information in the first information of the target node; the second information represents the name information corresponding to the target node under the assigned second node;
[0128] The second information is output to the second node assigned to the target node.
[0129] In one embodiment, before allocating each of the at least one target node to one of the at least one second node, the resource allocation device is further configured to:
[0130] Obtain at least one second name information for each of the at least one first node; the second name information represents the name information of the first node under the corresponding second node;
[0131] Integrate at least one second name information of each of the at least one first node to determine the first name information of each of the at least one first node.
[0132] In one embodiment, after the resource allocation device allocates each of the at least one target node to one of the at least one second node, it is further configured to:
[0133] A second tag is added to the assigned target node, and the correspondence between the second tag and the assigned target node is stored in a set database; the second tag indicates that the assigned target node is in a second state; the second state indicates that the assigned target node is an unassignable node.
[0134] In one embodiment, before determining the first information of at least one first node, the resource allocation device is further configured to:
[0135] Receive a first resource allocation request and set a distributed lock; the distributed lock is used to prevent the processing of other resource allocation requests besides the first resource allocation request; the first resource allocation request represents a request initiated by a second node in the continuous integration tool;
[0136] After allocating each of the at least one target node to one of the at least one second node, the resource allocation device is further configured to:
[0137] Release the distributed lock.
[0138] In practical applications, the first determining unit 1101, the second determining unit 1102, and the allocation unit 1103 can be implemented by the processor in the resource allocation device. Of course, the processor needs to run the programs stored in the memory to implement the functions of the above-mentioned program modules.
[0139] It should be noted that the above Figure 11 The resource configuration device provided in this embodiment is illustrated only by the division of the above-described program modules. In practical applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device can be divided into different program modules to complete all or part of the processing described above. Furthermore, the resource configuration device and resource configuration method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process is detailed in the method embodiments, and will not be repeated here.
[0140] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiments of this application, the embodiments of this application also provide an electronic device. Figure 12 This is a schematic diagram of the hardware structure of the electronic device according to an embodiment of this application, as shown below. Figure 12 As shown, the electronic device includes:
[0141] Communication interface 1 enables information exchange with other devices, such as network devices;
[0142] Processor 2 is connected to communication interface 1 to enable information interaction with other devices and, when running a computer program, executes the resource configuration methods provided by one or more of the above-mentioned technical solutions. The computer program is stored in memory 3.
[0143] Of course, in practical applications, the various components in an electronic device are coupled together through bus system 4. It can be understood that bus system 4 is used to achieve communication and connection between these components. In addition to the data bus, bus system 4 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 12 The general will label all buses as Bus System 4.
[0144] The memory 3 in this embodiment is used to store various types of data to support the operation of the electronic device. Examples of such data include any computer program used to operate on the electronic device.
[0145] It is understood that memory 3 can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memory 3 described in the embodiments of this application is intended to include, but is not limited to, these and any other suitable types of memory.
[0146] The methods disclosed in the embodiments of this application can be applied to processor 2, or implemented by processor 2. Processor 2 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 2 or by instructions in the form of software. The processor 2 may be a general-purpose processor, DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 2 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in memory 3. Processor 2 reads the program in memory 3 and completes the steps of the aforementioned method in combination with its hardware.
[0147] When processor 2 executes the program, it implements the corresponding processes in the various methods of the embodiments of this application. For the sake of brevity, these will not be described in detail here.
[0148] In an exemplary embodiment, this application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, such as a memory 3 that stores a computer program, which can be executed by a processor 2 to complete the steps described in the aforementioned method. The computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM.
[0149] In the several embodiments provided in this application, it should be understood that the disclosed apparatus, electronic devices, and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components may be combined, or integrated into another system, or some features may be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed may be through some interfaces, and the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0150] The units described above 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 units may be selected to achieve the purpose of this embodiment according to actual needs.
[0151] In addition, each functional unit in the various embodiments of this application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0152] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0153] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0154] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A resource allocation method, characterized in that, include: Receive the first resource allocation request initiated by a second node in the continuous integration tool and set a distributed lock; The distributed lock is used to prevent the processing of resource allocation requests initiated by other second nodes besides the one mentioned above. Determine first information of at least one first node; the first information includes at least the first state information of the first node; The first status information indicates whether the first node can be assigned to each of the at least one second node in the continuous integration tool; The first node represents a slave node in the continuous integration tool; The second node represents the master node in the continuous integration tool; The step of determining the first information of at least one first node includes: obtaining at least one second state information of the first node, performing a bitwise AND operation on each of the at least one second state information of the first node, and determining the first state information of the first information of the first node; the second state information indicates whether the first node can be assigned to the second node corresponding to the first node; each of the at least one second node in the continuous integration tool shares the resources of the at least one first node; The first node representing the first state of the first information is identified as at least one target node; the first state represents that the first node is an allocatable node. Based on the first resource allocation request, a target node is allocated to the second node; Release the distributed lock.
2. The method according to claim 1, characterized in that, The step of obtaining at least one second state information of the first node includes: A first label is determined in the configuration information of each of the at least one second node; the first label is used to mark the first node present in the second node; Based on the first label, obtain at least one second state information of the first node corresponding to the first label.
3. The method according to claim 1, characterized in that, The first information also includes the first name information of the first node; when assigning each of the at least one target node to one of the at least one second node, the method includes: The second information is determined from the first name information in the first information of the target node; the second information represents the name information corresponding to the target node under the assigned second node; The second information is output to the second node assigned to the target node.
4. The method according to claim 3, characterized in that, Before assigning each of the at least one target node to one of the at least one second node, the method further includes: Obtain at least one second name information for each of the at least one first node; the second name information represents the name information of the first node under the corresponding second node; Integrate at least one second name information of each of the at least one first node to determine the first name information of each of the at least one first node.
5. The method according to claim 1, characterized in that, After assigning each of the at least one target node to one of the at least one second node, the method further includes: A second tag is added to the assigned target node, and the correspondence between the second tag and the assigned target node is stored in a set database; the second tag indicates that the assigned target node is in a second state; the second state indicates that the assigned target node is an unassignable node.
6. A resource allocation device, characterized in that, The device includes: The receiving unit is used to receive a first resource allocation request initiated by a second node in the continuous integration tool. A setting unit is used to set a distributed lock; the distributed lock is used to prohibit the processing of resource allocation requests initiated by other second nodes besides the one second node. A first determining unit is configured to determine first information of at least one first node; the first information includes at least first state information of the first node; the first state information indicates whether the first node can be assigned to each of the at least one second node in the continuous integration tool; the first node indicates a slave node in the continuous integration tool; the second node indicates a master node in the continuous integration tool; determining the first information of at least one first node includes: obtaining at least one second state information of the first node, performing a bitwise AND operation on each of the at least one second state information of the first node to determine the first state information of the first node; the second state information indicates whether the first node can be assigned to the second node corresponding to the first node; each of the at least one second node in the continuous integration tool shares the resources of the at least one first node; The second determining unit is configured to determine the first node representing the first state of the first information as at least one target node; the first state represents the first node as an allocatable node. An allocation unit is configured to allocate a target node to the second node based on the first resource allocation request; The release unit is used to release the distributed lock.
7. An electronic device, characterized in that, include: The processor and the memory used to store computer programs that can run on the processor. When the processor is used to run the computer program, it performs the steps of the method according to any one of claims 1 to 5.
8. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Task scheduling method, network equipment and storage medium
CN112817728A