Quality Assessment Methods for Microservice Refactoring and Decomposition of Monolithic Power Grid Applications

By using multi-channel program graph modeling and graph neural networks, combined with power grid topology and security domain constraints, the problems of multi-channel dependency analysis and cross-domain transaction processing in the process of microservice transformation of monolithic power grid business applications are solved. This achieves efficient and accurate microservice decomposition and quality assessment, and generates clear microservice boundaries.

CN121436813BActive Publication Date: 2026-03-13安徽明生恒卓科技有限公司 +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-31
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

Existing technologies lack multi-channel program dependency analysis, neglect cross-security domain transaction processing and data reconfiguration in the process of microserviceing monolithic applications of power grid business, and lack a unified quality assessment system, making it difficult to guarantee the quality of the split.

Method used

We employ multi-channel program graph modeling, graph representation learning, constraint clustering, cross-domain collaborative processing, and data configuration methods, combined with graph neural networks, to construct a multi-dimensional indicator system for quality assessment, ensuring the isolation of power grid topology and security domains and data consistency.

Benefits of technology

It has enabled intelligent and precise microservice decomposition of power grid business, significantly improving decomposition efficiency and quality, generating clear microservice boundaries, and ensuring system security and performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121436813B_ABST
    Figure CN121436813B_ABST
Patent Text Reader

Abstract

This invention relates to the fields of computer software engineering and power industry information technology, specifically a method for quality assessment of microservice-based refactoring and decomposition of monolithic power grid applications. The method includes the following steps: S1, multi-channel program graph modeling; S2, multi-channel graph representation learning; S3, constraint clustering; S4, cross-domain collaborative processing; S5, data configuration; and S6, quality assessment. This invention avoids the subjectivity and limitations of traditional methods that rely on human experience for rule definition. It transforms what might have taken weeks or even months of manual analysis and decomposition into an automated process, significantly shortening the refactoring cycle and providing more objective and accurate analysis results. Through a data-driven approach, it can discover dependency patterns that are difficult to detect with the human eye, thereby generating microservices with clearer boundaries and simpler responsibilities, laying a solid foundation for subsequent system maintenance and expansion.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of computer software engineering and power industry information technology, specifically to a method for quality assessment of microservice-based reconstruction and decomposition of monolithic power grid business applications. Background Technology

[0002] As the scale and complexity of power grid business systems increase, traditional monolithic application architectures face challenges such as maintenance difficulties, insufficient scalability, and high deployment risks. Microservice architecture, by breaking down monolithic applications into multiple loosely coupled services, can significantly improve system flexibility, scalability, and reliability. Therefore, information systems in the power industry are gradually considering migrating from monolithic architectures to microservice architectures to adapt to the evolving needs of smart grids. For example, in business areas such as grid dispatching, equipment management, and marketing, introducing microservices helps enable independent deployment and upgrades of functional modules, improving system fault tolerance and real-time response capabilities.

[0003] However, manually refactoring a mature monolithic power grid application into microservices is a complex and error-prone task. Existing technologies typically employ Domain-Driven Design (DDD), where architecture experts divide services based on business domain boundaries and code dependencies. However, manually analyzing the massive codebase of a monolithic application, its intricate dependencies, and the high level of knowledge required in the power business domain often results in lengthy, costly, and unreliable decomposition quality. Some studies have attempted to automatically suggest microservice partitioning schemes using static analysis, runtime log analysis, or clustering-based algorithms, but existing solutions often consider only single-perspective information, such as call relationships or business function partitioning, ignoring the multi-dimensional constraints unique to power grid applications. For example, the core control domain and business management domain are typically located in different security network isolation zones. Existing methods that fail to consider this may result in services coupled across security domains, leading to security vulnerabilities and performance bottlenecks. Furthermore, how to re-partition and synchronize data management—including master data and massive amounts of time-series data—after microservice decomposition is a pressing issue. Improper handling can lead to data inconsistency or duplicate storage.

[0004] Another shortcoming is the lack of an objective quality assessment system after microservice decomposition. Different microservice partitioning schemes may have significant differences in service granularity, cohesion, coupling, data consistency, and performance overhead. Currently, there is a lack of a comprehensive indicator system and scoring method to quantify the merits of microservice decomposition, which makes it difficult for architects to make decisions. Without quantitative evaluation, the effects of microservice refactoring are difficult to verify, and it is impossible to optimize the decomposition scheme in a targeted manner.

[0005] In summary, existing technologies for microservice-oriented monolithic applications for power grid services suffer from several drawbacks, including a lack of multi-channel program dependency analysis, neglect of cross-security domain transaction processing and data reconfiguration, and the absence of a unified quality assessment standard. There is an urgent need for an integrated approach to automatically complete the microservice-oriented reconstruction of monolithic applications and to assess the quality of the decomposition results, thereby improving reconstruction efficiency and the rationality of the microservice architecture. Summary of the Invention

[0006] To address the problems in existing technologies, this invention provides a method for quality assessment of microservice-based reconstruction and decomposition of monolithic power grid applications.

[0007] The technical solution adopted by this invention to solve its technical problem is: a quality assessment method for microservice-based reconstruction and decomposition of power grid business unit applications, including the following steps:

[0008] S1. Multi-channel program graph modeling: Perform structural modeling on the target power grid business unit application, and construct a multi-channel program dependency graph that includes a topology dependency graph and a current signal data access relationship graph. The topology dependency graph describes the program element dependency relationship of the topology association of power grid equipment, and the current signal data access relationship graph describes the data dependency relationship between program elements and the acquisition, transmission and processing of power grid current signals.

[0009] S2. Multi-channel graph representation learning: Perform representation learning on the multi-channel program dependency graph to obtain vectorized embedding representations of program elements in the topology dimension and current signal processing dimension;

[0010] S3. Constraint Clustering: The embedded representations of each channel are merged to generate a unified feature vector. Power grid topology partitioning constraints and security domain constraints are introduced for clustering to form candidate microservices.

[0011] S4. Cross-domain collaborative processing: For cross-domain transactions involving power grid topology operations and current signal processing, the control domain and business domain are coordinated to ensure data consistency.

[0012] S5. Data Configuration: Migrate the power grid topology master data based on the clustering results and clarify its ownership. Configure the subscription relationship of the current signal data stream to ensure that current information is obtained on demand.

[0013] S6. Quality Assessment: Based on a multi-dimensional index system that includes topology consistency and current data processing performance, the splitting results are quantitatively evaluated and a score is output.

[0014] The construction of the topology dependency graph in step S1 includes: extracting the set of program elements associated with the topology of power grid equipment, using program elements as nodes and the calling and referencing relationships of topology data as directed edges to form a directed topology dependency graph.

[0015] Preferably, the construction of the current signal data access relationship graph in step S1 includes: extracting program elements for accessing grid current sampling data, current state information, and current analysis results, and forming a current signal data dependency graph with program elements as nodes and current data read / write and sharing relationships as edges.

[0016] Preferably, the representation learning in step S2 employs a graph neural network or a graph embedding algorithm, wherein a topological dimension embedding vector is generated for the topological correlation features of the aggregated program elements in the topological structure dependency graph through graph convolution propagation, and a current signal dimension embedding vector is generated for the current data interaction features of the aggregated program elements in the current signal data access relationship graph.

[0017] Preferably, the power grid topology partitioning constraint in step S3 specifically means that program elements belonging to the same power grid topology partition are preferentially clustered into the same microservice, and it is prohibited to assign program elements related to core current signal processing in different topology partitions to the same microservice.

[0018] Preferably, the migration of the power grid topology master data in step S5 includes: classifying the power grid equipment topology structure data and topology association rule data according to the responsibilities of microservices, designating a single microservice as the authoritative management source of the topology master data, and having other microservices obtain topology data updates through interfaces.

[0019] Preferably, the subscription relationship of the current signal data stream in step S5 includes: dividing the power grid current signal into multiple topics according to the acquisition device, monitoring area or signal type, and each microservice subscribes to the corresponding topic according to business needs, and realizes real-time distribution of the current signal through message middleware.

[0020] Preferably, the cross-domain collaborative processing in step S4 adopts an event-driven, message queue mechanism or a Saga compensation mechanism;

[0021] When a transaction involves topology changes and current signal synchronization, if the topology operation succeeds but the current signal synchronization fails, a current data rollback or resynchronization operation is triggered.

[0022] Preferably, the topology consistency index in step S6 is defined as the ratio of the number of microservices that only cover a single power grid topology partition function to the total number of microservices, which is used to quantify the degree of conformity between the splitting result and the boundary of the power grid topology partition.

[0023] Preferably, step S5 further includes a current information integrity assurance step: during current signal data migration, the migration integrity is verified by checking the number of current sampling points and the continuity of current data timing.

[0024] After subscription reconfiguration, the current data volume of the publisher and subscriber should be compared periodically.

[0025] The beneficial effects of this invention are:

[0026] (1) This invention realizes a high degree of intelligence and precision in the decomposition of microservices for power grid business, which significantly improves the efficiency and quality of decomposition. By combining static code analysis and runtime data, a program graph model with multiple dimensions such as call relationships and data dependencies is constructed, which makes the deconstruction of monolithic applications far more comprehensive and in-depth than the traditional single-perspective analysis.

[0027] (2) By introducing advanced algorithms such as graph neural networks, the vector representation of program elements in high-dimensional space is automatically learned. This process can automatically discover and quantify the deep and non-linear dependencies between program elements, avoiding the subjectivity and limitations of traditional methods that rely on human experience to define rules. It transforms the manual analysis and decomposition work that may have taken weeks or even months into a set of automated processes, greatly shortening the reconstruction cycle and making the analysis results more objective and accurate.

[0028] (3) By using a data-driven approach, dependency patterns that are difficult for the human eye to detect can be discovered, thereby generating microservices with clearer boundaries and simpler responsibilities, laying a solid foundation for subsequent system maintenance and expansion. Attached Figure Description

[0029] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0030] Figure 1 The flowchart of the quality assessment method for microservice-based reconstruction and splitting of monolithic power grid applications provided by this invention is shown below.

[0031] Figure 2 This is a flowchart illustrating the operational logic of the automatic refactoring and evaluation method for microservice-based monolithic applications in this invention.

[0032] Figure 3 This is a schematic diagram of multi-channel program dependency graph modeling for the monolithic application of the present invention;

[0033] Figure 4 This is a schematic diagram of the system composition structure used to implement the method of this invention;

[0034] Figure 5 This is a schematic diagram of the microservice decomposition quality assessment index system and scoring process of the present invention. Detailed Implementation

[0035] To make the technical means, creative features, objectives and effects of this invention easier to understand, the invention will be further described below in conjunction with specific embodiments.

[0036] like Figure 2As shown, the method of this invention can be implemented in a pipeline manner, including data access and acquisition, multi-view modeling, boundary generation, automatic reconstruction, quality assessment, output and feedback, and supports iterative optimization based on scoring and constraints. The data access and acquisition layer is used to aggregate CIM master data and equipment ledgers, telemetry and telecontrol time-series data, work orders and power outage plans, scheduling and control instructions, city and voltage level information, as well as operation logs and call chains. The multi-view modeling module constructs a multi-channel program diagram based on the above data. Where V is the set of vertices, E is the set of edges, and X is the set of attributes, forming a channel set. and the adjacency matrix set corresponding to each channel. M represents the total number of channels, and m represents the channel number in the channel set C. The boundary generation module performs channel encoding, gated weighting, and residual fusion on the multi-channel graph, and performs clustering under constraints to obtain the microservice boundary partition P; it also allows external partitioning suggestions to be included. As prior information, it influences the boundary generation results. The automatic refactoring module, based on partition P, adapts and replaces contracts or protocols for monolithic applications, completes transaction slicing and compensation design, performs data ownership migration and data schema evolution, and generates engineering and deployment artifacts; this process can be combined with the reconfiguration of messaging and protocol infrastructure, as well as timing and alarm topics. The quality assessment module calculates a set of metrics. The system performs direction unification and normalization to form a comprehensive score Q, and supports self-learning of weights to obtain a set of weight parameters W. It also outputs sub-item evidence and diagnostic information. The output and feedback module generates a service codebase, migration scripts, protocol gateway and subscription configurations, deployment and observation configurations, and an evaluation report. When the comprehensive score Q falls below a threshold or violates feedback constraints... When the process returns to the boundary generation module, it continues to iterate; when the termination condition is met, the process ends.

[0037] Please see Figures 1-5 As shown, the present invention provides a method for quality assessment of microservice-based reconstruction and decomposition of monolithic power grid applications, comprising the following steps:

[0038] S1. Multi-channel program graph modeling: Perform structural modeling on the target power grid business unit application, and construct a multi-channel program dependency graph that includes a topology dependency graph and a current signal data access relationship graph. The topology dependency graph describes the program element dependency relationship of the topology association of power grid equipment, and the current signal data access relationship graph describes the data dependency relationship between program elements and the acquisition, transmission and processing of power grid current signals.

[0039] The program graph construction module is mainly responsible for static code analysis and runtime data collection of monolithic applications, and constructs a multi-channel program dependency graph. This module extracts entities such as classes, functions, and modules and their relationships from the source code library, and can obtain information such as call frequency and data flow by combining runtime logs or monitoring data, and outputs a multi-channel program graph model including call graphs and data dependency graphs.

[0040] Multi-perspective software architecture modeling is performed on the target monolithic application, constructing program dependency graphs across multiple channels. For example, different types of dependencies are extracted from source code and system runtime information, including call relationship graphs representing calls / call frequencies between classes or modules, data access relationship graphs representing dependencies on shared database tables or data entities, and other perspectives such as module dependency graphs or component communication graphs.

[0041] S2. Multi-channel graph representation learning: Perform representation learning on the multi-channel program dependency graph to obtain vectorized embedding representations of program elements in the topology dimension and current signal processing dimension.

[0042] The graph representation learning module receives multi-channel graph data generated by the program graph modeling module, and uses machine learning algorithms to learn the graph representation, generating node embedding vectors. This module can incorporate a graph neural network model or other graph embedding algorithms, training and optimizing them separately for each type of graph, so that nodes with similar functions are closer together in the vector space. The output is the embedding representation matrix of each program node in each channel.

[0043] Representation learning is performed on the above multi-channel program graph to obtain the vectorized embedding representation of program elements in each channel.

[0044] like Figure 3 As shown, the multi-channel graph is composed of a node feature matrix and various adjacency relationships. The node feature matrix is ​​denoted as... Where N is the number of nodes and d is the dimension of node features. Adjacency relationships can include static structural adjacencies. Co-occurrence adjacency Semantic or textual adjacency , grid topology or voltage level adjacency Geographic or administrative zone adjacency Timing or alarm propagation neighbor etc., all are uniformly recorded as For each channel m, a channel encoder is used. right Representation learning is performed to obtain channel embeddings. ,Right now:

[0045] ;

[0046] To integrate multi-channel information, a gating unit is introduced to weight the contribution of each node to each channel. The gating weight can be calculated according to... Calculate, W g b g These are the weight matrix and bias term of the gated unit, respectively. The activation function is used, and the channel embedding is modulated element-wise to obtain... Then the gated weighted sum is calculated. ; and the sum of all embedded channels Perform residual stacking to obtain the fused embedding:

[0047] ;

[0048] Based on the fusion embedding Z, the similarity between nodes is calculated and constrained clustering is performed. For example, the similarity can be:

[0049] ;

[0050] For scale parameters, Initial weights are assigned to nodes i and j, and during the clustering process, a must-cluster constraint (ML) and a no-cluster constraint (CL) are injected. The final output is the microservice boundary partition P, with external partition suggestions. It can be used as a soft or hard constraint injection to adjust the ML and CL constraint sets or affect cluster initialization, thereby achieving the fusion of prior and data-driven results.

[0051] S3. Constraint Clustering: The embedded representations of each channel are merged to generate a unified feature vector. Power grid topology partitioning constraints and security domain constraints are introduced for clustering to form candidate microservices.

[0052] The embedding fusion and clustering module is used to fuse the node embedding vectors from different channels to form a unified feature vector and perform clustering operations to generate microservice candidates. This module implements a constrained clustering algorithm, which can avoid illegal grouping or force specific elements to be combined together during the clustering process according to preset constraints (such as security domain labels). After the clustering is completed, the module outputs the preliminary microservice partitioning results, that is, the code element list corresponding to each service.

[0053] The node embedding representations from each channel are fused to generate a unified representation for microservice partitioning and clustering. Pre-defined constraints are applied during the clustering process. Specifically, for each node v, the embedding vectors from its different channels are merged, for example, using weighted fusion or connection fusion methods to construct a comprehensive embedding. One possible fusion formula is:

[0054] ;

[0055] in This is a coefficient that adjusts the importance of different channels (when there are more than two types of channels, it can be generalized to a weighted sum or concatenation of the embeddings of each channel followed by mapping through a fully connected layer). Then, the resulting node is comprehensively embedded. Cluster analysis is performed to group program elements with high similarity and close association into the same cluster. Each cluster corresponds to a candidate microservice, and each node is embedded in the data dependency channel. ,Will As the embedded representation of node v in the call relationship channel, it is denoted as .

[0056] S4. Cross-domain collaborative processing: For cross-domain transactions involving power grid topology operations and current signal processing, the control domain and business domain should collaborate to ensure data consistency. After the initial microservice partitioning is completed, the consistency issues of cross-service business logic and transactions in the original monolithic application need to be resolved.

[0057] In particular, in power system applications, some operational processes span the control domain and the business domain. For example, a fault handling process may include equipment isolation control domain operations and notification reporting business domain operations. In a monolithic system, this is usually completed by a single transaction, but when split, they belong to two separate services. If they are directly split, the following problems may occur: cross-domain calls are restricted by network isolation and cannot communicate directly, or the calls may be half successful and half unsuccessful, leading to data inconsistency. Therefore, this invention proposes a special transaction processing strategy to solve this problem. The core idea is to introduce reliable asynchronous communication between cross-domain operations to complete the overall transaction in a loosely coupled manner.

[0058] First, the transaction processing module scans and analyzes the function call graph or business process configuration of the original system to identify which processes involve multiple services. This can be done by analyzing transaction boundaries in the code, such as database transaction begin / commit blocks, or by identifying business function chains. For example, a "issue dispatch instruction" process first issues equipment operation instructions in the control system and then records the dispatch instructions in the business system. The transaction processing module determines that this process involves two microservices: "control instruction service" (belonging to the control domain) and "dispatch ticket service" (belonging to the business domain), which are cross-domain transactions.

[0059] For cross-microservice and especially cross-security domain business transactions during the refactoring process, corresponding processing mechanisms are designed to ensure transaction integrity and system consistency. In monolithic applications, some business processes may involve sequential control domain operations and business domain operations, such as executing power grid control commands first and then recording business logs. In a microservice architecture, such transactions are split into different services and security domains, requiring a loosely coupled coordination solution. This invention decomposes the original cross-domain transaction process into two parts: control domain sub-transactions and business domain sub-transactions. Coordination is achieved through event-driven or intermediate message queues: after the control domain microservice completes its operation, it generates an event message to notify the business domain microservice to continue subsequent operations.

[0060] For example, suppose the serial transaction operation sequence corresponding to a cross-domain business process in the original monolithic application is: Assume there is a serial transaction operation sequence in the original monolithic application as follows:

[0061] ;

[0062] in Let represent the k-th atomic operation. Indicates operation The security domain to which it belongs. If the process involves only one security domain switch in its execution sequence, then there exists a unique switch point i such that for all... have To control security domains, and for all have For business security domains, among which At this point, the original serial transaction can be divided into two sub-transactions, a control domain sub-transaction:

[0063] ;

[0064] And business domain sub-transactions:

[0065] ;

[0066] After a sub-transaction in the control domain is completed, the domain microservice publishes the domain event. The process is forwarded to the business domain via message broker to trigger the execution of business domain sub-transactions. When a business domain sub-transaction fails, a compensation action is triggered to roll back or correct previously completed partial results. In critical operation scenarios requiring strong consistency, a two-phase commit protocol can be used to achieve cross-domain atomicity. If there are multiple security domain switching in the sequence, the transaction is decomposed into multiple local sub-transactions for each consecutive security domain segment, and a multi-phase Saga compensation mechanism is used for orchestration and consistency assurance.

[0067] S5. Data Configuration: Migrate the power grid topology master data based on the clustering results and clarify its ownership. Configure the subscription relationship of the current signal data stream to ensure that current information is obtained on demand.

[0068] In the process of decomposing a monolithic application into a microservice architecture, the original data storage is divided and migrated, and the data publishing and subscription channels are reconfigured to ensure that each microservice can access the required data and that the data is consistent and reliable. First, the master data (such as static data like device ledgers and user information) and time-series data (such as real-time streaming data like sensor sampling and telemetry data) used by the monolithic application are classified and organized to form a data set D. Then, based on the microservice partitioning results, the data subset involved in each microservice is allocated to the corresponding service management: Let... For the master data set that microservice i is responsible for or needs, this invention will The data is migrated from the original database to independent data storage for each microservice, ensuring that each master data entity is owned and maintained by a single microservice as much as possible. For master data entities shared by multiple services, a master service is designated as the authoritative source, and other services that need the data obtain updates through interfaces or subscriptions, thus avoiding data inconsistencies caused by directly sharing the database. Next, for time-series data streams, a message queue or publish-subscribe mechanism is introduced to reconfigure the data: the set of all real-time data sources in the system is defined as S (e.g., measurement points and sensor data streams in a SCADA system), and the set of data streams subscribed to by each microservice is determined. Through message middleware, real-time data that was originally centrally processed by a monolithic application is published as topics, and relevant microservices subscribe to the corresponding topics to obtain data according to their own responsibilities.

[0069] For example, the monitoring microservice in the control domain subscribes to the topic of power grid telemetry, and the analysis microservice in the business domain subscribes to the topic of electricity consumption data statistics. Through this publish / subscribe reconfiguration, each microservice can still obtain the real-time data it needs in its own isolated operating environment. Furthermore, the producer-consumer decoupling improves the scalability and reliability of the system. During the data migration process, this invention also formulates a data synchronization strategy to ensure that historical data is correctly migrated and new data is distributed in real time when switching to a microservice architecture, avoiding data omission or duplication.

[0070] S6. Quality Assessment: Based on a multi-dimensional index system that includes topology consistency and current data processing performance, the splitting results are quantitatively evaluated and a score is output.

[0071] This invention establishes a quality evaluation index system for the results of microservice decomposition, quantifying the merits and demerits of the microservice architecture from multiple dimensions. The index system of this invention includes, but is not limited to, the following indicators:

[0072] Service cohesion metric: Measures the cohesion of the functions within each microservice. It can be defined as the tightness of the call relationships within a microservice. For example, it measures the degree of cohesion of the program node subset corresponding to the i-th microservice in the microservice partitioning result. Calculate its cohesion. ,in In order to be in The number of internal call edges, From The number of call edges pointing to the outside of the service. Then, the average cohesion of all microservices can be taken as the overall structural cohesion metric. The higher the cohesion, the stronger the functional correlation within the service after partitioning, and the clearer the functional boundaries.

[0073] Service decoupling metric: Measures the degree of loose coupling between microservices, complementing cohesion. It can be measured by the proportion of cross-service calls or dependencies, defined as the set of all cross-microservice call edges. If the total set of edges in the call graph is E (e.g., the total number of edges in the call graph), then a decoupling index can be defined. This is the supplementary value representing the proportion of cross-service calls. The closer a value is to 1, the more calls are encapsulated within the service, resulting in lower coupling between microservices. High decoupling helps reduce the complexity of dependencies between services, improves independent deployment, and enhances fault tolerance.

[0074] Domain consistency metric: measures the consistency between microservice partitioning and business domain and security domain boundaries. In order to meet the isolation between control domain and business domain, this invention requires that each microservice should cover the functions of only a single security domain as much as possible.

[0075] Data consistency and attribution metrics: These measure whether the data is clearly partitioned across microservices and whether there is duplication or sharing. The set of data entities in the system is defined as D, where... This represents a set of shared data entities accessed by multiple microservices. Define the data ownership metric. This indicates the proportion of data entities that exclusively own the data. This indicates that each piece of data has a clearly defined and unique service responsible for it, and there is no data sharing across services; lower A high value indicates that there is a lot of data that needs to be shared or synchronized between services. This metric reflects the coupling of microservices at the data level. The higher the metric, the more reasonable the data boundary division and the less data dependency between services.

[0076] Performance overhead metrics: These assess the increased communication and resource overhead that microservices may incur, such as the number of remote calls and network latency. A direct measure is the remote call ratio, i.e., the cross-service call edge mentioned earlier. Compared to the proportion of total calls or the average number of services involved in each business operation, a low remote call ratio means that most operations are completed within the service, resulting in low performance overhead. If operational monitoring data is obtained, metrics such as average response time between services and the number of round trips can be statistically analyzed to comprehensively evaluate the performance impact. This invention quantifies the performance changes brought about by microservices by comparing the performance of key business processes before and after refactoring in a test environment. Key performance indicators such as the increase rate of average response time can be incorporated into the evaluation system. In addition, the indicator system can also include service scale balance, the difference in code size and complexity of each microservice, maintainability indicators such as code modularity level, and the size of the impact of modifications. It can be expanded according to actual needs. The above indicators together form a comprehensive quality evaluation system, objectively characterizing the microservice decomposition scheme from aspects such as architectural structure, domain rationality, data management, and performance.

[0077] As a preferred technical solution, the construction of the topology dependency graph in step S1 includes: extracting the set of program elements associated with the topology of power grid equipment, using program elements as nodes and the calling and referencing relationships of topology data as directed edges to form a directed topology dependency graph.

[0078] Let V be the set of program elements in a monolithic application, and define a graph for each type of dependency. ,in This represents the set of edges between nodes under the p-th dependency relationship, for example, when calling a relation graph. In the context of class u calling a method of class v, then in Add directed edges to Data dependency graph In the context of class u accessing a database table or data object managed by class v, then in Add edge to middle Through the above methods, the present invention obtains a multi-channel program graph model that reflects different dependent channels of a single application.

[0079] As a preferred technical solution, the construction of the current signal data access relationship graph in step S1 includes: extracting program elements for accessing grid current sampling data, current state information, and current analysis results, and forming a current signal data dependency graph with program elements as nodes and current data read / write and sharing relationships as edges.

[0080] First, identify and extract a set of program elements directly related to the power grid equipment topology from the monolithic application. These elements may include, but are not limited to: functions that handle device connection relationships, database tables that store topology data, and configuration files that define the topology structure.

[0081] Analyze the interactions between these program elements. If element A calls or references element B to complete an operation related to topology data, a directed edge is established between node A and node B, pointing from A to B. Through the above process, a directed topology dependency graph is finally constructed that accurately reflects how programs organize and call topology data in power grid operations.

[0082] The comprehensive scoring function can be defined as a weighted sum of the various indicators:

[0083] ;

[0084] in This represents the evaluation value of the j-th quality indicator. For the corresponding weight coefficients, satisfying and (Weights can be normalized), by adjusting the weight vector. This can reflect the degree of importance attached to various quality attributes in different application scenarios. For example, in power grid control scenarios, more emphasis may be placed on security domain isolation and real-time performance, while in marketing business scenarios, more emphasis may be placed on data consistency and service decoupling. The weight learning method provided by this invention can automatically adjust W based on historical data or expert feedback. One implementation method is to use supervised machine learning: first, collect several microservice decomposition schemes and their manual evaluation scores as training samples, and denote the value of the j-th indicator on the n-th scheme as... The overall score is: The optimal weights are determined by minimizing the error between the predicted score and the expert score, for example, by using the least squares optimization objective.

[0085] ;

[0086] Solving the above optimization yields the weight parameters W that best approximate the expert scores. Another implementation involves using evolutionary algorithms or other optimization strategies to search for weights to maximize a specific overall objective. When training data is lacking, multi-indicator decision-making methods such as the Analytic Hierarchy Process (AHP) can be employed: domain experts are invited to compare indicators pairwise to determine their relative importance, thereby deriving the weights W. Through weight learning, this invention can adjust the scoring function to suit the preferences of different industry applications, making the overall scoring results more aligned with actual needs. Ultimately, the overall score... This score can be used to evaluate the merits of the current microservice partitioning scheme; a higher score indicates better partitioning quality. If the score is below the target, developers can adjust the microservice partitioning based on feedback from each sub-indicator and iteratively optimize the architecture design.

[0087] like Figure 4As shown, the quality assessment process includes indicator calculation, normalization, weighted scoring, constraint penalties, and result output. In the indicator calculation stage, raw indicator values ​​are obtained from dimensions such as service cohesion, service decoupling, domain consistency, data ownership, and performance and cost. The indicator directions are standardized to ensure that each indicator satisfies the semantics that a larger value indicates a better solution. In the normalization stage, indicators of different dimensions are scaled to ensure the comparability of the weighted synthesis. In the weighted scoring stage, a weight vector w is assigned to each indicator, and a weighted sum is calculated to obtain the comprehensive score Q. w can be updated through weight learning or a self-calibration mechanism, with weight updates based on the ranking learning results of historical solutions or expert feedback. To reflect strong constraints, constraint penalties are introduced in the scoring stage, deducting points for solutions that violate hard constraints, such as cross-domain write operation restrictions or failure to meet the lower bound of topology consistency. Finally, the comprehensive score Q, sub-indicator reports, and improvement suggestions R are output. These improvement suggestions can be used to drive the re-iteration of step S2 or step S3 to improve the microservice boundary.

[0088] like Figure 5 As shown, the method of this invention can be implemented collaboratively by a program graph modeling module, a graph representation learning module, an embedding fusion and clustering module, a transaction processing module, a message middleware, a data migration and subscription module, and a quality assessment module. The database provides historical data, master data, and time-series data, while the monolithic application codebase provides source code, runtime logs, and call chain information. The program graph modeling module extracts static call relationships and data access relationships from the code and data sides to construct a multi-channel program dependency graph. The graph representation learning module trains graph neural networks or graph embeddings on the multi-channel program graph, outputting the embedding matrix of each channel node. The embedding fusion and clustering module fuses the multi-channel embeddings and performs clustering under constraints such as security domain labels to form an initial microservice partitioning list. The transaction processing module identifies cross-service transactions based on the microservice partitioning, especially transactions across control domains and business domains, decomposes them into multiple local sub-transactions, and orchestrates them through an event-driven mechanism. In failure scenarios, a compensation mechanism is used to achieve eventual consistency; in critical scenarios requiring strong consistency, a two-phase commit protocol can be used. Cross-domain events and data distribution are forwarded through the message middleware. The data migration and subscription module completes the allocation and migration of master data ownership based on microservice boundaries, and reconfigures the publication and subscription relationships of time-series data by topic, while monitoring the health status of the subscription link. The quality assessment module calculates and weights the indicators such as cohesion, decoupling, domain consistency, data ownership, and performance based on the partitioning results and their operational performance. The assessment conclusions can be fed back to the embedding fusion and clustering module and the transaction processing and data configuration module for iterative optimization of the microservice partitioning and refactoring scheme.

[0089] As a preferred technical solution, the representation learning in step S2 adopts a graph neural network or a graph embedding algorithm, wherein a topological dimension embedding vector is generated for the topological correlation features of the aggregated program elements through graph convolution propagation for the topological structure dependency graph, and a current signal dimension embedding vector is generated for the current data interaction features of the aggregated program elements for the current signal data access relationship graph.

[0090] Node representations are trained on each dependency graph using either a graph neural network (GNN) or a graph embedding algorithm. Taking one of the dependency graphs... For example, construct its adjacency matrix. Size is ,in This indicates the existence of an edge from node u to node v, and multi-layer graph convolution propagation is performed to obtain node feature embeddings. The computation of graph convolution can be represented as:

[0091] ;

[0092] in, For the first Node feature matrix of the initial layer (This can be taken as the initial eigenvector of the identity matrix or the node). Let D be the adjacency matrix of the dependency graph, and D be the corresponding degree matrix. ), For the first The weight matrix of the layer, This is a non-linear activation function (such as ReLU). After several layers of propagation, the embedding vector representation of each node in this channel is obtained. Repeat the above process for each channel p, ultimately for each program node. Learn to obtain multiple sets of embedding representations The structural and semantic features of the node under different dependencies are encoded respectively.

[0093] In simple cases, a unit vector can be used (i.e., assigning a one-hot encoding to node v as the initial feature); alternatively, node attributes can be used as initial features, such as the number of lines of code in the class, the number of methods, the module ID, etc., which can then be normalized appropriately. Next, the node representations are iteratively updated according to the graph neural network propagation formula. The first layer of propagation calculation is as follows:

[0094] ;

[0095] in This represents the set of neighboring nodes of node v in the call relationship graph (e.g., the set of all nodes that call v or are called by v). The degree of node u (using a symmetric normalization factor) It can balance the influence of nodes of different degrees on v. It is the weight matrix of the first layer. The activation function (e.g., ReLU) at this layer means: gathering the information of the neighboring nodes of v and mapping it through a trainable matrix to obtain the first-order representation of v. Then, the second layer of propagation occurs:

[0096] ;

[0097] After two layers of propagation, the representation of each node already contains information about its surrounding neighbors, that is, it reflects, to some extent, the local structural patterns related to it in the call graph. This invention will... As the embedded representation of node v in the call relationship channel, it is denoted as Similarly, in data dependency graphs Train a GNN on top of that (using the same structure but with independent parameters) to obtain the embedding representation of each node in the data-dependent channels. ;

[0098] The above model can be built using existing deep learning frameworks such as TensorFlow or PyTorch, and stochastic gradient descent can be used to adjust the weights. Training is then performed. The training objective can be self-supervised, for example, to make topologically adjacent nodes closer in the embedding space. A common method is GraphSage or Node2Vec, which transform the graph structure into a sequence of nodes and train embeddings by sampling the node neighborhood through walkthroughs. This invention is not limited to a specific representation learning algorithm, as long as it can transform the graph structure into a node vector representation. In Example 1, this invention uses a graph convolutional network model and adopts the reconstruction loss between all node pairs as the training objective: that is, to embed the node into a reconstructed adjacency matrix such that the inner product of connected node vectors is larger, and that of unconnected nodes is smaller. After training convergence, two embedding matrices are obtained: one is the call relation embedding matrix. One is a data relationship embedding matrix. Each matrix has a dimension of 1. (d is the dimension of the embedding vector).

[0099] As a preferred technical solution, the power grid topology partitioning constraint in step S3 is specifically as follows: program elements belonging to the same power grid topology partition are preferentially clustered into the same microservice, and it is prohibited to assign program elements related to core current signal processing in different topology partitions to the same microservice.

[0100] Positive constraints: Set a hard or guiding rule that program elements belonging to the same power grid topology partition, such as the same substation or the same feeder area, should be given priority in being assigned to the same microservice during clustering. This reflects the principle of "business similarity".

[0101] Reverse constraint: A mandatory rule is set that prohibits assigning program elements responsible for core current signal processing, such as real-time protection and control algorithms, from different topology partitions to the same microservice. This reflects the principles of isolation and decoupling, especially for critical business operations.

[0102] Clustering algorithms can employ k-means, spectral clustering, or graph community detection-based methods. To ensure that the clustering results meet the security domain isolation requirements of power grid services, constraints are introduced during the clustering process: program elements belonging to different security domains are prohibited from being assigned to the same microservice. In other words, let the function... To determine the security domain (control security domain or business security domain) to which node v belongs, the following constraint must be satisfied: If If u and v cannot be assigned to the same cluster, then u and v cannot be grouped into the same cluster. Formalistically:

[0103] ,like ,but ,in This represents the clustering assignment function, returning the cluster identifier to which element x belongs. Through the above-described embedding fusion and constraint clustering steps, this invention obtains a preliminary microservice partitioning scheme. Each cluster represents a microservice candidate, including a group of classes or components that are highly related in terms of program dependencies and business semantics. The security domain constraints applied in this process ensure that the microservice partitioning complies with the network isolation requirements of the power grid control domain / business domain.

[0104] As a preferred technical solution, the migration of the power grid topology master data in step S5 includes: classifying the power grid equipment topology structure data and topology association rule data according to the responsibilities of microservices, designating a single microservice as the authoritative management source of the topology master data, and having other microservices obtain topology data updates through interfaces.

[0105] The power grid current signal is divided into multiple topics according to the acquisition equipment, monitoring area or signal type. Each microservice subscribes to the corresponding topic according to business needs, and the current signal is distributed in real time through message middleware.

[0106] Data ownership allocation: After the microservice boundaries are determined, core master data such as power grid equipment topology data and topology association rule data are clearly allocated to the corresponding microservices according to the core responsibilities of each microservice.

[0107] Establish an authoritative data source: For each type of topology master data, designate a unique microservice as its "authoritative management source." This microservice has exclusive authority to create, update, and delete the data.

[0108] Define the access interface: Other microservices that need to use this data are not allowed to directly access or modify the data storage of the authoritative source, but must obtain the data or request data updates by calling the standardized interface provided by the authoritative microservice.

[0109] A publish / subscribe (Pub / Sub) architecture is adopted. First, the massive amounts of power grid current signals generated throughout the system are categorized according to preset rules such as acquisition devices, monitoring areas, or signal types, with each category defined as a topic. Each microservice distributes the signal according to its own business needs. A message middleware is introduced as the core hub. When a current signal is generated, the data source publisher publishes the signal to the corresponding topic, and the message middleware is responsible for pushing the message in real time to all microservice subscribers who have subscribed to that topic.

[0110] As a preferred technical solution, the cross-domain collaborative processing in step S4 adopts an event-driven, message queue mechanism or a Saga compensation mechanism; when the transaction involves topology changes and current signal synchronization, if the topology operation is successful but the current signal synchronization fails, the current data rollback or resynchronization operation is triggered.

[0111] Technology selection: Three mainstream distributed transaction processing mechanisms were identified as suitable: event-driven architecture, message queues, and Saga compensation mechanism.

[0112] Detailed Explanation of the Saga Mechanism: This section focuses on explaining the application of the Saga compensation mechanism in this scenario. When a cross-domain transaction, such as "topology change current signal synchronization update," is decomposed into a series of local sub-transactions:

[0113] First, the first sub-transaction is executed. If the topology operation is successful, the second sub-transaction is executed. If the current signal synchronization fails, the Saga mechanism will trigger a compensation action, namely, the current data rollback or resynchronization operation, to undo or correct the previously completed operation, thereby restoring the entire system to a consistent state.

[0114] As a preferred technical solution, the topology consistency index in step S6 is defined as the ratio of the number of microservices that only cover a single power grid topology partition function to the total number of microservices, which is used to quantify the degree of conformity between the splitting result and the boundary of the power grid topology partition.

[0115] Define domain consistency metrics Percentage of microservices containing only single-domain functionality: Where k is the total number of microservices, The number of microservices belonging to only one security domain, for example, if all microservices are strictly divided by domain. A higher metric indicates that the microservice partitioning better meets the requirements of security domain isolation. Furthermore, if power grid services are categorized by functional domains such as dispatching, substations, and power consumption, a similar consistency metric can be defined to evaluate whether microservices align with business boundaries.

[0116] By calculating this ratio, we can quantitatively assess the degree to which the microservice decomposition results match the boundaries of the power grid topology partitions. The closer the ratio is to 1, the clearer the boundaries of the decomposed microservices in the topology dimension, and the more it conforms to the ideal model of "one microservice corresponding to one business domain".

[0117] As a preferred technical solution, step S5 also includes a current information integrity assurance step: when migrating current signal data, the migration integrity is verified by checking the number of current sampling points and the continuity of current data timing; after subscription reconfiguration, the current data volume of the publishing end and the subscription end is compared periodically.

[0118] Integrity verification during migration: During the migration of current signal data from a monolithic database to a microservice-specific data store, two verification methods are employed: Verifying the number of current sampling points: Comparing the total number of current sampling points for a specific dataset, such as a certain time period or a certain device, before and after the migration; Verifying the temporal continuity of current data: Checking whether the timestamp sequence of the data is continuous and whether there are any abnormal time jumps or missing data to ensure data integrity in the time dimension. Integrity comparison after subscription reconfiguration: After completing the data stream subscription relationship configuration, the system periodically executes a comparison task. This compares the total amount of data generated by the publisher (e.g., a topic in the message middleware) and the total amount of data received by the subscriber. Through consistency checks, it is ensured that no data is lost during distribution.

[0119] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of protection claimed by the present invention. The scope of protection of the present invention is defined by the appended claims and their equivalents.

Claims

1. A quality assessment method for microservice-based refactoring and decomposition of single-unit power grid business applications, characterized by: Includes the following steps: S1. Multi-channel program graph modeling: Perform structural modeling on the target power grid business unit application, and construct a multi-channel program dependency graph that includes a topology dependency graph and a current signal data access relationship graph. The topology dependency graph describes the program element dependency relationship of the topology association of power grid equipment, and the current signal data access relationship graph describes the data dependency relationship between program elements and the acquisition, transmission and processing of power grid current signals. S2. Multi-channel graph representation learning: Perform representation learning on the multi-channel program dependency graph to obtain the vectorized embedding representation of program elements in the topology dimension and the current signal processing dimension; S3. Constraint Clustering: The embedded representations of each channel are merged to generate a unified feature vector. Power grid topology partitioning constraints and security domain constraints are introduced for clustering to form candidate microservices. S4. Cross-domain collaborative processing: For cross-domain transactions involving power grid topology operations and current signal processing, the control domain and business domain are coordinated to ensure data consistency. S5. Data Configuration: Migrate the power grid topology master data based on the clustering results and clarify its ownership. Configure the subscription relationship of the current signal data stream to ensure that current information is obtained on demand. The migration of the power grid topology master data in step S5 includes: assigning power grid equipment topology structure data and topology association rule data to microservices according to their responsibilities, designating a single microservice as the authoritative management source of the topology master data, and having other microservices obtain topology data updates through interfaces; The subscription relationship of the current signal data stream in step S5 includes: dividing the power grid current signal into multiple topics according to the acquisition equipment, monitoring area or signal type, and each microservice subscribes to the corresponding topic according to business needs, and realizes real-time distribution of the current signal through message middleware; S6. Quality Assessment: Based on a multi-dimensional index system that includes topology consistency and current data processing performance, the splitting results are quantitatively evaluated and a score is output.

2. The method for quality assessment of microservice-based reconstruction and decomposition of monolithic power grid applications according to claim 1, characterized in that: The construction of the topology dependency graph in step S1 includes: extracting the set of program elements associated with the topology of power grid equipment, using program elements as nodes and the calling and referencing relationships of topology data as directed edges to form a directed topology dependency graph.

3. The method for quality assessment of microservice-based reconstruction and decomposition of monolithic power grid applications according to claim 1, characterized in that: The construction of the current signal data access relationship graph in step S1 includes: extracting program elements for accessing grid current sampling data, current state information, and current analysis results, and forming a current signal data dependency graph with program elements as nodes and current data read / write and sharing relationships as edges.

4. The method for quality assessment of microservice-based reconstruction and decomposition of single-unit applications for power grid business as described in claim 1 or 2, characterized in that: The representation learning described in step S2 employs a graph neural network or a graph embedding algorithm. Specifically, for the topological structure dependency graph, the topological association features of the aggregated program elements are used to generate a topological dimension embedding vector through graph convolution propagation. For the current signal data access relationship graph, the current data interaction features of the aggregated program elements are used to generate a current signal dimension embedding vector.

5. The method for quality assessment of microservice-based reconstruction and decomposition of monolithic power grid applications according to claim 4, characterized in that: The grid topology partitioning constraint mentioned in step S3 is as follows: program elements belonging to the same grid topology partition are preferentially clustered into the same microservice, and it is prohibited to assign program elements related to core current signal processing in different topology partitions to the same microservice.

6. The method for quality assessment of microservice-based reconstruction and decomposition of monolithic power grid applications according to claim 1 or 3, characterized in that: The cross-domain collaborative processing described in step S4 adopts an event-driven, message queue mechanism or a Saga compensation mechanism; When a transaction involves topology changes and current signal synchronization, if the topology operation succeeds but the current signal synchronization fails, a current data rollback or resynchronization operation is triggered.

7. The method for quality assessment of microservice-based reconstruction and decomposition of monolithic power grid applications according to claim 3, characterized in that: The topology consistency index mentioned in step S6 is defined as the ratio of the number of microservices that only cover the function of a single power grid topology partition to the total number of microservices, which is used to quantify the degree of conformity between the partitioning result and the boundary of the power grid topology partition.

8. The method for quality assessment of microservice-based reconstruction and decomposition of monolithic power grid applications according to claim 1 or 3, characterized in that: Step S5 also includes a current information integrity assurance step: during current signal data migration, the migration integrity is verified by checking the number of current sampling points and the continuity of current data timing. After subscription reconfiguration, the current data volume of the publisher and subscriber should be compared periodically.

Citation Information

Patent Citations

  • Three-dimension motion object detection method and system

    CN106780551A

  • Cloud native micro-service splitting and reconstructing method based on runtime behaviors

    CN121116381A