CN115309634A - Micro-service extraction method, system, medium, equipment and information processing terminal - Google Patents

Micro-service extraction method, system, medium, equipment and information processing terminal Download PDF

Info

Publication number
CN115309634A
CN115309634A CN202210835089.8A CN202210835089A CN115309634A CN 115309634 A CN115309634 A CN 115309634A CN 202210835089 A CN202210835089 A CN 202210835089A CN 115309634 A CN115309634 A CN 115309634A
Authority
CN
China
Prior art keywords
micro
service
services
class
source code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210835089.8A
Other languages
Chinese (zh)
Inventor
王宾
邓亚楠
贺小伟
吴昊
张渊辉
王师蕾
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Northwest University
Original Assignee
Northwest University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Northwest University filed Critical Northwest University
Priority to CN202210835089.8A priority Critical patent/CN115309634A/en
Publication of CN115309634A publication Critical patent/CN115309634A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention belongs to the technical field of micro-service extraction, and discloses a micro-service extraction method, a system, a medium, equipment and an information processing terminal, which are used for carrying out hierarchical division on a source code; acquiring a time sequence diagram of each method of a control layer through reverse engineering, and acquiring class diagrams of a physical layer, a database access layer and other layers; modeling a display service function of the time sequence diagram; carrying out implicit business function modeling on the class diagram; extracting candidate micro-services of the source code based on the business function model through spectral clustering; evaluating the quality of the candidate micro-service; and the candidate micro-services are visualized in a graph structure form, and an adjusting function is provided for the framework personnel. The method uses the spectral clustering algorithm to extract the micro-services, and achieves the aims of high cohesion inside the micro-services and low coupling among the micro-services; the extraction of the micro-service after the business function modeling is carried out on the source code greatly reduces the use threshold of the method, and reduces the time cost and the labor cost of extracting the monomer architecture to the micro-service.

Description

Micro-service extraction method, system, medium, equipment and information processing terminal
Technical Field
The invention belongs to the technical field of micro-service extraction, and particularly relates to a micro-service extraction method, a system, a medium, equipment and an information processing terminal.
Background
The system of the monomer architecture is migrated to the micro-service architecture, so that the problems of the system based on the monomer architecture can be better solved. The task of micro-service extraction is to reasonably extract classes with the same business function from a single-body architecture system to form a group of candidate micro-services. Compared with the traditional manual extraction and identification method, the existing micro-service extraction method realizes automatic or semi-automatic micro-service identification, but the key input part for determining the extraction of the candidate micro-service quality still depends on the generation of professionals, the method has higher use threshold, and the automatic extraction method has higher difficulty. The current automatic extraction method mainly comprises a static method and a dynamic method, and has the following characteristics: 1. the extraction method for performing the micro-service based on the program running execution track depends on the design of the test case, the test case needs to be generated by a software designer familiar with the system, and the legacy system often has the problems of complex business, large flow of developers and incomplete documents, so that the design of the test case is difficult to completely cover all business functions, the incomplete design of the test case can cause the coverage rate of the proposed micro-service class to be lower, and the use threshold of the method is higher. 2. The method for extracting the micro-service based on the source code generally adopts the similarity of the code as a basis to extract the micro-service, cannot fully reflect the business relationship, has poor quality and usability of the extracted micro-service, and greatly determines the expansibility of the micro-service according to the quality of the micro-service, so that the method has great hidden danger in use. The above problems all lead to the difficulty of automatic extraction of the micro-service.
Through the above analysis, the problems and defects of the prior art are as follows: the extraction method for performing the micro-service based on the program running execution track depends on the design of the test case, the test case needs to be generated by a software designer familiar with the system, and the legacy system often has the problems of complex business, large flow of developers and incomplete documents, so that the design of the test case is difficult to completely cover all business functions, the incomplete design of the test case can cause the coverage rate of the proposed micro-service class to be lower, and the use threshold of the method is higher. The method for extracting the micro-service based on the source code generally adopts the similarity of the codes as a basis to extract the micro-service, cannot fully reflect the business relationship, has poor quality and usability of the extracted micro-service, and largely determines the expansibility of the micro-service, so the method has low applicability.
Disclosure of Invention
The invention provides a method, a system, a medium, a device and an information processing terminal for extracting micro-services, and particularly relates to a method, a system, a medium, a device and an information processing terminal for extracting micro-services based on a single system source code.
The invention is realized in such a way that a micro-service extraction method comprises the following steps: generating a class diagram and a sequence diagram according to the source code; extracting service functions based on the class diagram and the sequence diagram; and performing micro-service extraction on the extracted service function by using a rapid spectral clustering algorithm, and finally performing quality evaluation and visual display on the generated candidate micro-service.
Carrying out hierarchical division on a source code; acquiring a time sequence diagram of each method of a control layer through reverse engineering, and acquiring class diagrams of a physical layer, a database access layer and other layers; modeling a display service function of the time sequence diagram; carrying out implicit business function modeling on the class diagram; extracting candidate micro-services of the source code based on the business function model through spectral clustering; evaluating the quality of the candidate micro-service; and finally, visualizing the candidate micro-services in a graph structure form to provide an adjusting function for the framework personnel.
Further, the micro-service extraction method comprises the following steps:
step one, performing hierarchical division on a source code, acquiring a timing diagram of a control layer through reverse engineering, and acquiring class diagrams of a physical layer, a database access layer and other layers; because source code writing irregularities can affect the extraction of microservices.
Step two, performing display service function modeling on the time sequence diagram, and performing implicit service function modeling on the class diagram; the method is characterized in that a time sequence diagram can reflect dynamic relations among classes, and a class diagram is analyzed mainly by considering the idea that a domain-driven model is popular in the splitting of the current micro-service, so that the domain relations can be mined through class diagram analysis, and partial service relations which cannot be reflected by the time sequence diagram are supplemented.
And step three, extracting candidate micro services of the source code based on the business function model through spectral clustering, wherein the spectral clustering takes the identification of the micro services as graph clustering, and the micro services with high cohesion and low coupling are extracted.
Evaluating the quality of the candidate micro-service, visualizing the candidate micro-service in a graph structure form and providing an adjusting function; the method is characterized in that the legacy system is improved by using the micro-service with poor quality, the expansibility is poor, the advantage of a micro-service architecture cannot be fully embodied, and the condition can be avoided by evaluating the quality of the micro-service.
Further, in the first step, the source code of the single legacy system is hierarchically divided, and a control layer, a service layer, a database access layer, a physical layer and other layers in the source code are identified.
Generating a time sequence diagram and a class diagram of the system through reverse engineering according to the source code of the single system program:
(1) Generating a timing graph for each method in a control layer of the source code using a SequenceDiagram tool, wherein the control layer of the source code refers to a class that interacts with a user interface display in charge;
(2) Class diagrams for the database access layer and the physical and other layers are generated for each class file of the source code using the PlantUML Parser tool.
Further, in the second step, the service function modeling is displayed on the timing diagram to obtain a calling relation mapping table between classes, and the method specifically includes:
(1) Reading one time sequence diagram file from a plurality of time sequence diagram files for analysis, and ending the business function modeling process when the time sequence diagram file is empty;
(2) Statistics of two classes C i And C j Number of calls f between ij Each occurrence of C i To C j Calling relationship between f ij Adding 1;
(3) Two classes C i And C j The number of calls between them is stored in the Map structure, where the key is a string composed of two classes of class names concatenated with "_", and the value is the number of calls f ij
(4) And after all the time chart files are analyzed, outputting the model Map.
Carrying out implicit business function modeling according to the class diagram to obtain a semantic similarity relation matrix between classes:
(1) Reading two class diagrams in a plurality of class diagram files for analysis, and ending the implicit business function modeling process when the class diagram files are empty;
(2) Computing two class diagrams C i And C j Semantic similarity between S ij (ii) a Making a bag dictionary according to input text information, and matching the words in the text with keys in the bag to obtain a corpus; initializing a tf-idf transformation model to obtain a converted corpus coprus _ tfidf, training a coprus _ tfidf corpus by using an Lsi model, and calculating the sparse matrix similarity; and converting the format by using a word segmentation list needing to find the similarity as a corpus doc _ test _ vec to obtain the similarity of the text.
Further, in the third step, after the business function model of the source code is obtained, clustering is performed by using a spectral clustering algorithm to obtain the candidate micro-service.
(1) Constructing a similarity matrix, wherein the formula is as follows:
Figure BDA0003749592600000041
wherein, W ij Representing a similarity matrix, w if there is a call between two classes i and j ij =map ij Otherwise w ij =S ij ;D ij Is a diagonal matrix, and the value on the diagonal is the sum of corresponding rows or columns in the W matrix;
(2) Constructing a Laplace matrix L and normalizing the L, wherein the formula is as follows:
L=D-W;
Figure BDA0003749592600000042
(3) Decomposing eigenvalues of the Laplacian matrix, accelerating the decomposition process by using a Lanczos method to obtain the first k minimum eigenvalues and corresponding eigenvectors, and finally forming a k-dimensional eigenvalue matrix F;
(4) Clustering the k-dimensional feature matrix F by using Kmeans; using AFK-MC 2 Selecting initial cluster center, randomly selecting and extracting an initial center sample c 1 (ii) a Calculating a proposal distribution q (x) of all data sets, randomly extracting a data point from q (x) and calculating a distance dx; sampling a sequence with the length of m by using Markov chain Monte Carlo, and taking the last k-1 sequences as central points C = { C1, C2,.., ck };
Figure BDA0003749592600000043
Figure BDA0003749592600000044
Figure BDA0003749592600000045
using A-means to reduce the time for the K-means algorithm to assign data points to cluster C; calculate each data point x i Selecting the closest centroid C to the distance from the cluster center k Calculating the equidistant index alpha of said points i The formula is as follows:
α i =abs(||i-μ 1 || 2 -||i-μ 2 || 2 );
calculating an improvement threshold
Figure BDA0003749592600000051
The formula is as follows:
Figure BDA0003749592600000052
when in use
Figure BDA0003749592600000053
When x i Do not move in round iterations, x i Fixed allocation to cluster C k And no longer participate in distance calculation and reassignment.
After spectral clustering, a group of clustering results is obtained, and each clustering cluster is a micro service candidate.
Further, the quality evaluation of the extracted candidate micro service in the fourth step includes:
using a modularization evaluation mode, the higher the modularization evaluation value is, the lower the coupling degree between the micro services is, and the higher the polymerization degree inside the micro service is, and the calculation formula is as follows:
Figure BDA0003749592600000054
where N is the number of microservices, N i Is the number of classes within the microservice, W i Is the weighted sum, W, between the internal edges of the microservice i i,j Is the weighted sum of the edges between micro-service i and micro-service j.
And visualizing the extracted candidate micro-services, displaying the micro-services to which the class files belong and the calling relation among the classes in a graph structure form based on Echarts, and dragging a vertex to manually adjust the micro-services to which the classes belong.
Another object of the present invention is to provide a microservice extraction system using the microservice extraction method, the microservice extraction system comprising:
the hierarchical division module is used for hierarchically dividing the source code, acquiring a timing chart of the control layer through reverse engineering, and acquiring class diagrams of a physical layer, a database access layer and other layers;
the business function modeling module is used for performing display business function modeling on the time sequence diagram and performing implicit business function modeling on the class diagram;
the candidate micro-service extraction module is used for extracting candidate micro-services of the source codes based on the business function model through spectral clustering;
and the quality evaluation module is used for evaluating the quality of the candidate micro-service, visualizing the candidate micro-service in a graph structure form and providing an adjusting function.
Another object of the present invention is to provide a computer device comprising a memory and a processor, the memory storing a computer program which, when executed by the processor, causes the processor to perform the steps of the microservice extraction method.
It is a further object of the present invention to provide a computer readable storage medium, storing a computer program which, when executed by a processor, causes the processor to perform the steps of the microservice extraction method.
Another object of the present invention is to provide an information data processing terminal for implementing the micro-service extraction system.
In combination with the technical solutions and the technical problems to be solved, please analyze the advantages and positive effects of the technical solutions to be protected in the present invention from the following aspects:
first, aiming at the technical problems existing in the prior art and the difficulty in solving the problems, the technical problems to be solved by the technical scheme of the present invention are closely combined with results, data and the like in the research and development process, and some creative technical effects are brought after the problems are solved. The specific description is as follows:
the micro-service extraction method provided by the invention carries out business function modeling based on the source code, and solves the problem of poor modularity of the method for carrying out micro-service extraction directly based on the similarity of the source code; the spectral clustering algorithm is used for extracting the micro-services, so that the targets of high cohesion inside the micro-services and low coupling between the micro-services are better realized; the extraction of the micro-service after the business function modeling is carried out on the source code greatly reduces the use threshold of the method, the framework personnel can obtain the candidate micro-service without knowing the legacy system, the automation of the extraction of the micro-service is realized, and the time cost and the labor cost of the extraction of the monomer framework to the micro-service are reduced.
The invention solves the problems that the generation of the key input part of the micro-service extraction technology needs professional personnel and the use threshold of the method is high by providing the method for modeling the service function based on the source code. The method enables an architect to quickly obtain the candidate micro-services only by automatically generating the sequence diagram and the class diagram through reverse engineering when the micro-services of the single-architecture legacy system are extracted. The service function of the legacy system does not need to be analyzed, and the use threshold of the micro-service extraction method is reduced. The method and the system can visualize the extracted micro-services in a graph form, and are convenient for an architect to visually observe the extraction result for adjustment.
Secondly, considering the technical scheme as a whole or from the perspective of products, the technical effect and advantages of the technical scheme to be protected by the invention are specifically described as follows:
the micro-service extraction method provided by the invention aims to automatically acquire the service function information to extract the micro-service by using the source code of the single legacy system, and reduces the use threshold of the micro-service extraction method. The method helps the constructors to quickly extract the micro-services from the single legacy system, so that the constructors do not need to know the service information of the single legacy system, the use threshold of the method is reduced, the technical personnel can conveniently and quickly obtain the micro-services with high cohesion and low coupling, and the cost and risk of the migration of the single architecture to the micro-service architecture are reduced.
Third, as an inventive supplementary proof of the claims of the present invention, there are also presented several important aspects:
(1) The technical scheme of the invention fills the technical blank in the industry at home and abroad:
the current mainstream micro-service extraction technology has the following problems: 1. the extraction method for performing the micro-service based on the program running execution track depends on the design of the test case, the test case needs to be generated by a software designer familiar with the system, and the legacy system often has the problems of complex business, large flow of developers and incomplete documents, so that the design of the test case is difficult to completely cover all business functions, the incomplete design of the test case can cause the coverage rate of the proposed micro-service class to be lower, and the use threshold of the method is higher. 2. The method for extracting the micro-service based on the source code generally adopts the similarity of the code as a basis to extract the micro-service, cannot fully reflect the business relationship, has poor quality and usability of the extracted micro-service, and greatly determines the expansibility of the micro-service according to the quality of the micro-service, so that the method has great hidden danger in use. The above problems all lead to the difficulty of automatic extraction of the micro-service.
The method provides a technology for extracting the business function based on the source code, and utilizes reverse order engineering to generate a sequence diagram acquired from the source code so as to obtain a calling relation reflecting the business function of the program. The method can improve the quality of the micro-service without the participation of experts, and reduces the difficulty of automatic extraction of the micro-service.
(2) The technical scheme of the invention solves the technical problems which are always desired to be solved but are not successfully achieved:
the micro-service extraction technology is dedicated to research on a method capable of automatically splitting a single body system into micro-services, and the obtained micro-services have good functional modularity, are easy to expand, develop and maintain, and can solve the problem that the single body system is difficult to maintain and expand. But current microservice extraction methods do not simultaneously address the above challenges.
The method for extracting the service function based on the source code solves the technical problems that the prior method for automatically acquiring the program service function needs to be analyzed based on the program running track, a test case can not be designed by an expert, and the full automation can not be realized; the technical problem that the micro-service quality extracted by the traditional source code-based method is poor is solved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments of the present invention will be briefly described below, and it is obvious that the drawings described below are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flowchart of a method for extracting microservice provided by an embodiment of the present invention;
FIG. 2 is a flow chart of modeling a display service function according to an embodiment of the present invention;
FIG. 3 is a flow chart of implicit business function modeling provided by an embodiment of the present invention;
FIG. 4 is a result diagram of a visualization of candidate microservices provided by an embodiment of the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is further described in detail with reference to the following embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
In view of the problems in the prior art, the present invention provides a method, a system, a medium, a device and an information processing terminal for extracting micro-services, which are described in detail below with reference to the accompanying drawings.
1. Illustrative embodiments are explained. This section is an explanatory embodiment expanding on the claims so as to fully understand how the present invention is embodied by those skilled in the art.
As shown in fig. 1, the method for extracting micro services provided by the embodiment of the present invention includes the following steps:
s101, performing hierarchical division on a source code;
s102, acquiring a timing diagram and a class diagram of a control layer through reverse engineering;
s103, modeling a display service function of the time sequence diagram;
s104, carrying out implicit business function modeling on the class diagram;
s105, extracting candidate micro-services of the source codes based on the business function model through spectral clustering;
s106, evaluating the quality of the candidate micro service;
and S107, visualizing the candidate micro-services in a graph structure form and providing an adjusting function.
As a preferred embodiment, the method for extracting micro services provided in the embodiment of the present invention specifically includes the following steps:
s1: the source code of the monolithic legacy system is hierarchically partitioned, as shown in fig. 2, to identify a control layer, a business layer, a database access layer, a physical layer, and other layers in the source code. The source code, which generally follows the development specification, all lie under the same package with the same suffix name for the class. The control layer is generally located under a package where a Controller, an Action, a View and the like directly receive a user request and respond to the class of the user. The database access layer is typically located under Dao or a package that interacts directly with the database. The Service layer is typically located under a package of Service, etc. that interacts with both the control layer and the database layer. Classes in the physical layer are typically used to encapsulate data for data transmission. The other classes mainly relate to configuration classes of items, tool classes, and the like.
S2: the timing diagrams and class diagrams are generated by reverse engineering. Specifically, this step comprises the following substeps:
s21: generating a timing graph for each method in a control layer of the source code using a SequenceDiagram tool, wherein the control layer of the source code refers to a class that interacts with a user interface display in charge;
s22: a class diagram is generated for each class file of the source code using the PlantUMLParser tool.
S3: modeling a display service function according to a timing diagram, and fig. 2 is a flow chart of modeling a display service function provided by an embodiment of the present invention, and the detailed process is as follows:
s31: firstly, reading one time sequence diagram file from a plurality of time sequence diagram files for analysis, and ending a modeling process of displaying a business function when the time sequence diagram file is empty;
s32: statistics of two classes C i And C j Number of calls f between ij No occurrence of a C i To C j Calling relationship between f ij Adding 1;
s33: two classes C i And C j The number of times of call between is stored in the Map structure, wherein the key is a character string composed of two classes of class names spliced by using a _, and the value is the number of times of call f ij
S34: and after all the time sequence diagram files are analyzed, outputting the model Map.
S4: an implicit service function modeling is performed according to the class diagram, and fig. 3 is a flowchart of the implicit function modeling provided by the embodiment of the present invention, and the detailed process is as follows:
s41: firstly, reading two class diagrams from a plurality of class diagram files for analysis, and ending the implicit business function modeling process when the class diagram files are empty;
s42: computing two class diagrams C i And C j Semantic similarity between S ij . Firstly, a bag-of-words dictionary is made according to input text information, then matching is carried out according to words in a text and keys in the bag-of-words to obtain a corpus, a tf-idf conversion model is initialized to obtain a converted corpus _ tfidf, the corpus _ tff corpus is trained by using an Lsi model to calculate sparse matrix similarity, a format conversion is carried out to make a participle list needing to find the similarity into a corpus doc _ test _ vec, and the similarity of the text is obtained.
S5: clustering is carried out by using spectral clustering to obtain candidate micro services, and the detailed process is as follows:
s51: constructing a similarity matrix, formula W ij Representing a similarity matrix, w if there is a call between two classes i and j ij =map ij Otherwise w ij =S ij ;D ij For a diagonal matrix, the values on the diagonal are the sums of corresponding rows or columns in the W matrix.
Figure BDA0003749592600000101
S52: constructing a Laplace matrix L and normalizing the L, wherein the formula is as follows:
L=D-W
Figure BDA0003749592600000102
s53: and (3) carrying out eigenvalue decomposition on the Laplace matrix, accelerating the decomposition process by using a Lanczos method to obtain the first k minimum eigenvalues and corresponding eigenvectors, and finally forming a k-dimensional eigenvalue matrix F.
S54: the k-dimensional feature matrix F is clustered using Kmeans. First using AFK-MC 2 Selecting an initial cluster center, randomly selecting and extracting an initial center sample c1, then calculating proposal distribution q (x) of all data sets (shown in formula 5), randomly extracting a data point from q (x) and calculating a distance dx (shown in formula 6); finally, a sequence with the length of m is sampled by a Markov chain Monte Carlo (Metropolis-Hastings), and the last k-1 sequences are taken as central points C = { C1, C2.
Figure BDA0003749592600000111
Figure BDA0003749592600000112
d x =d(x,C i-1 ) 2
The use of A-means reduces the time for the K-means algorithm to assign data points to cluster C. Calculate each data point x i Selecting the closest centroid C to the distance from the cluster center k Calculating the equidistant index alpha of the point i The formula is as follows:
α i =abs(||i-μ 1 || 2 -||i-μ 2 || 2 )
calculating an improvement threshold
Figure BDA0003749592600000113
The formula is as follows:
Figure BDA0003749592600000114
when in use
Figure BDA0003749592600000115
Then, consider xi not to move in this iteration, let x i Fixed allocation to cluster C k No further participation in distance calculation and reassignment is made.
After the spectral clustering of the steps, a group of clustering results can be obtained, and each clustering is a micro-service candidate.
S6: and performing quality evaluation on the extracted candidate micro service. By using the modularized evaluation method, the higher the modularized evaluation value is, the lower the coupling degree between the micro-services is, and the higher the polymerization degree inside the micro-services is. The formula is as follows:
Figure BDA0003749592600000116
where N is the number of microservices, N i Is the number of classes within the microservice, W i Is the weighted sum, W, between the internal edges of the microservice i i,j Is the weighted sum of the edges between micro-service i and micro-service j.
S7: and visualizing the candidate micro-services extracted by the method, and displaying the micro-services to which each class belongs in a graph structure form based on Echarts. As shown in fig. 4, the vertex of the graph represents a class file, the color of the vertex represents the micro service to which the vertex belongs, the vertex with the same color belongs to the same micro service, and the edge represents the call relationship between classes.
The micro-service extraction system provided by the embodiment of the invention comprises:
the hierarchical division module is used for carrying out hierarchical division on the source code, acquiring a timing diagram of a control layer through reverse engineering, and acquiring class diagrams of a physical layer, a database access layer and other layers;
the service function modeling module is used for carrying out display service function modeling on the time sequence diagram and carrying out implicit service function modeling on the class diagram;
the candidate micro-service extraction module is used for extracting candidate micro-services of the source codes based on the business function model through spectral clustering;
and the quality evaluation module is used for evaluating the quality of the candidate micro-service, visualizing the candidate micro-service in a graph structure form and providing an adjusting function.
2. Application examples. In order to prove the creativity and the technical value of the technical scheme of the invention, the part is the application example of the technical scheme of the claims on specific products or related technologies.
The technical solution of the present invention is described in detail below with reference to the embodiment of extracting the micro-service of the application spring blog.
First, the source code of the SpringBlog application program is pulled on the gitubs, and the hierarchical relationship of the source code is analyzed. The control layer, business layer, database access layer, physical layer, and other layers in the source code are identified. The class of the control layer is the class directly receiving the user request and responding to the user, at the end of the suffix Controller. The database access layer is typically located under the repositories, package that interacts with the database. The Service layer is located under a Service package which interacts with both the control layer and the database layer. Classes in the phy layer are typically used to encapsulate data for data transmission, mainly under the models and forms packets. The other classes mainly relate to the configuration class of the item and the tool class.
In the second step, a tool is used to obtain the timing diagram of the control layer for the SpringBlog control layer, as well as the class diagram of the other layers.
And thirdly, modeling the display service function according to the time sequence diagram. Reading one time sequence diagram file from a plurality of time sequence diagram files for analysis, and ending the business function modeling process when the time sequence diagram file is empty; and outputting the model Map. Statistics of two classes C i And C j Number of calls f between ij No occurrence of a C i To C j Calling relationship between f ij Adding 1; two classes C i And C j The number of calls between them is stored in the Map structure, where the key is a string composed of two classes of class names concatenated with "_", and the value is the number of calls f ij
And fourthly, carrying out implicit business function modeling according to the class diagram. Calculating semantic similarity S between the two class diagrams Ci and Cj ij . Firstly, bag-of-words dictionary is made according to input text information, then matching is carried out according to words in the text and keys in the bags of words to obtain a corpus, a tf-idf conversion model is initialized to obtain a converted corpus _ tfidf, the corpus _ tfidf corpus is trained by using an Lsi model to calculate sparse matrix similarity, a format conversion is carried out to make a participle list needing to find the similarity into a corpus doc _ test _ vec, and the similarity of the text is obtained.
And fifthly, clustering by using spectral clustering to obtain candidate micro services.
And sixthly, using a modularization evaluation mode, wherein the higher the modularization evaluation value is, the lower the coupling degree between the micro services is, and the higher the polymerization degree inside the micro services is. The formula is as follows:
Figure BDA0003749592600000131
where N is the number of microservices, N i Is the number of classes within the microservice, W i Is the weighted sum, W, between the internal edges of the microservice i i,j Is the weighted sum of the edges between micro-service i and micro-service j.
And seventhly, visualizing the candidate micro-services extracted by the method.
3. Evidence of the relevant effects of the examples. The embodiment of the invention achieves some positive effects in the process of research and development or use, and has great advantages compared with the prior art, and the following contents are described by combining data, diagrams and the like in the test process.
Compared with the traditional micro-service extraction method based on source codes, the micro-service extraction method provided by the invention has the advantages that the module quality is greatly improved, and the following table shows the quality evaluation of the two methods for extracting the micro-service by the SpringBlog application program.
Where the MEMSC is the MQ value of the extracted micro-service of the traditional approach and the OUR is the MQ value of the micro-service obtained by the approach presented herein. And K is the splitting granularity of the micro-services, the SpringBlog application program is split into 6 micro-services, 7 micro-services, 8 micro-services, 9 micro-services and 10 micro-services respectively, and the module quality MQ of the micro-services is counted. The MQ value represents the quality of the microservice, the higher the value, the better the modularity of the microservice, and the more the microservice meets the criteria of high cohesion and low coupling.
By observation, the micro-service extraction method provided by the invention has higher micro-service quality than the traditional micro-service extraction method under five different splitting granularities. Especially, in the case that the splitting granularity k =9, the quality of the micro service is greatly improved.
Figure BDA0003749592600000141
It should be noted that embodiments of the present invention can be realized in hardware, software, or a combination of software and hardware. The hardware portion may be implemented using dedicated logic; the software portions may be stored in a memory and executed by a suitable instruction execution system, such as a microprocessor or specially designed hardware. Those skilled in the art will appreciate that the apparatus and methods described above may be implemented using computer executable instructions and/or embodied in processor control code, such code being provided on a carrier medium such as a disk, CD-or DVD-ROM, programmable memory such as read only memory (firmware), or a data carrier such as an optical or electronic signal carrier, for example. The apparatus and its modules of the present invention may be implemented by hardware circuits such as very large scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, or programmable hardware devices such as field programmable gate arrays, programmable logic devices, etc., or by software executed by various types of processors, or by a combination of hardware circuits and software, e.g., firmware.
The above description is only for the purpose of illustrating the present invention and the appended claims are not to be construed as limiting the scope of the invention, which is intended to cover all modifications, equivalents and improvements that are within the spirit and scope of the invention as defined by the appended claims.

Claims (10)

1. A micro-service extraction method is characterized by comprising the following steps:
performing hierarchical division on a source code; acquiring a time sequence diagram of each method of a control layer through reverse engineering, and acquiring class diagrams of a physical layer, a database access layer and other layers; modeling a display service function of the time sequence diagram; carrying out implicit business function modeling on the class diagram; extracting candidate micro-services of the source code based on the business function model through spectral clustering; evaluating the quality of the candidate micro-service; and finally, visualizing the candidate micro-services in a graph structure form to provide an adjusting function for the framework personnel.
2. A microservice extraction process as claimed in claim 1, characterised in that it comprises the following steps:
step one, performing hierarchical division on a source code, acquiring a timing diagram of a control layer through reverse engineering, and acquiring class diagrams of a physical layer, a database access layer and other layers;
step two, performing display service function modeling on the time sequence diagram, and performing implicit service function modeling on the class diagram;
extracting candidate micro-services of the source codes based on the business function model through spectral clustering;
and step four, evaluating the quality of the candidate micro-service, visualizing the candidate micro-service in a graph structure form and providing an adjusting function.
3. The microservice extraction method of claim 2, wherein in the first step, the source code of the single legacy system is hierarchically divided, and a control layer, a business layer, a database access layer, a physical layer and other layers in the source code are identified;
generating a time sequence diagram and a class diagram of the system through reverse engineering according to the source code of the single system program:
(1) Generating a timing graph for each method in a control layer of the source code using a SequenceDiagram tool, wherein the control layer of the source code refers to a class that interacts with a user interface display in charge;
(2) Class diagrams for the database access layer and the physical and other layers are generated for each class file of the source code using the PlantUML Parser tool.
4. The microservice extraction method of claim 2, wherein in the second step, the obtaining of the call relation mapping table between classes by performing display service function modeling on the timing diagram specifically comprises:
(1) Reading one time sequence diagram file from a plurality of time sequence diagram files for analysis, and ending the business function modeling process when the time sequence diagram file is empty;
(2) Counting the calling times fij between the two classes Ci and Cj, and adding 1 to fij when the calling relation between Ci and Cj occurs once;
(3) Storing the calling times between the two classes Ci and Cj in a Map structure, wherein the key is a character string formed by splicing the class names of the two classes by using a _, and the value is the calling times fij;
(4) After all the time sequence diagram files are analyzed, outputting a model Map;
carrying out implicit business function modeling according to the class diagram to obtain a semantic similarity relation matrix between classes:
(1) Reading two class diagrams from a plurality of class diagram files for analysis, and ending the implicit business function modeling process when the class diagram files are empty;
(2) Calculating semantic similarity Sij between the two class diagrams Ci and Cj; making a bag dictionary according to input text information, and matching the words in the text with keys in the bag to obtain a corpus; initializing a tf-idf transformation model to obtain a converted corpus coprus _ tfidf, training a coprus _ tfidf corpus by using an Lsi model, and calculating the sparse matrix similarity; and converting the format by using a word segmentation list needing to find the similarity as a corpus doc _ test _ vec to obtain the similarity of the text.
5. The microservice extraction method of claim 2, wherein in the third step, after obtaining the service function model of the source code, clustering is performed by using a spectral clustering algorithm to obtain candidate microservices;
(1) Constructing a similarity matrix, wherein the formula is as follows:
Figure FDA0003749592590000021
wherein Wij represents a similarity matrix, if a calling relationship exists between two classes i and j, wij = mapij, and vice versa; dij is a diagonal matrix, and the value on the diagonal is the sum of corresponding rows or columns in the W matrix;
(2) Constructing a Laplace matrix L and normalizing the L, wherein the formula is as follows:
L=D-W;
Figure FDA0003749592590000022
(3) Decomposing eigenvalues of the Laplacian matrix, accelerating the decomposition process by using a Lanczos method to obtain the first k minimum eigenvalues and corresponding eigenvectors, and finally forming a k-dimensional eigenvalue matrix F;
(4) Clustering the k-dimensional feature matrix F by using Kmeans; selecting initial clustering centers by using AFK-MC2, and randomly selecting and extracting an initial center sample c 1 (ii) a Calculating a proposal distribution q (x) of all data sets, randomly extracting a data point from q (x) and calculating a distance dx; sampling a sequence with the length of m by using Markov chain Monte Carlo, and taking the last k-1 sequences as central points C = { C1, C2,.., ck };
Figure FDA0003749592590000031
Figure FDA0003749592590000032
using A-means to reduce the time for the K-means algorithm to assign data points to cluster C; calculate each data point x i Selecting the closest centroid C to the distance from the cluster center k Calculating the equidistant index alpha of said points i The formula is as follows:
α i =abs(||i-μ 1 || 2 -||i-μ 2 || 2 );
calculating an improvement threshold
Figure FDA0003749592590000033
The formula is as follows:
Figure FDA0003749592590000034
when in use
Figure FDA0003749592590000035
When x is i Do not move in round iterations, x i Fixed allocation to cluster C k No longer participating in distance calculation and reallocation;
after spectral clustering, a group of clustering results is obtained, and each clustering cluster is a micro service candidate.
6. The microservice extraction method of claim 2, wherein the quality assessment of the extracted candidate microservices at step four comprises:
using a modularization evaluation mode, the higher the modularization evaluation value is, the lower the coupling degree between the micro services is, and the higher the polymerization degree inside the micro service is, and the calculation formula is as follows:
Figure FDA0003749592590000036
where N is the number of microservices, N i Is the number of classes within the microservice, W i Is the weighted sum, W, between the internal edges of the microservice i i,j Is the sum of the weights of the edges between micro service i and micro service j;
and visualizing the extracted candidate micro-services, displaying the micro-services to which the class files belong and the calling relation among the classes in a graph structure form based on Echarts, and dragging a vertex to manually adjust the micro-services to which the classes belong.
7. A microservice extraction system to which the microservice extraction method of any of claims 1 to 6 is applied, the microservice extraction system comprising:
the hierarchical division module is used for hierarchically dividing the source code, acquiring a timing chart of the control layer through reverse engineering, and acquiring class diagrams of a physical layer, a database access layer and other layers;
the business function modeling module is used for performing display business function modeling on the time sequence diagram and performing implicit business function modeling on the class diagram;
the candidate micro-service extraction module is used for extracting candidate micro-services of the source codes based on the business function model through spectral clustering;
and the quality evaluation module is used for evaluating the quality of the candidate micro-service, visualizing the candidate micro-service in a graph structure form and providing an adjusting function.
8. A computer arrangement, characterized in that the computer arrangement comprises a memory and a processor, the memory storing a computer program which, when executed by the processor, causes the processor to carry out the steps of the microservice extraction method according to any of the claims 1-6.
9. A computer-readable storage medium, storing a computer program which, when executed by a processor, causes the processor to carry out the steps of the microservice extraction method according to any of claims 1 to 6.
10. An information data processing terminal characterized by being configured to implement the micro-service extraction system of claim 7.
CN202210835089.8A 2022-07-16 2022-07-16 Micro-service extraction method, system, medium, equipment and information processing terminal Pending CN115309634A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210835089.8A CN115309634A (en) 2022-07-16 2022-07-16 Micro-service extraction method, system, medium, equipment and information processing terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210835089.8A CN115309634A (en) 2022-07-16 2022-07-16 Micro-service extraction method, system, medium, equipment and information processing terminal

Publications (1)

Publication Number Publication Date
CN115309634A true CN115309634A (en) 2022-11-08

Family

ID=83857533

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210835089.8A Pending CN115309634A (en) 2022-07-16 2022-07-16 Micro-service extraction method, system, medium, equipment and information processing terminal

Country Status (1)

Country Link
CN (1) CN115309634A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115759720A (en) * 2022-11-24 2023-03-07 北京中知智慧科技有限公司 Method and device for disassembling micro-service of software system
CN117311801A (en) * 2023-11-27 2023-12-29 湖南科技大学 Micro-service splitting method based on networking structural characteristics
CN117539433A (en) * 2023-11-02 2024-02-09 北京航空航天大学 Microservice design method based on model driven architecture

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115759720A (en) * 2022-11-24 2023-03-07 北京中知智慧科技有限公司 Method and device for disassembling micro-service of software system
CN117539433A (en) * 2023-11-02 2024-02-09 北京航空航天大学 Microservice design method based on model driven architecture
CN117311801A (en) * 2023-11-27 2023-12-29 湖南科技大学 Micro-service splitting method based on networking structural characteristics
CN117311801B (en) * 2023-11-27 2024-04-09 湖南科技大学 Micro-service splitting method based on networking structural characteristics

Similar Documents

Publication Publication Date Title
CN115309634A (en) Micro-service extraction method, system, medium, equipment and information processing terminal
US20190095806A1 (en) SGCNN: Structural Graph Convolutional Neural Network
US7720773B2 (en) Partitioning data elements of a visual display of a tree using weights obtained during the training state and a maximum a posteriori solution for optimum labeling and probability
CN110162771B (en) Event trigger word recognition method and device and electronic equipment
CN109815955A (en) Topic householder method and system
US20050246353A1 (en) Automated transformation of unstructured data
CN108959474B (en) Entity relation extraction method
CN111512315A (en) Block-wise extraction of document metadata
CN107391682B (en) Knowledge verification method, knowledge verification apparatus, and storage medium
Mitchell et al. Measuring data
JPWO2013132614A1 (en) Meaning estimation apparatus, method, and program
Egbert et al. Bootstrapping techniques
CN113158656B (en) Ironic content recognition method, ironic content recognition device, electronic device, and storage medium
CN112464927B (en) Information extraction method, device and system
CN109983473A (en) Flexible integrated identification and semantic processes
CN109144879B (en) Test analysis method and device
CN117217315B (en) Method and device for generating high-quality question-answer data by using large language model
CN116402166B (en) Training method and device of prediction model, electronic equipment and storage medium
CN112183102A (en) Named entity identification method based on attention mechanism and graph attention network
KR20220068462A (en) Method and apparatus for generating knowledge graph
Manandhar et al. Magic layouts: Structural prior for component detection in user interface designs
Vu et al. Revising FUNSD dataset for key-value detection in document images
RU2715024C1 (en) Method of trained recurrent neural network debugging
US10705810B2 (en) Automatic code generation
US20230023636A1 (en) Methods and systems for preparing unstructured data for statistical analysis using electronic characters

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination