Microservice Partitioning Method and Device Based on Domain Knowledge of Programming Frameworks

The method leverages programming framework knowledge to enhance microservice partitioning precision by identifying logical layers and class dependencies, addressing the challenge of high coupling in existing methods.

CN116301745BActive Publication Date: 2025-07-15INST OF SOFTWARE - CHINESE ACAD OF SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310121682.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-16
Publication Date
2025-07-15
Estimated Expiration
2043-02-16

AI Technical Summary

Technical Problem

The prior art is difficult to accurately reflect business functions in microservice division, and ignores the different levels of classes in the system, resulting in high coupling between submodules and difficult to realize a high cohesion and low coupling microservice architecture.

Method used

Based on the domain knowledge of the programming framework, through dynamic instrumentation and test case analysis, we identify the logical hierarchy and dependencies of classes, combine hierarchical clustering algorithms, calculate the similarity between classes, consider database dependencies, and interactively evaluate the division results.

Benefits of technology

A more reasonable microservice division is achieved, the coupling between submodules is reduced, the accuracy and integration of division is improved, and the developers are allowed to optimize results interactively.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116301745B_ABST
    Figure CN116301745B_ABST
Patent Text Reader

Abstract

The present invention discloses a microservice partitioning method and device based on the knowledge of the programming framework field. The method includes: classifying the classes in the software system into different logical levels based on the programming framework; establishing the dependency call relationship between the classes in the software system; combining the dependency call relationship to obtain the test case set for each class; for two classes located in different logical levels, calculating the similarity between classes based on the test cases involved in the test case set; and obtaining the microservice partitioning result based on the similarity between classes and the target number of classes for hierarchical clustering. The present invention can help users participate in the microservice partitioning work.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a microservice partitioning method and device based on programming framework domain knowledge, belonging to the field of computer software technology. Background Art

[0002] In the early days of software development, most of the modules were developed and deployed together using a monolithic architecture. However, as the functions of the system continued to evolve, its complexity increased. When the scale of the system became large, the coupling relationship between the modules in the monolithic architecture would bring burdens on subsequent development, construction, deployment and maintenance, affecting the smooth operation of the system and the on-demand expansion of functions. In order to eliminate the defects in the monolithic architecture and improve the understandability and scalability of the system, modern applications use a microservice architecture to split the system into several relatively independent sub-modules. The modules initiate remote request calls through network communication. During the development process, each module can be modified and deployed independently, which undoubtedly reduces the complexity of the system. Compared with developing a new system from scratch, enterprises usually choose to transform the legacy system to make it conform to the microservice architecture. However, the complexity of the legacy system itself increases the difficulty of understanding its architecture and implementing module splitting. Manual division is time-consuming, labor-intensive and prone to errors. Therefore, it is necessary to use program analysis technology to automatically analyze the functional boundaries within the system to assist users in the microservice division of the system.

[0003] The implementation of microservice division of legacy systems can be divided into three steps: the first step is to collect architecture-related information from the legacy system to help users understand its functional boundaries; the second step is to split the legacy system into several sub-modules according to the identified functional boundaries. The modules should have high cohesion and low coupling, so that they can serve as candidates for microservice division; the third step is to evaluate and tune the results of the division, and iterate and improve them according to certain indicators.

[0004] Most existing work analyzes the static dependencies in the system by constructing control flow graphs and data flow graphs, so as to divide the classes in the original system into different business areas. Although this static analysis technology can analyze the system relatively comprehensively, it lacks information about actual operation, which makes it difficult for the division results to accurately reflect the business functions. Dynamic analysis technology designs test cases, performs functional tests on the system, and collects operation trajectories as the basis for dividing the system. Dynamic analysis technology can effectively reflect the actual operation of business functions, but it is difficult to ensure comprehensive coverage. Therefore, work in recent years often combines static analysis and dynamic analysis to make up for each other's shortcomings and achieve more accurate and comprehensive functional boundary identification.

[0005] In the process of splitting the system, most work chooses to use unsupervised machine learning methods to identify the functional boundaries of the system. By using the dependencies between classes collected during the dynamic and static analysis, a similarity index between classes is defined, and various clustering algorithms are used to split the legacy system. Some teams have adopted genetic algorithms, through repeated iteration and mutation of the permutations and combinations of classes, so that the final partition can meet the characteristics of high cohesion and low coupling (see Jin, W., Liu, T., Cai, Y., Kazman, R., Mo, R. and Zheng, Q., 2019. Service candidate identification from monolithic systems based on execution traces. IEEE Transactions on Software Engineering, 47(5), pp. 987-1007.). Some other research teams have chosen hierarchical clustering algorithms. By defining the similarity between classes, the classes with the closest call relationships to each other are aggregated to represent the results of microservice transformation (see Kalia, A.K., Xiao, J., Krishna, R., Sinha, S., Vukovic, M. and Banerjee, D., 2021, August. Mono2micro: a practical and effective tool for decomposing monolithic java applications to microservices. In Proceedings of the 29th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering (pp. 1214-1224).).

[0006] The microservice partitioning technology based on the combined dynamic and static analysis and clustering algorithm can reflect the running situation of the application system to a certain extent, but it also has deficiencies: these methods treat all classes equally and ignore the different levels of different classes in the whole system. For example, for the classes responsible for database access, multiple sub-modules are likely to call them frequently, but in actual partitioning, they can only be partitioned into a certain sub-module, resulting in high-frequency calls related to the database between the finally partitioned sub-modules, increasing the coupling degree between sub-modules, which is contrary to the purpose of microservice partitioning. For this reason, some teams consider the data dependency relationship and also take into account the use of data tables by classes in the system, so that the finally partitioned microservice system is not only independent in function but also in data (see Nitin, V., Asthana, S., Ray, B. and Krishna, R., 2022. CARGO: AI-Guided Dependency Analysis for Migrating Monolithic Applications to Microservices Architecture. arXiv preprint arXiv:2207.11784.). However, this method only captures the control flow calls and data dependency relationships in the system through static analysis and it is difficult to ensure accuracy. Summary of the Invention

[0007] To solve the above problems, the present invention proposes a microservice partitioning method and device based on the knowledge of programming frameworks. This method can not only perceive the programming frameworks adopted by software systems, thus more efficiently identifying the business functions responsible for each class in the system, but also allows users to interactively evaluate and optimize by setting the hyperparameters of the clustering algorithm to help users participate in the work of microservice partitioning.

[0008] The technical content of the present invention includes:

[0009] A microservice partitioning method based on the knowledge of programming frameworks, the method comprising:

[0010] Based on the programming framework, classify the classes in the software system into different logical levels;

[0011] Establish the dependency call relationship between classes in the software system;

[0012] Combined with the dependency call relationship, obtain the test case set for each class;

[0013] For two classes located in different logical levels, calculate the similarity between classes based on the test cases involved in the test case set;

[0014] Based on the inter-class similarity and the target number of classes in hierarchical clustering, obtain the microservice division result.

[0015] Further, the classifying the classes in the software system into the control layer, service layer, data mapping layer, and data entity layer based on the programming framework includes:

[0016] Read the dependency configuration information stored in xml format from the Pom.xml file under the root directory of the software system;

[0017] Based on the dependency configuration information, infer the programming framework of the software system;

[0018] Based on the knowledge graph of the programming framework, identify the functional logic layer to which each class in the software system belongs;

[0019] According to the functional logic layer, classify the classes into the control layer, service layer, data mapping layer, and data entity layer respectively.

[0020] Further, the logical layers include: control layer, service layer, data mapping layer, and data entity layer.

[0021] Further, the establishing the dependency call relationship between classes in the software system includes:

[0022] Instrument the software system through dynamic instrumentation technology;

[0023] Inject a probe into the J2EE application with JavaAgent to collect the method call traces of the software system when executing a specific network request;

[0024] Based on the points in the method call traces, establish the dependency call relationship between classes.

[0025] Further, for two classes located in different logical layers, calculating the inter-class similarity based on the test cases involved in the test case set includes:

[0026] Calculate the direct call similarity between the two classes where c i represents the i-th class in a logical layer, c j represents the j-th class in another logical layer, represents the set of test cases participated by class c i represents the set of test cases participated by class c represents the set of test cases participated by class c i represents the set of test cases participated by class c represents the set of test cases participated by class c i and class c j together;

[0027] Calculate the direct call pattern similarity between two classes wherein represents the set of test cases jointly participated by class c i and class c k ; represents the set of test cases jointly participated by class c and class c j ; C represents the set of all classes involved in the dynamic testing process, and U represents the set of all test cases; k

[0028] Calculate the indirect call similarity between two classes wherein represents the set of test cases generated with other classes as the transfer between class c i and class c j ;

[0029] Calculate the indirect call pattern similarity between two classes wherein represents the set of test cases generated with other classes as the transfer between class c i and class c k ; represents the set of test cases generated with other classes as the transfer between class c and class c j ; k

[0030] Sum the direct call similarity DCR(c i , c j ), the direct call pattern similarity DCP(c i , c j ), the indirect call similarity ICR(c i , c j ) and the indirect call pattern similarity ICP(c i , c j ) to obtain the inter-class similarity between class c i and class c j .

[0031] Furthermore, after establishing the dependency call relationship between classes in the software system, it further includes:

[0032] Determine whether there is a data persistence layer framework in the software system;

[0033] In the case that there is a data persistence layer framework in the software system, obtain the database dependency relationship based on the data mapping information used by the data persistence layer framework.

[0034] Furthermore, obtaining the microservice partitioning result based on the inter-class similarity and the number of target classes for hierarchical clustering includes:​​

[0035] Generate a number of data tables based on the database dependencies; wherein, there are dependencies among the classes in each data table;

[0036] For two classes belonging to the same data table, assign a similarity weight to the similarity between the corresponding classes, so that the similarity between the classes after the similarity weight is assigned is greater than the similarity between the classes before the similarity weight is assigned;

[0037] Obtain the microservice partitioning result based on the similarity between the classes after the similarity weight is assigned and the target number of classes for hierarchical clustering.

[0038] Further, the method further includes:

[0039] Measure the quality of the microservice partitioning result;

[0040] Modify the aggregation quantity in the microservice partitioning result based on the quality of the microservice partitioning result to obtain the final microservice partitioning result.

[0041] Further, the measuring the quality of the microservice partitioning result includes:

[0042] Calculate the call ratio between microservices in the microservice partitioning result, and compare the call ratio between microservices with a first set threshold to obtain the quality of the microservice partitioning result;

[0043] And / or,

[0044] Calculate the purity of the business context in the microservice partitioning result, and compare the purity of the business context with a second set threshold to obtain the quality of the microservice partitioning result;

[0045] And / or,

[0046] Calculate the number of interfaces in the microservice partitioning result, and compare the number of interfaces with a third set threshold to obtain the quality of the microservice partitioning result;

[0047] And / or,

[0048] Calculate the non-extreme degree in the microservice partitioning result, and compare the non-extreme degree with a fourth set threshold to obtain the quality of the microservice partitioning result;

[0049] And / or,

[0050] Calculate the class partitioning index in the microservice partitioning result, and in the case where the class partitioning index does not meet the set requirements, after modifying the target number of classes for hierarchical clustering, return to the step of obtaining the microservice partitioning result based on the similarity between the classes and the target number of classes for hierarchical clustering.

[0051] A microservice partitioning device based on domain knowledge of programming frameworks, the device comprising:

[0052] A programming framework analysis module, configured to classify classes in a software system into corresponding logical levels based on the programming framework;

[0053] A dynamic test execution module, configured to establish a dependency call relationship between classes in the software system;

[0054] A business class aggregation module, configured to combine the dependency call relationship to obtain a test case set for each class; for two classes located in different logical levels, calculate the similarity between classes based on the test cases involved in the test case set; based on the similarity between classes and the target number of classes for hierarchical clustering, obtain a microservice partitioning result.

[0055] Further, the device further comprises:

[0056] An instruction evaluation module, configured to measure the quality of the microservice partitioning result and modify the aggregation number in the microservice partitioning result based on the quality of the microservice partitioning result to obtain a final microservice partitioning result.

[0057] Compared with the prior art, the advantages of the present invention are as follows:

[0058] 1) It has awareness of the framework domain knowledge of legacy systems and can partition microservices more reasonably and efficiently.

[0059] 2) It pays attention to the application of the database and achieves an integrated partitioning of data and applications.

[0060] 3) It allows developers to interactively evaluate the partitioning result to improve the quality of partitioning. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] Figure 1 Is the overall system workflow.

[0062] Figure 2 Is the system module composition.

[0063] Figure 3 Is the workflow diagram of the programming framework analysis module.

[0064] Figure 4 Is the workflow diagram of the dynamic test execution module.

[0065] Figure 5 Is the schematic diagram of the system business logic layering.

[0066] Figure 6 Is the workflow diagram of the business class aggregation module and the quality assessment module. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0067] The present invention will be further described in detail below with reference to the accompanying drawings. The examples given are only used to explain the present invention and are not intended to limit the scope of the present invention.

[0068] Figure 1 Shown is the working process and module composition of the entire system. Below, taking the legacy system in the background art as an example, the working process of the microservice division of the present invention will be elaborated in detail.

[0069] 1. Programming framework analysis

[0070] Currently, most of the legacy systems targeted by the present invention are developed using J2EE technology. Such projects have certain commonalities in their overall structure. They often rely on the Maven tool for dependency management. When compiling a project, Maven will read the dependency information stored in xml format from the Pom.xml file in the root directory of the current project, and based on this, pull relevant dependencies from the local or remote repository to complete the compilation and construction of the project. By parsing the dependency configuration information in the Pom.xml file, the present invention can infer information such as the programming framework and database persistence layer framework adopted by the system. Then, according to the basic specifications that different frameworks should follow in configuration, the corresponding configuration files are retrieved within the project, thereby establishing the basic framework of the legacy system.

[0071] The present invention has established a knowledge graph of the programming framework field for the programming models adopted by different programming frameworks. The knowledge graph contains specific knowledge related to the framework. Each node on it can represent a programming framework, a persistence layer framework, a configuration file, annotation information, and a logical level. Edges are connected between the framework and the configuration file and the logical level, representing the information that needs to be concerned during analysis. For example, when it is parsed that the framework used in the legacy system is Spring Boot, we will take the following steps to extract relevant domain information from the knowledge graph:

[0072] (1) Retrieve the Spring Boot node and find the other nodes connected to it;

[0073] (2) Retrieve the configuration file node. According to the conventions in the programming specifications, retrieve the configuration file from the project and parse it. According to the type of logical level connected to the configuration file, classify the classes specified by the configuration file into the corresponding logical level;

[0074] (3) Retrieve the annotation information node. According to the type of logical level connected to it, classify the annotated classes into the corresponding logical level;

[0075] Identify the programming framework adopted by the system through the configuration file, apply the corresponding knowledge graph, so as to identify the functional logic levels to which each class in the system belongs, and layer the system in terms of business logic. Based on the domain knowledge corresponding to the framework, the present invention divides the classes in the legacy system into four levels from top to bottom, namely controller class, service class, data mapping class, and data entity class. The controller class is responsible for the routing control during page jumps; the service class provides specific function implementations and represents the specific business functions in the legacy system; the data mapping class is responsible for operating the database and provides data addition, deletion, modification, and query for the upper-layer services; the data entity class forms a corresponding relationship with the data tables in the database and is the object implementation in the legacy system.

[0076] For the persistence layer framework used by the legacy system, the present invention also identifies it in the same steps as above. For example, MyBatis allows users to write xml files to map the SQL statements used when code methods operate on the database. Through the domain knowledge graph, the present invention can capture and record the database tables corresponding to each method for subsequent business boundary division.

[0077] 2. Dynamic Instrumentation and Trace Collection

[0078] In order to collect the inter-class dependency information during the running of the program, the present invention instruments the legacy system through dynamic instrumentation technology, injects probes into the J2EE application with the help of JavaAgent, and collects the method call traces when it executes specific network requests. By performing various test behaviors on the legacy system, the present invention can obtain the traces of the behaviors within the system related to specific business functions. Each point in the trace represents a class, and the points are associated through call relationships, thereby establishing an inter-class dependency call relationship. By synthesizing each execution trace, the call frequency between classes reflects the strength of the dependency relationship.

[0079] Regarding the database usage, the present invention also collects the corresponding SQL statement calls, establishes a mapping from classes to data tables, and records it as a type of dependency relationship for subsequent business function splitting.

[0080] 3. Multi-level Clustering

[0081] Compared with traditional methods, the hierarchical clustering algorithm used in the present invention considers the layering of business logic. As Figure 5 shown, by combining the system information obtained in the dynamic and static analysis processes, the inter-level call relationships can be extracted, and its overall process is as follows:

[0082] (1) For the framework-related information and data layer mapping information extracted from the framework dependencies of the application, the present invention preliminarily hierarchizes each class involved in the application source code with the help of them, and classifies the classes into the control layer, service layer, data mapping layer, and data entity layer from top to bottom;

[0083] (2) For the logs collected during dynamic execution, the present invention uses them to establish call relationships between the classes in each layer, and these call relationships imply the dependency situations between classes.

[0084] For the hierarchical dependency relationships constructed in the foregoing steps, the present invention performs clustering among different layers. For example, for the existing logical hierarchical structure of the controller layer, business layer, data access layer, and data entity layer, the present invention clusters the classes in the controller layer with each of the other layers to represent the usage of the controller layer for business functions and data tables, so as to achieve a higher partitioning accuracy. When performing hierarchical clustering, it is necessary to calculate the similarity matrix between classes, and this matrix is obtained from the trajectories recorded by dynamic instrumentation. The present invention defines the similarity between classes as follows:

[0085] Given two existing classes c i and c j , the present invention uses Uc i and Uc j to represent the sets of test cases they participate in respectively. Then, the similarity between these two classes can be defined as:

[0086] Sim(c i , c j ) = DCR(c i , c j ) + DCP(c i , c j ) + ICR(c i , c j ) + ICP(c i , c j ) + DR(c i , c j )

[0087] Among them, DCR(c i , c j ) represents the direct call similarity between two classes, that is, among the test cases involved in c i and c j , the proportion of the number of test cases in which there is a call between c i and c j . The formula is described as follows:

[0088]

[0089] Among them, Represents class c i and c j Participate in the test cases together. If c i Participates in test cases a and b, while c j Participates in test cases b and c, and in test case b, c i Invokes c j , then the direct call similarity between the two is 1 / 3.

[0090] DCP(c i ,c j ) represents the direct call pattern similarity between two classes, that is, the similarity in the behavior of c i and c j when calling other classes. Its formulaic description is as follows:

[0091]

[0092] For example, in two test cases, c i and c j Call the same class c k , which means there is similarity in their behavior of calling classes. The present invention calculates the proportion of common calls between the two in all test cases.

[0093] ICR(c i ,c j ) represents the indirect call similarity. Similar to the direct call, it calculates the calls that occur between two classes through other classes as a transfer. The formula description is as follows:

[0094]

[0095] ICP(c i ,c j ) is the indirect call pattern similarity, similar to the direct call pattern similarity, representing the similarity in the indirect call behavior between two classes. The formula description is as follows:

[0096]

[0097] For the database dependency relationship, the present invention assigns a certain similarity weight to classes that depend on the same data table to ensure that they can independently manage their own data in the divided microservices. DR(c i ,c j ) is the data table association similarity, which is used to represent the similarity in the use of data tables between two classes, where represents the number of test cases in which c i and c j call the same data table. The formula description is as follows:

[0098]

[0099] The present invention sums up the above five types of similarities to represent the similarity between classes, and uses this as the standard for clustering between classes.

[0100] 4. Evaluation and Optimization of Partitioning Metrics

[0101] In the process of microservice transformation of legacy systems, developers may have difficulty determining the final number of microservices to be aggregated, and the hyperparameters in these clustering algorithms will affect the quality of microservice partitioning. To further optimize the results after microservice partitioning, the present invention provides an interactive metric optimization module to help developers measure the quality of the current microservice partitioning and decide whether to modify the aggregation quantity to further optimize the clustering effect. These metrics include:

[0102] Degree of structural modularity: This metric is used to measure the difference between the number of calls within each microservice partition and the number of calls between partitions. The higher the value, the higher the degree of cohesion and the better the result.

[0103] Proportion of calls between microservices: This metric is used to measure the ratio of the number of calls between each microservice partition to the number of calls between all classes. The lower the value, the better the effect of class aggregation after partitioning.

[0104] Purity of business context: This metric is used to measure the number of businesses involved in each microservice partition. The fewer the number, the lower the value, indicating that each partition is more concentrated in business functions.

[0105] Number of interfaces: This metric is used to measure the average number of interfaces exposed by each microservice partition. The fewer the number, the clearer the function after partitioning.

[0106] Degree of non-extremity: This metric is used to measure the proportion of partitions containing between 5 and 20 classes among all microservice partitions. The lower this metric, the more balanced the class partitioning.

[0107] We will not preset the target number of clusters, but will provide the corresponding evaluation metrics generated as the target number of clusters changes for users to judge. For example, for a system containing M classes, when performing hierarchical clustering, we will successively set the target number of clusters to M / 2, M / 4, M / 8, until n the value of M / 2 is less than 10, and then we will no longer halve it, but decrease it one by one, calculate the evaluation metrics when the target number of clusters is 9, 8, 7, 6..., record these metrics and visually display them to developers.

[0108] If the developer is not satisfied with the metrics of the current microservice partitioning, modify the number of target classes for hierarchical clustering and regenerate the corresponding clustering results to obtain a result that better meets the expectations.

[0109] To more clearly illustrate the specific implementation details, this application disassembles the system, as Figure 2 shown, the system implemented by the present invention includes four modules: a programming framework analysis module, a dynamic test execution module, a business class aggregation module, and a quality assessment module. The following is an introduction to each module:

[0110] 1. Programming framework analysis module

[0111] As Figure 3 shown, this module is mainly responsible for extracting framework dependency-related information from the legacy system, and its workflow is as follows:

[0112] (1) By analyzing the dependencies included in the project configuration file in the root directory of the project source code. For J2EE projects, this file is generally Pom.xml, and infer the framework used by the system from it. For example, when this module identifies SpringBoot-related dependencies, it can retrieve the application.properties file in the resource folder of the project with the help of SpringBoot-related programming framework domain knowledge and obtain the corresponding configuration of SpringBoot from it;

[0113] (2) Similarly, by analyzing the dependencies in the configuration file, it can also be determined whether there is a data persistence layer framework in the legacy system. If so, further obtain the data mapping information used by the data persistence layer framework. For example, for the MyBatis framework, the present invention will attempt to extract the corresponding Mapper file to obtain the dependency relationship between the data tables involved in database calls and the corresponding methods in the system.

[0114] 2. Dynamic test execution module

[0115] As Figure 4 shown, this module is mainly responsible for executing dynamic tests and collecting the runtime call information of the system, and its workflow is as follows:

[0116] (1) When the application starts, use the JavaAgent technology to dynamically instrument the application with a proxy and inject the application probe into it to collect the call information of the methods in the program;

[0117] (2) Design corresponding business scenarios for the legacy system to traverse as fully as possible the possible application execution paths and collect the runtime logs related to business functions;

[0118] (3) After the test cases start to execute, by means of the method call situations left by the probes in the legacy system, the collected call information is sent to the log collector and persistently saved locally.

[0119] 3. Business class aggregation module and quality assessment module

[0120] As Figure 6 shown, these two modules are mainly responsible for splitting the business boundaries of the legacy system and continuously iterating the results. The working process is as follows:

[0121] (1) According to the extracted call relationships, calculate the similarity between each class according to the preset rules to construct an inter-class similarity matrix;

[0122] (2) Implement clustering among different business logic layers. For classes belonging to the same layer, the present invention clusters them with classes in other layers, so as to establish a vertical logical association from top to bottom; for classes within the same layer, the present invention splits the classes from each other to avoid too high coupling between the finally obtained sub-modules. For example, for classes at the controller layer, after clustering with classes in the service layer, data persistence layer, and data entity layer, the present invention should analyze whether there are overlaps between the classes attached to each controller. If there are, then compare the similarity between these overlapping classes and the corresponding controller layer classes, and retain the higher similarity relationship;

[0123] (3) Calculate evaluation indicators for each division for the user to judge. If the user is not satisfied with the current division situation, the user can specify the total number of divisions to optimize the result, return to the previous step, and continue iterative tuning to obtain a result that better meets the expectations.

[0124] Although the tool implementation examples of the present invention are disclosed for illustrative purposes, which aim to help understand the content of the present invention and implement it accordingly, those skilled in the art can understand that: without departing from the spirit and scope of the present invention and the appended claims, various substitutions, changes, and modifications are possible. Therefore, the present invention should not be limited to the content disclosed in the best implementation examples, and the scope of protection required by the present invention is defined by the scope of the claims.

Claims

1. A microservice partitioning method based on domain knowledge in the programming framework field, characterized in that The method includes: Based on a programming framework, classify the classes in the software system into different logical levels; Establish the dependency call relationships between the classes in the software system; Combined with the dependency call relationships, obtain the test case set for each class; For two classes located in different logical levels, calculate the similarity between the classes based on the test cases involved in the test case set; Based on the similarity between the classes and the target number of classes for hierarchical clustering, obtain the microservice partitioning result.

2. The method according to claim 1, characterized in that, The classifying the classes in the software system into a control layer, a service layer, a data mapping layer, and a data entity layer based on the programming framework includes: Read the dependency configuration information stored in xml format from the Pom.xml file under the root directory of the software system; Based on the dependency configuration information, infer the programming framework of the software system; Based on the knowledge graph of the programming framework, identify the functional logical levels to which each class in the software system belongs; According to the functional logical levels, classify the classes into a control layer, a service layer, a data mapping layer, and a data entity layer respectively.

3. The method according to claim 1, wherein, The logical levels include: a control layer, a service layer, a data mapping layer, and a data entity layer.

4. The method according to claim 1, wherein The establishing the dependency call relationships between the classes in the software system includes: Instrument the software system through dynamic instrumentation technology; Inject probes into the J2EE application with JavaAgent to collect the method call traces of the software system when executing specific network requests; Based on the points in the method call traces, establish the dependency call relationships between the classes.

5. The method according to claim 1, characterized in that, The calculating the similarity between the classes for two classes located in different logical levels based on the test cases involved in the test case set includes: Calculate the direct call similarity between two classes where, c i represents the i-th class in a logical hierarchy, and c j represents the j-th class in another logical hierarchy, represents the set of test cases participated by class c i and represents the set of test cases participated by class c i and represents the set of test cases jointly participated by class c i and class c j ;​​ Calculate the direct call pattern similarity between two classes where represents the set of test cases jointly participated by class c i and class c k ; represents the set of test cases jointly participated by class c and class c j ; C represents the set of all classes involved in the dynamic testing process, and U represents the set of all test cases; k ​ Calculate the indirect call similarity between two classes where represents the set of test cases generated with other classes as intermediaries between class c i and class c j ; Calculate the similarity of indirect call patterns between two classes where represents the set of test cases generated with other classes as intermediaries between class c i and class c k ; represents the set of test cases generated with other classes as intermediaries between class c j and class c k ; Add the direct call similarity DCR(c i , c j ), the direct call pattern similarity DCP(c i , c j ), the indirect call similarity ICR(c i , c j ) and the indirect call pattern similarity ICP(c i , c j ), and obtain the inter-class similarity between class c i and class c j .

6. The method according to claim 1, wherein After establishing the dependency call relationships between the classes in the software system, it further includes: Judge whether there is a data persistence layer framework in the software system; In the case that there is a data persistence layer framework in the software system, obtain the database dependency relationship based on the data mapping information used by the data persistence layer framework.

7. The method according to claim 6, wherein The obtaining the microservice partitioning result based on the similarity between the classes and the target number of classes for hierarchical clustering includes: Based on the database dependency relationship, generate several data tables; wherein, the classes in each data table have dependency relationships; For two classes belonging to the same data table, assign a similarity weight to the corresponding similarity between the classes, so that the similarity between the classes after assigning the similarity weight is greater than the similarity between the classes before assigning the similarity weight; Based on the similarity between the classes after assigning the similarity weight and the target number of classes for hierarchical clustering, obtain the microservice partitioning result.

8. The method according to any one of claims 1 to 7, characterized in that The method further includes: Measure the quality of the microservice partitioning result; Based on the quality of the microservice partitioning result, modify the aggregation quantity in the microservice partitioning result to obtain the final microservice partitioning result.

9. The method according to claim 8, wherein The measuring the quality of the microservice partitioning result includes: Calculate the call ratio between the microservices in the microservice partitioning result, and compare the call ratio between the microservices with a first set threshold to obtain the quality of the microservice partitioning result; and / or Calculate the business context purity in the microservice partitioning result, compare the business context purity with a second set threshold, and obtain the quality of the microservice partitioning result; and / or, Calculate the number of interfaces in the microservice partitioning result, compare the number of interfaces with a third set threshold, and obtain the quality of the microservice partitioning result; and / or, Calculate the non-extreme degree in the microservice partitioning result, compare the non-extreme degree with a fourth set threshold, and obtain the quality of the microservice partitioning result; and / or, Calculate the class partitioning index in the microservice partitioning result, and when the class partitioning index does not meet the set requirements, after modifying the target number of classes for hierarchical clustering, return to the target number of classes for hierarchical clustering based on the inter-class similarity, and obtain the microservice partitioning result.

10. A microservice partitioning device based on domain knowledge in the programming framework field, characterized in that, The device includes: A programming framework analysis module, configured to classify classes in a software system into corresponding logical levels based on a programming framework; A dynamic test execution module, configured to establish a dependency call relationship between classes in a software system; A business class aggregation module, configured to combine the dependency call relationship to obtain a test case set for each class; for two classes located in different logical levels, calculate the inter-class similarity based on the test cases involved in the test case set; obtain the microservice partitioning result based on the inter-class similarity and the target number of classes for hierarchical clustering.

11. The device according to claim 10, characterized in that, The device further includes: An instruction evaluation module, configured to measure the quality of the microservice partitioning result and modify the aggregation quantity in the microservice partitioning result based on the quality of the microservice partitioning result to obtain the final microservice partitioning result.

Citation Information

Patent Citations

  • Test case generation method and device, computer equipment and storage medium

    CN112527630A

  • Multilayer architecture identification method based on software dependency relationship extraction

    CN113467786A