Microservice system change influence range analysis method and system based on knowledge graph
Through the knowledge graph-based method, the knowledge graph of microservices is generated and the calling link of the change function is analyzed, which solves the problems of low efficiency and low accuracy of microservice changes in the prior art, and achieves efficient and accurate analysis of the scope of change impact.
Patent Information
- Application Number
- CN202510196074.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-21
- Publication Date
- 2025-06-06
AI Technical Summary
The prior art is inefficient and accurate when analyzing the impact of microservice changes, making it difficult to fully judge the main impact content within the scope of the change and the associated impact on other microservices.
Using a knowledge graph-based method, a knowledge graph of microservices is generated. By analyzing the changed functions and generating the calling link of the function, a 3D graph of each function is drawn to identify the scope of influence of the change function and other microservices that may be affected.
It improves the efficiency and accuracy of microservice change impact analysis, and can quickly and intuitively judge the main impact content within the scope of the change and the associated impact on other microservices.
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of microservice change impact scope analysis, and specifically relates to a method and system for analyzing the impact scope of microservice system changes based on a knowledge graph. Background Art
[0002] Microservices, or microservice architecture, is a cloud-native architecture approach that includes many small, loosely coupled and independently deployable components or services in a single application. Microservices are widely used in the development of large-scale financial technology systems. As the system is built, the number of microservices continues to increase, the complexity of the relationships between microservices increases exponentially, and the internal complexity of microservices continues to rise. During the system iteration process, software developers and software testers need to analyze as comprehensively as possible whether the iteration content affects other functions of the microservice, as well as the impact on other microservices. If omissions occur, it may lead to imperfect design and incomplete test coverage, which may eventually lead to failures after going online.
[0003] Impact analysis after microservice changes generally relies on manual logic analysis and change code association analysis. Manual analysis is mainly based on the functional logic of the change and the understanding of existing functions to analyze the possible impact, but due to the complexity of the code and the effectiveness of communication, manual analysis is inefficient and has a high probability of omissions; change code association analysis uses technical means to find out the changed code content, starting from the changed code, find directly related code, and the result is fine-grained function or class information. This method is difficult to quickly and intuitively determine the main impact content within the scope of this service. The association relationship is limited to a single application and is temporarily built in memory. It is inefficient when used for analysis, and it is even more difficult to find the associated impact on other microservices. Summary of the invention
[0004] In order to solve the problems of low efficiency and low accuracy caused by the existing methods of manually analyzing the impact of microservice changes, the present invention provides a method and system for analyzing the impact scope of microservice system changes based on knowledge graph, which has high efficiency and accuracy.
[0005] The purpose of the present invention is achieved through the following technical solutions: The first aspect of the present invention discloses a method for analyzing the impact scope of a microservice system change based on a knowledge graph. The method is suitable for use by a microservice change impact analysis unit. The method comprises the following steps: In response to receiving a microservice change analysis instruction including engineering system information and a corresponding microservice to be analyzed, a change information acquisition instruction is generated, so that the change content identification service unit compares the code line information of the source code of the microservice to be analyzed with the source code of the current normal operating version according to the change information acquisition instruction to generate change function list information, wherein the generated change function list information includes all functions that have been changed in the microservice to be analyzed compared with the current normal operating version; Obtain the changed function list information and generate an impact link generation instruction containing the changed function list information, so that the microservice knowledge graph construction service unit processes the knowledge graph corresponding to the microservice to be analyzed according to the impact link generation instruction to obtain the call links of all functions in the changed function list information; The call link is obtained and a 3D graph of each function is drawn according to the call link.
[0006] The second aspect of the present invention discloses a method for analyzing the impact range of changes in a microservice system based on a knowledge graph. The method is suitable for use by a microservice knowledge graph construction service unit. The method comprises the following steps: In response to receiving the impact link generation instruction, a graph computing method is used for each function and the knowledge graph corresponding to the microservice to be analyzed to obtain the call links of all functions in the changed function list information.
[0007] The third aspect of the present invention discloses a microservice system change impact range analysis system based on a knowledge graph, comprising: A microservice change impact analysis unit, the microservice change impact analysis unit comprising a first memory and a first controller that are communicatively connected in sequence, the first memory storing a first computer program, the first controller being used to read the first computer program and execute a method for analyzing the impact range of a microservice system change based on a knowledge graph as described in the first aspect; A microservice knowledge graph construction service unit, the microservice knowledge graph construction service unit comprising a second memory and a second controller that are communicatively connected in sequence, the second memory storing a second computer program, the second controller being used to read the second computer program and execute a method for analyzing the impact scope of a microservice system change based on a knowledge graph as described in the second aspect; An input unit, the input unit is used to generate microservice change analysis instructions and knowledge graph construction / update instructions; a change content identification service unit, the change content identification service unit being used to compare the code line information of the source code of the microservice to be analyzed with the source code of the current normal running version according to the change information acquisition instruction when receiving the microservice change analysis instruction to generate change function list information; A storage unit is used to store source code and knowledge graph of the engineering system.
[0008] Compared with the prior art, the present invention has at least the following advantages and beneficial effects: The present invention generates a knowledge graph from microservices, parses the functions changed by the microservices to be analyzed and generates the call links of the functions according to the knowledge graph, and then generates a 3D graph of each function call link to identify the functional scope affected by the changed function and other microservices that may be affected. This method is efficient and accurate. DETAILED DESCRIPTION
[0009] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments.
[0010] Therefore, the following detailed description of the embodiments of the present invention is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0011] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features of the embodiments may be combined with each other.
[0012] Furthermore, the terms “first”, “second”, etc. are merely used for distinguishing descriptions and should not be understood as indicating or implying relative importance.
[0013] In the description of the present invention, it is also necessary to explain that, unless otherwise clearly specified and limited, the terms "set", "install", "connect", and "connect" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0014] The first aspect of the present invention provides a method for analyzing the impact range of a microservice system change based on a knowledge graph, which is suitable for use by a microservice change impact analysis unit. Specifically, the method includes steps S01 to S03.
[0015] Step S01, in response to receiving a microservice change analysis instruction including engineering system information and a corresponding microservice to be analyzed, generating a change information acquisition instruction, so that the change content identification service unit compares the code line information of the source code of the microservice to be analyzed with the source code of the current normal operating version according to the change information acquisition instruction to generate change function list information, wherein the generated change function list information includes all functions of the microservice to be analyzed that have been changed compared with the current normal operating version; Step S02: acquiring the changed function list information and generating an impact link generation instruction containing the changed function list information, so that the microservice knowledge graph construction service unit processes the knowledge graph corresponding to the microservice to be analyzed according to the impact link generation instruction to obtain the call links of all functions in the changed function list information; Step S03: Obtain the call link and draw a 3D graph of each function according to the call link.
[0016] Specifically, in this step, for each function in the generated change function list information, first query the knowledge graph of the microservice to be analyzed for the incoming edges of each function that jump upward N times and the vertices connected by the incoming edges, where N is a natural number greater than or equal to 1; then render the vertex 3D graphics with different colors according to the type of vertex, use the function as the bottom layer and the number of hops to distinguish the level of the vertex, and obtain the 3D graph of the call link to which each function belongs.
[0017] Exemplarily, N can be set to 1, 2, 3, 4, 5, 6, 7, 8, etc.
[0018] A second aspect of the present invention provides a method for analyzing the impact scope of changes in a microservice system based on a knowledge graph. The method is suitable for use in a service unit for constructing a microservice knowledge graph. The method includes the following steps S11 to S12.
[0019] Step S11: Generate or update the knowledge graph of the microservice to be analyzed.
[0020] Specifically, when the microservice knowledge graph construction service unit receives a knowledge graph construction / update instruction including version information of the microservice source code to be analyzed and the corresponding storage address, it first retrieves the source code of the microservice to be analyzed according to the knowledge graph construction / update instruction, wherein the source code includes the Java class defined during the business logic design and development; then compiles the source code to obtain a Java bytecode file for each Java class; then performs an abstract syntax tree analysis on each Java bytecode file to obtain a syntax tree corresponding to each Java bytecode file, wherein the nodes of the tree include information about the Java class, and the Java class The information includes the name of the class, the field list, and the function information; then, the syntax tree is traversed and encapsulated into nodes, wherein each Java class is encapsulated as a class node, the functions in the function information that are internal to the project system are encapsulated as internal function nodes, the external interfaces defined in the function information are encapsulated as interface function nodes, the functions that are not internal and are called in the project system in the function information are defined as external function nodes, and the functions of other microservice interfaces called in the function information are encapsulated as external interface call function nodes; finally, each node is taken as a vertex and the relationship between nodes as an edge to generate a knowledge graph of the microservice to be analyzed.
[0021] Step S12: In response to receiving the impact link generation instruction, a graph computing method is used for each function and the knowledge graph corresponding to the microservice to be analyzed to obtain the call links of all functions in the changed function list information.
[0022] The fourth aspect of the present invention discloses a microservice system change impact range analysis system based on a knowledge graph, comprising a microservice change impact analysis unit, a microservice knowledge graph construction service unit, an input unit, a change content identification service unit and a storage unit.
[0023] Among them, the microservice change impact analysis unit includes a first memory and a first controller that are communicatively connected in sequence, a first computer program is stored in the first memory, and the first controller is used to read the first computer program to execute a microservice system change impact range analysis method based on a knowledge graph as described in the first aspect; the microservice knowledge graph construction service unit includes a second memory and a second controller that are communicatively connected in sequence, a second computer program is stored in the second memory, and the second controller is used to read the second computer program to execute a microservice system change impact range analysis method based on a knowledge graph as described in the second aspect; the input unit is used to generate microservice change analysis instructions and knowledge graph construction / update instructions; the change content identification service unit is used to compare the source code of the microservice to be analyzed with the code line information of the current normal running version source code change according to the change information acquisition instruction when receiving the microservice change analysis instruction; the storage unit is used to store the source code and knowledge graph of the engineering system.
[0024] For example, the first memory and the second memory may include, but are not limited to, random access memory (RAM), read-only memory (ROM), flash memory, first input first output (FIFO) and first input last output (FILO), etc.; the first controller and the second controller may not be limited to using a microcontroller of the STM32F105 series. In addition, the computer device may also include, but are not limited to, a power supply unit, a display screen and other necessary components.
[0025] Among them, the source code and knowledge graph of the engineering system can be directly stored in the same storage unit. For the convenience of management, they can be stored separately, that is, the storage unit includes a code management unit for storing the source code of the engineering system, a graph database for storing the knowledge graph, and a relational database for storing engineering system information and its corresponding source code address relationship.
[0026] Specifically, based on the above system, the complete operation process can be implemented in the following way: After completing the update of the microservices of the engineering system, the R&D testers submit the code to the code management unit.
[0027] When it is necessary to analyze the impact of changes to the updated microservice, i.e. the microservice to be analyzed, the knowledge graph of the microservice to be analyzed must be generated first. At this time, the R&D tester inputs the engineering system information and the corresponding microservice to be analyzed to trigger the microservice change analysis instruction. After receiving the instruction, the microservice change impact analysis unit generates and sends a knowledge graph construction / update instruction to the microservice knowledge graph construction service unit. The microservice knowledge graph construction service unit queries the storage address corresponding to the microservice version to be analyzed in the relational database according to the microservice version to be analyzed in the knowledge graph construction / update instruction, and retrieves the source code of the corresponding microservice to be analyzed.
[0028] For the source code of the microservice to be analyzed, the source code contains the Java class defined during the design and development of the business logic. The microservice knowledge graph construction service unit first compiles the source code to obtain the Java bytecode file of each Java class. Then, an abstract syntax tree is analyzed for each Java bytecode file to obtain the syntax tree corresponding to each Java bytecode file, which contains various information in the Java class corresponding to the bytecode file, such as the class name, field list, and function information.
[0029] The syntax tree is traversed and packaged into nodes.
[0030] During the traversal process, each Java class is encapsulated as a class node, which includes attributes such as the class name, the fully qualified name of the class, the list of fields contained in the class, the list of functions of the class, the name of the parent class of the class, the annotation information of the class, the source code file name where the class is located, etc.
[0031] For the functions contained in each class in this code project, during the traversal process, when parsing the function definitions of each class, the main information of each internal function, including the class name to which the function belongs, the function's signature, and the list of other function names called inside the function, is encapsulated into a function node object and marked as an internal function type, hereinafter referred to as an internal function node. This part of the node is the key part of the impact analysis.
[0032] For the functions of Java external dependency packages used in this code project, such as built-in functions of JDK and functions of frameworks referenced by project codes such as Spring, when traversing the aforementioned syntax tree and parsing the internal logic of each function, the main information of the functions that do not belong to this project and are involved in the call in the function definition, including the class name to which the function belongs and the function's signature, is encapsulated into a function node object and marked as an external function type, hereinafter referred to as an external function node, for auxiliary analysis.
[0033] For the external interface defined in this code project, that is, the class to which the external interface function belongs uses the Controller annotation of springframework and the interface function uses the Mapping annotation, the path attribute in the annotation is obtained and updated as the interface address to the interface address attribute of the internal function node object corresponding to the function, and the "Is it an interface node" attribute of the object is updated to true, that is, it is marked as an interface function node. This part of the nodes is the core part of the impact analysis to form an intuitive application value, which is convenient for quickly understanding the service content affected by code changes.
[0034] For the functions defined in this code project that call other microservice interfaces, that is, the class to which the interface belongs contains external interface call annotations such as Spring Cloud Feign, the call target address in the annotation is obtained and updated to the external call address attribute of the internal function node corresponding to the function, and the "whether to call external interface" attribute of the object is updated to true, that is, it is marked as an external interface call function node. This part of the node is the core part of the impact analysis to form an intuitive application value. It is used to establish the association relationship between each microservice to provide an analysis of the impact range of code changes on other microservices.
[0035] Finally, each node is taken as a vertex and the relationship between nodes as an edge to generate a knowledge graph of the microservice to be analyzed and store it in the graph database.
[0036] After the knowledge graph is generated, the research and test personnel initiate a microservice change analysis instruction. After receiving the instruction, the microservice change impact analysis unit generates and sends a change information acquisition instruction to the change content identification service unit.
[0037] The change content identification service unit compares the code line information of the source code of the microservice to be analyzed with the code line information of the current normal operating version source code according to the change information acquisition instruction to generate changed function list information, wherein the generated changed function list information includes all the functions that have been changed in the microservice to be analyzed compared with the current normal operating version.
[0038] Specifically, the change content identification service unit obtains the code line information of the microservice to be analyzed compared with the source code of the current normal running version by pulling the source code of the microservice to be analyzed and the source code of the current normal running version by comparing the functions. Then, based on lexical analysis, grammatical analysis, and semantic analysis, the class information and function information of the changed code line information are obtained, and the changed function list information is generated. That is, all the functions of the microservice to be analyzed that have been changed compared with the current normal running version are obtained.
[0039] The microservice change impact analysis unit obtains the changed function list information and generates an impact link generation instruction containing the changed function list information. After receiving the instruction, the microservice knowledge graph construction service unit processes the knowledge graph corresponding to the microservice to be analyzed according to the impact link generation instruction to obtain the call links of all functions in the changed function list information and returns the call links of all functions in the changed function list information to the microservice change impact analysis unit.
[0040] The microservice change impact analysis unit obtains the call link and draws a 3D graph of each function based on the call link. Specifically, for each function in the generated change function list information, the knowledge graph of the microservice to be analyzed is used to query the incoming edges of each function N hops upward and the vertices connected by the incoming edges; different colors are used to render the vertex 3D graphics according to the type of vertex, and the function is used as the bottom layer and the number of hops to distinguish the level of the vertex, so as to obtain the 3D graph of the call link to which each function belongs. For the convenience of analysis, the 3D graph can be a hierarchical and classified 3D graph. The vertices at the top level of the 3D graph are usually interface function nodes, thereby obtaining the external service interface involved in each function. An external service interface corresponds to one or more system functions of the microservice, so as to determine the functional impact range of the microservice to which the changed function belongs.
[0041] According to the 3D graph drawn on the page, obtain the calls to external microservices involved in the functions to which the changed function belongs, so as to determine other microservices that may be affected by the changed function.
[0042] Although the present invention has been described in detail with reference to the aforementioned embodiments, it is still possible for those skilled in the art to modify the technical solutions described in the aforementioned embodiments, or to make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for analyzing the impact scope of changes in a microservice system based on a knowledge graph, characterized in that: The method is suitable for use by a microservice change impact analysis unit, and includes the following steps: In response to receiving a microservice change analysis instruction including engineering system information and a corresponding microservice to be analyzed, a change information acquisition instruction is generated, so that the change content identification service unit compares the code line information of the source code of the microservice to be analyzed with the source code of the current normal operating version according to the change information acquisition instruction to generate change function list information, wherein the generated change function list information includes all functions that have been changed in the microservice to be analyzed compared with the current normal operating version; Obtain the changed function list information and generate an impact link generation instruction containing the changed function list information, so that the microservice knowledge graph construction service unit processes the knowledge graph corresponding to the microservice to be analyzed according to the impact link generation instruction to obtain the call links of all functions in the changed function list information; The call link is obtained and a 3D graph of each function is drawn according to the call link.
2. According to the method for analyzing the impact range of microservice system changes based on knowledge graph according to claim 1, it is characterized by: The obtaining the call link and drawing a 3D graph of each function according to the call link includes: For each function in the generated changed function list information, query the knowledge graph of the microservice to be analyzed for each function's upward N-hop incoming edges and the vertices connected by the incoming edges, where N is a natural number greater than or equal to 1; Different colors are used to render vertex 3D graphics according to the type of vertex. The function is used as the bottom layer and the number of hops is used to distinguish the level of the vertex, and a 3D graph of the call chain to which each function belongs is obtained.
3. A method for analyzing the impact scope of changes in a microservice system based on a knowledge graph, characterized by: The method is suitable for use by a microservice knowledge graph construction service unit, and the method includes the following steps: In response to receiving the impact link generation instruction, a graph computing method is used for each function and the knowledge graph corresponding to the microservice to be analyzed to obtain the call links of all functions in the changed function list information.
4. The method for analyzing the impact range of changes in a microservice system based on a knowledge graph according to claim 3 is characterized in that: In response to receiving the link generation-influencing instruction, the method further includes: In response to receiving a knowledge graph construction / update instruction, the knowledge graph construction / update instruction includes version information and a corresponding storage address of a source code of a microservice to be analyzed, and the source code of the microservice to be analyzed is retrieved according to the knowledge graph construction / update instruction, wherein the source code includes a Java class defined during the design and development of the business logic; Compiling the source code to obtain a Java bytecode file for each Java class; Performing an abstract syntax tree analysis on each Java bytecode file to obtain a syntax tree corresponding to each Java bytecode file, wherein the tree node includes Java class information, and the Java class information includes the class name, field list, and function information; Traverse the syntax tree and encapsulate it into nodes, wherein each Java class is encapsulated as a class node, the functions in the function information that are internal to the project system are encapsulated as internal function nodes, the external interfaces defined in the function information are encapsulated as interface function nodes, the functions that are not internal and are called in the project system in the function information are defined as external function nodes, and the functions of other microservice interfaces called in the function information are encapsulated as external interface call function nodes; Each node is taken as a vertex and the relationship between nodes as an edge to generate a knowledge graph of the microservice to be analyzed.
5. A microservice system change impact range analysis system based on knowledge graph, characterized in that: include: A microservice change impact analysis unit, the microservice change impact analysis unit comprising a first memory and a first controller that are sequentially communicatively connected, the first memory storing a first computer program, the first controller being used to read the first computer program and execute a method for analyzing the impact range of a microservice system change based on a knowledge graph according to any one of claims 1-2; A microservice knowledge graph construction service unit, the microservice knowledge graph construction service unit comprising a second memory and a second controller that are sequentially communicatively connected, the second memory storing a second computer program, the second controller being used to read the second computer program and execute a method for analyzing the impact scope of a change in a microservice system based on a knowledge graph as described in any one of claims 3-4; An input unit, the input unit is used to generate microservice change analysis instructions and knowledge graph construction / update instructions; a change content identification service unit, the change content identification service unit being used to compare the code line information of the source code of the microservice to be analyzed with the source code of the current normal running version according to the change information acquisition instruction when receiving the microservice change analysis instruction to generate change function list information; A storage unit is used to store source code and knowledge graphs of the engineering system.
6. The microservice system change impact range analysis system based on knowledge graph according to claim 5 is characterized by: The storage unit includes a code management unit for storing source code of the engineering system and a graph database for storing a knowledge graph.
7. The microservice system change impact range analysis system based on knowledge graph according to claim 1 is characterized by: The storage unit also includes a relational database for storing the relationship between engineering system information and its corresponding source code address.