A method and system for real-time library expansion based on a distributed power monitoring system
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-13
- Publication Date
- 2026-08-14
AI Technical Summary
[0005]为解决现有技术中存在的不足,本发明提供一种基于分布式电力监控系统的实时库拓展方法,能够解决现有技术中分布式实时库获取批量数据时数据获取效率低下、扩展能力弱的技术问题
1、实现实时库水平扩展,突破容量与性能瓶颈。采用按厂站、按区域分片策略与分片算法,将数据分布式存储于多节点,解决传统集中式实时库存储上限、处理能力不足问题,支撑海量测点数据高效管理。
Smart Images

Figure CN122570601A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer monitoring technology, and more specifically, it provides a method and system for real-time library expansion in a distributed power monitoring system. Background Technology
[0002] In modern power systems, power monitoring systems play a crucial role, ensuring the safe, stable, and efficient operation of the power system. With the continuous expansion of power grids and the increasing automation and intelligence of the power industry, power monitoring systems need to process and analyze massive amounts of data in real time, placing extremely stringent demands on their data processing capabilities and real-time performance.
[0003] As a core component of the power monitoring system, the distributed real-time database is responsible for storing and managing various real-time data generated during power system operation, such as telemetry data (including values for voltage, current, and power) and remote signaling data (such as switch status and equipment alarm signals). This data forms the basis for the power monitoring system to perform functions such as real-time monitoring, fault diagnosis, load forecasting, and dispatch control.
[0004] However, there are a series of serious problems when acquiring batch data from distributed real-time libraries. On the one hand, data acquisition efficiency is low. The amount of data generated by the power system is huge and growing rapidly. Traditional data acquisition methods are inadequate for handling such large-scale data. On the other hand, horizontal scalability is weak. Traditional distributed real-time libraries download the entire data of a certain application to a single server node, resulting in a large consumption of server memory resources, which cannot be expanded indefinitely. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a real-time database expansion method based on a distributed power monitoring system, which can solve the technical problems of low data acquisition efficiency and weak scalability when the distributed real-time database acquires batch data in existing technologies.
[0006] The present invention adopts the following technical solution.
[0007] A method for expanding a real-time library based on a distributed power monitoring system includes the following steps; Step 1: Construct a real-time database sharding strategy, shard the power monitoring system measurement point data based on this strategy, and download the sharded data to the server's real-time database; Step 2: Parse the priority configuration information of each server in each shard, and select the server master node corresponding to each server in each shard based on the priority configuration information; Step 3: Construct a measurement point sharding information caching strategy, and cache sharded data according to the measurement point sharding information caching strategy; Step 4: Distribute the real-time data access request initiated by the client to each shard server master node, obtain the requested real-time data from each shard server master node, and return the obtained real-time data to the client after aggregation.
[0008] Preferably, step 1 specifically includes: Parse the data sharding configuration information of each server node to extract the sharded applications and sharding numbers of the real-time libraries installed on the server nodes; the data sharding configuration information includes the application name and sharding number, the application name is the application name supported by the distributed power monitoring system, and the sharding number is a positive integer greater than 0; Retrieve the information table from the relational database table and parse the content of the sharding mode field in the information table to extract the sharding mode value; Based on the real-time database sharding application installed on the server node, the database sharding number, and the table sharding mode value, construct a relational database table sharding data query statement, execute the constructed sharding data query statement on the relational database table, obtain the sharding data, and download it to the server's real-time database.
[0009] Preferably, in step 1, the sharding mode field content part_mode in the relational database table information table includes data type and identifier; The data type is an enumeration value. When the sharding mode value is 0, it means no sharding; when the sharding mode value is 1, it means sharding by plant / station; and when the sharding mode value is 2, it means sharding by region. When the segmentation mode value is 1, it is identified by the station_id field, and when the segmentation mode value is 2, it is identified by the region_id field.
[0010] Preferably, the construction of the relational database sharded data query statement specifically includes: Parse the configuration information of the power monitoring system to extract the number of power plants in each segment (stations_one_part) and the number of regions in each segment (regions_one_part); Calculate the shard number of the data recorded in the table based on the sharding pattern value, and construct the SQL_WHERE clause for the relational database sharding query; as follows: If the sharding mode value is equal to 0, the condition for the relational database sharding query will be empty, indicating no sharding; If the sharding mode value is equal to 1, then the conditions for sharded queries in the relational database are met: sql_where=“((station_id%100000) / stations_one_part+1)= node_partition_no” Where station_id%100000 represents the remainder when the value of the plant / station identifier field is divided by 100000; If the sharding mode value is equal to 2, then the conditions for relational database sharding queries are met: sql_where="((region_id%1000) / regions_one_part+1)= node_partition_no" Where node_partition_no is the partition number of the server, and region_id%1000 represents the remainder of the region identifier field value divided by 1000.
[0011] Preferably, in step 2, the master node of each shard server is selected based on priority configuration information, as follows: Calculate the actual order number (real_order) of each shard server node based on server node priority, server role, and node ID: real_oder = run_role*1000000+run_order*10000+node_id Where, run_role is the server node priority; run_order is the server role, which is 1 when the server role is a front-end server, 2 when the server role is a SCADA server, and 3 when the server role is an application server; node_id is the node ID; Sort all server nodes in each shard by their real_order number in ascending order. The first server node in each shard's sorting queue is the master node of the shard server, and the other server nodes are the backup nodes of the shard server.
[0012] Preferably, in step 3, the measurement point fragmentation information caching strategy specifically includes: Build a sharded real-time library cache table based on the sharding mode value: If the sharding mode value is equal to 0, the real-time library cache table corresponding to the original table will not be built; If the sharding mode value is equal to 1, then a real-time database cache table corresponding to the original table is constructed. The name of the real-time database cache table is appended with "_part" to the original table name. The fields of the original table include the primary key id, substation ID, and shard number partition_no. The first two fields of the original table are downloaded from the relational database. The value of partition_no is calculated based on the corresponding record station_id, and the calculation method is as follows: partition_no=(station_id%100000) / stations_one_part+1; Where stations_one_part represents the number of plants in each partition, and station_id is the plant identification field; If the sharding mode value is equal to 2, then a real-time database cache table corresponding to the original table is constructed. The name of the real-time database cache table is appended with "_part" to the original table name. The fields of the original table include the primary key id, substation, and shard number partition_no. The first two fields of the original table are downloaded from the relational database. The value of partition_no is calculated based on the corresponding record region_id, and the calculation method is as follows: partition_no=(region_id%1000) / regions_one_part+1.
[0013] Among them, regions_one_part represents the number of regions in each shard, and region_id represents the region identifier field.
[0014] Preferably, in step 4, the real-time data access request includes a measurement point tag key_id_tag, and the measurement point tag is parsed to obtain the table name, record ID, and column name corresponding to the measurement point tag key_id_tag; Real-time data access requests are broken down and combined with the contents of the local real-time database cache table, and then distributed to the master nodes of each shard server. Specifically, this includes: Classify table names and determine whether the corresponding table name (table_name) is sharded based on the sharding mode value; If not segmented, the key_id_tag for this measurement point will be retrieved from the local real-time database; If sharding has been performed, the value of partition_no is retrieved from the local real-time library cache table to obtain the shard number corresponding to the key_id_tag of the measurement point, and the real-time data access request corresponding to the key_id_tag of the measurement point is assigned to the corresponding shard server master node. All measurement point tags (key_id_tag) are processed, and all real-time database data obtained are aggregated in the order requested and returned to the client.
[0015] This invention also proposes a real-time library expansion system based on a distributed power monitoring system, used to implement the real-time library expansion method based on the distributed power monitoring system, comprising: The download module is used to build a real-time library sharding strategy. Based on this strategy, the power monitoring system measurement point data is sharded and the sharded data is downloaded to the server's real-time library. The node computing module is used to parse the priority configuration information of each server in each shard and select the server master node corresponding to each server in each shard based on the priority configuration information. The caching module is used to construct a caching strategy for measurement point shard information and to cache shard data according to the measurement point shard information caching strategy; The data access module is used to distribute real-time data access requests initiated by the client to the master nodes of each shard server, obtain the requested real-time data from each master node of the shard server, and return the obtained real-time data to the client after aggregation.
[0016] The present invention also proposes a terminal, including a processor and a storage medium; The storage medium is used to store instructions; The processor is used to operate according to the instructions to execute the steps of the real-time library expansion method based on the distributed power monitoring system.
[0017] The present invention also proposes a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the real-time library expansion method based on the distributed power monitoring system.
[0018] The beneficial effects of this invention are as follows: This invention uses a method of sharding the full data of a power monitoring application and loading multiple shards onto multiple server nodes, saving memory resources. In other words, as the data volume increases, the number of shards and servers can be increased to expand the real-time data volume, achieving horizontal scaling of the distributed real-time database. By distributing real-time data to different server nodes through real-time data sharding technology, load balancing for real-time data access is achieved. Real-time database sharding introduces complexity and performance issues for real-time database access. Therefore, this invention employs a real-time database proxy service and caching mechanism to effectively solve these problems.
[0019] The present invention has at least the following beneficial effects: 1. Achieve horizontal scaling of the real-time database, breaking through capacity and performance bottlenecks. By adopting a sharding strategy and algorithm based on plant and region, data is distributed and stored across multiple nodes, solving the problems of insufficient storage capacity and processing power of traditional centralized real-time databases, and supporting efficient management of massive measurement point data.
[0020] 2. This invention enables automatic calculation of primary and backup nodes, ensuring high system availability. It automatically determines the primary and backup nodes based on node roles, priorities, and node identifiers, eliminating the need for manual configuration. In the event of a failure, the backup node quickly takes over, ensuring uninterrupted data processing and alarm push notifications, thereby improving system reliability.
[0021] 3. Local caching of measurement point shard information improves access efficiency. A shard cache table is built and downloaded locally to achieve fast mapping of shard numbers, reduce duplicate queries and network overhead, and improve real-time data location and reading speed.
[0022] 4. Real-time database proxy load balancing enables transparent access. Requests are broken down, distributed, and aggregated through a proxy service, automatically routed to the corresponding master node, and data is acquired in parallel to balance access pressure. Clients do not need to be aware of data location, achieving transparent access, simplifying business logic, and improving overall access efficiency.
[0023] 5. Flexible configuration and easy deployment and maintenance. Supports multiple sharding modes, including no sharding, by plant / site, and by region. Parameters are configurable, and data download and primary / standby election are completed automatically, reducing system coupling and maintenance complexity, and offering strong versatility. Attached Figure Description
[0024] Figure 1 This is a schematic diagram of the real-time library expansion method based on a distributed power monitoring system in this invention. Figure 2 This is a schematic diagram of the process by which the client initiates a real-time data access request in this invention; Figure 3 This is a structural diagram of the real-time library expansion system based on the distributed power monitoring system in this invention; Figure 4 This is a detailed flowchart of one embodiment of the real-time library expansion method in this invention. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of this invention. The embodiments described in this application are merely some embodiments of this invention, and not all embodiments. Based on the spirit of this invention, other embodiments obtained by those skilled in the art without creative effort are all within the protection scope of this invention.
[0026] like Figure 1 As shown, this invention proposes a real-time database expansion method based on a distributed power monitoring system. This expansion method specifically includes a real-time database sharding strategy and algorithm, a sharding master / slave node calculation method, a measurement point sharding information caching strategy and its application, and the use of a real-time database proxy to achieve load balancing for real-time database access. The method includes the following steps: Step 1: Construct a real-time database sharding strategy, shard the power monitoring system measurement point data based on this strategy, and download the sharded data to the server's real-time database; Step 1 specifically includes the following steps: Step 1-1: Parse the data sharding configuration information of each server node and extract the sharding application and sharding number node_partition_no of the real-time library installed on the server node; The data sharding configuration information includes the application name and shard number. The application name is the application name supported by the distributed power monitoring system, and the shard number is a positive integer greater than 0. The data sharding configuration information consists of two parts connected by the symbol "@", namely the application name and the shard number. The application name is the application name supported by the distributed power monitoring system (such as scada), and the shard number is a positive integer greater than 0. The shard numbers are numbered sequentially according to the number of data shards. An example of sharding configuration information is "scada@1". Steps 1-2: Obtain the relational database table information table and parse the sharding mode field content in the relational database table information table to extract the sharding mode value; The sharding mode field in the relational database table information table includes the data type and identifier; The data type is an enumeration value. When the sharding mode value is 0, it means no sharding; when the sharding mode value is 1, it means sharding by plant / station; and when the sharding mode value is 2, it means sharding by region. When the segmentation mode value is 1, it is identified by the station_id field, and when the segmentation mode value is 2, it is identified by the region_id field.
[0027] Preferably, when dividing by plant and station, one section is set for every 200 plants and stations; when dividing by region, one section is set for every region.
[0028] Steps 1-3: Based on the real-time database sharding application installed on the server node, the database sharding number, and the table sharding mode value, construct a relational database table sharding data query statement, execute the constructed sharding data query statement on the relational database table, obtain the sharding data, and download it to the server's real-time database.
[0029] Specifically, the query statements for constructing relational database sharded data include: Parse the system configuration information to extract the number of stations in each segment (stations_one_part) and the number of regions in each segment (regions_one_part); Preferably, the number of stations in each segment is set to 200, and the number of regions in each segment is set to 1.
[0030] Furthermore, based on the sharding pattern value, calculate the sharding number of the recorded data in the table, and construct the condition SQL_WHERE clause for the relational database sharding query; specifically as follows: If the sharding mode value is equal to 0, the condition for the relational database sharding query will be empty, indicating no sharding; If the sharding mode value is equal to 1, then the conditions for sharded queries in the relational database are met: sql_where=“((station_id%100000) / stations_one_part+1)= node_partition_no” Where station_id%100000 represents the remainder when the value of the plant / station identifier field is divided by 100000; If the sharding mode value is equal to 2, then the conditions for relational database sharding queries are met: sql_where="((region_id%1000) / regions_one_part+1)= node_partition_no" Where node_partition_no is the partition number of the server, and region_id%1000 represents the remainder of the region identifier field value divided by 1000.
[0031] Preferably, the real-time database cache table can quickly locate the shard where the query point data is located, and indirectly locate the master node of the query data shard.
[0032] Step 2: Parse the priority configuration information of each server in each shard, and select the server master node corresponding to each server in each shard based on the priority configuration information; Specifically, the priority configuration information of each server node is parsed, the priority data run_order of each server node is extracted, and the master node of each shard is calculated based on the priority of all server nodes in each shard. The other server nodes in this shard are the backup nodes of the shard. Furthermore, the master node of each shard server is selected based on priority configuration information, as follows: Calculate the actual order number (real_order) of each shard server node based on server node priority, server role, and node ID (node_id): real_oder = run_role*1000000+run_order*10000+node_id Where, run_role is the server node priority; run_order is the server role, which is 1 when the server role is a front-end server, 2 when the server role is a SCADA server, and 3 when the server role is an application server; node_id is the node ID; Sort all server nodes in each shard by their real_order number in ascending order. The first server node in each shard's sorting queue is the master node of the shard server, and the other server nodes are the backup nodes of the shard server.
[0033] Step 3: Construct a measurement point sharding information caching strategy, and cache sharded data according to the measurement point sharding information caching strategy; The specific caching strategy for measurement point fragment information includes: Build a sharded real-time database cache table based on the sharding mode value: If the sharding mode value is equal to 0, then the real-time library cache table corresponding to the original table will not be built; If the sharding mode value is equal to 1, then a real-time database cache table corresponding to the original table is constructed. The name of the real-time database cache table is appended with "_part" to the original table name. The fields of the original table include the primary key id, substation ID, and shard number partition_no. The first two fields of the original table are downloaded from the relational database. The value of partition_no is calculated based on the corresponding record station_id, and the calculation method is as follows: partition_no=(station_id%100000) / stations_one_part+1; Among them, stations_one_part represents the number of plants in each segment, and station_id is the plant identification field; If the sharding mode value is equal to 2, then a real-time database cache table corresponding to the original table is constructed. The name of the real-time database cache table is appended with "_part" to the original table name. The fields of the original table include the primary key id, substation, and shard number partition_no. The first two fields of the original table are downloaded from the relational database. The value of partition_no is calculated based on the corresponding record region_id, and the calculation method is as follows: partition_no=(region_id%1000) / regions_one_part+1.
[0034] Among them, regions_one_part represents the number of regions in each shard, and region_id represents the region identifier field.
[0035] Step 4: Distribute the real-time data access request initiated by the client to each shard server master node, obtain the requested real-time data from each shard server master node, and return the obtained real-time data to the client after aggregation.
[0036] like Figure 2 As shown, the real-time data access request initiated by the real-time database client is received through the real-time database proxy service module. The client access request content is decomposed and combined with the local real-time database cache content. The client request is distributed to each shard server master node, and the requested real-time data is obtained from each shard server master node in parallel. The real-time data obtained from each shard master node is aggregated and returned to the client, thus realizing the load balancing of real-time data access. Specifically, the real-time data access request includes the measurement point tag `key_id_tag`. Parsing the measurement point tag yields the table name, record ID (primary key), and column name corresponding to that tag, connected by a "." symbol, such as "png_dig.1103000000001938801.value". Parsing each `key_id_tag` extracts the corresponding table name (`table_name`), record ID (`rec_id`), and column name (`col_name`). The real-time data access request is then broken down and combined with the local real-time database cache table content before being distributed to the master nodes of each shard server. This process includes: Classify the table name (table_name) and determine whether the corresponding table name (table_name) is sharded based on the sharding mode value; If not segmented, the key_id_tag for this measurement point will be retrieved from the local real-time database; If sharding has been performed, the value of partition_no is retrieved from the local real-time library cache table to obtain the shard number corresponding to the key_id_tag of the measurement point, and the real-time data access request corresponding to the key_id_tag of the measurement point is assigned to the corresponding shard server master node. All measurement point tags (key_id_tag) are processed, and all real-time database data obtained are aggregated in the order requested and returned to the client.
[0037] Real-time database clients (such as HMIs) request real-time data from the real-time database proxy service according to business needs, and complete business functions based on the returned real-time data. They do not need to know which server the real-time data is stored on, thus achieving transparent access to real-time data and improving access efficiency.
[0038] like Figure 3The method proposed in this invention will be described in conjunction with the following embodiments: Parse the data sharding configuration information of each server node to extract the real-time database sharding application and its number node_partition_no installed on the server node. The data sharding configuration information consists of two parts connected by the symbol "@", namely the application name and the shard number. The application name is the application name supported by the distributed power monitoring system (such as scada), and the shard number is a positive integer greater than 0, such as the sharding configuration information "scada@1". Parse the sharding mode field in the relational database table information to extract the sharding mode value. The sharding mode field name is part_mode, and the data type is an enumeration value. The enumeration content is: 0 - no sharding, 1 - sharding by plant / station (default is one shard for every 200 plants / stations), 2 - sharding by region (default is one shard for one region). If sharding is by plant / station, the table has a plant / station ID field station_id; if sharding is by region, the table has a region ID field region_id. Based on the server's sharding application, shard number, and table sharding mode value, construct a relational database sharding data query statement. Execute this query statement in the relational database to retrieve sharded data and download it to the local real-time database. Parse the system configuration information to extract the number of plants / stations per shard (stations_one_part, default 200) and the number of regions per shard (regions_one_part, default 1). Calculate the shard number of each table record based on the table sharding mode value, and construct the relational database sharding data query condition `sql_where` as follows: If part_mode equals 0, then sql_where will be empty; If part_mode equals 1, then: sql_where=“((station_id%100000) / stations_one_part+1)= node_partition_no” If part_mode equals 2, then: sql_where="((station_id%1000) / regions_one_part+1)= node_partition_no" Based on the table sharding mode value, construct a query statement for the content of the cached table in the relational database, execute this query statement in the relational database, retrieve the cached data, and download it to the local real-time database; the specific method is as follows: If part_mode equals 0, then the corresponding real-time library cache table will not be built; If part_mode equals 1, then the corresponding real-time database cache table will be created. The name of the real-time database cache table will be the original table name with the suffix "_part". This table consists of three fields: id (primary key), station_id, and partition_no. The first two fields of the table content are downloaded from the relational database. partition_no is calculated based on the station_id of the corresponding record, and the calculation method is as follows: partition_no=(station_id%100000) / stations_one_part+1; If part_mode equals 2, then the corresponding real-time database cache table will be created. The name of the real-time database cache table will have "_part" appended to the original table name. This table consists of three fields: id (primary key), region_id, and partition_no. The first two fields are downloaded from the relational database. partition_no is calculated based on the region_id of the corresponding record, as follows: partition_no=(region_id%1000) / regions_one_part+1; Parse the priority and role configuration information of each server node, extract the priority `run_role` for each server node, where `run_role` is an integer greater than or equal to 0, with smaller values indicating higher priority; based on the priority, role, and node ID (node_id) of all server nodes in each shard, calculate the master node for each shard server, with other server nodes serving as backup nodes; the method for calculating the master node of a shard server is as follows: real_oder = run_role*1000000+run_order*10000+node_id Where, run_role is the server node priority; run_order is the server role, which is 1 when the server role is a front-end server, 2 when the server role is a SCADA server, and 3 when the server role is an application server; node_id is the node ID; Sort all server nodes in each shard in ascending order of their actual sequence number real_oder. The first server node in each shard sorting queue is the shard master, and the other server nodes are shard backups. Each server node independently subscribes to and receives the data collected in its segment, processes the received data according to the specifications of the distributed power monitoring system, writes the processing results into the local segment real-time database, determines whether the server node is the master node of the segment server, and if so, submits the processed data to the time series library for storage and sends alarm information to the alarm service subsystem. The real-time database proxy service module receives real-time data access requests from real-time database clients. It breaks down the client's request content, combines it with local real-time database cache content, and distributes the client request to the master nodes of each shard server. It then retrieves the requested real-time data from each shard server master node in parallel, aggregates the data from each shard master node, and returns it to the client. The real-time database request content received by the proxy service is a `key_id_tag` array. Each `key_id_tag` consists of three parts: table name, record ID (primary key), and column name, connected by the symbol ".", such as "png_dig.1103000000001938801.value". It parses each `key_id_tag` and extracts the corresponding table name (t...). The system retrieves data from the following tables: `key_id_tag`, `rec_id`, and `col_name`. It categorizes `table_name` and determines whether it's sharded based on the sharding mode. If not sharded, the data corresponding to this `key_id_tag` is retrieved from the local real-time database. If `table_name` is sharded, the shard number `partition_no` is retrieved from the local real-time database cache table to obtain the shard number corresponding to the `key_id_tag`. The system then distributes the real-time data access request for this `key_id_tag` to the corresponding shard server master node. All `key_id_tag` data is processed, and all retrieved real-time database data is aggregated according to the request order and returned to the client.
[0039] Real-time database clients (such as HMIs) request real-time database data from the real-time database proxy service according to business needs, and complete business functions based on the returned real-time data. They do not need to know which server the required real-time data is stored on, thus achieving transparent access to real-time data and improving access efficiency.
[0040] like Figure 2 As shown, this invention also proposes a real-time library expansion system based on a distributed power monitoring system, used in the aforementioned real-time library expansion method based on a distributed power monitoring system. This system includes: The download module is used to build a real-time library sharding strategy. Based on this strategy, the power monitoring system measurement point data is sharded and the sharded data is downloaded to the server's real-time library. The node computing module is used to parse the priority configuration information of each server in each shard and select the server master node corresponding to each server in each shard based on the priority configuration information. The caching module is used to construct a caching strategy for measurement point shard information and to cache shard data according to the measurement point shard information caching strategy; The data access module is used to distribute real-time data access requests initiated by the client to the master nodes of each shard server, obtain the requested real-time data from each master node of the shard server, and return the obtained real-time data to the client after aggregation.
[0041] The beneficial effects of this invention are as follows: Compared with the prior art, the prior art downloads all the data of a certain application of the power monitoring system onto a single server, which consumes a lot of memory. The application master node provides data access services and responds to all data accesses of the application, resulting in low access efficiency. In contrast, this invention can download all the data in fragments to real-time databases on multiple servers and obtain real-time data from multiple servers in parallel, which effectively improves the efficiency of real-time data acquisition in the distributed power monitoring system. In addition, the method described can also horizontally scale the distributed real-time database, effectively enhancing the scalability, applicability and load balancing of the distributed power monitoring system.
[0042] This disclosure can be a system, method, and / or computer program product. A computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for causing a processor to implement various aspects of this disclosure.
[0043] Computer-readable storage media can be tangible devices capable of holding and storing instructions for use by an instruction execution device. Computer-readable storage media can be, for example—but not limited to—electrical storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital multifunction disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or recessed protrusions storing instructions thereon, and any suitable combination of the foregoing. The computer-readable storage media used herein are not to be construed as transient signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., light pulses through fiber optic cables), or electrical signals transmitted through wires.
[0044] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.
[0045] Computer program instructions used to perform the operations of this disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as the "C" language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing the status information of the computer-readable program instructions to implement various aspects of this disclosure.
[0046] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the protection scope of the claims of the present invention.
Claims
1. A real-time library expansion method based on a distributed power monitoring system, characterized in that, Includes the following steps; Step 1: Construct a real-time database sharding strategy, shard the power monitoring system measurement point data based on this strategy, and download the sharded data to the server's real-time database; Step 2: Parse the priority configuration information of each server in each shard, and select the server master node corresponding to each shard based on the priority configuration information; Step 3: Construct a measurement point sharding information caching strategy, and cache sharded data according to the measurement point sharding information caching strategy; Step 4: Distribute the real-time data access request initiated by the client to each shard server master node, obtain the requested real-time data from each shard server master node, and return the obtained real-time data to the client after aggregation.
2. The real-time library expansion method based on a distributed power monitoring system as described in claim 1, characterized in that: Step 1 specifically includes: Parse the data sharding configuration information of each server node to extract the sharded applications and sharding numbers of the real-time libraries installed on the server nodes; the data sharding configuration information includes the application name and sharding number, the application name is the application name supported by the distributed power monitoring system, and the sharding number is a positive integer greater than 0; Retrieve the information table from the relational database table and parse the content of the sharding mode field in the information table to extract the sharding mode value; Based on the real-time database sharding application installed on the server node, the database sharding number, and the table sharding mode value, construct a relational database table sharding data query statement, execute the constructed sharding data query statement on the relational database table, obtain the sharding data, and download it to the server's real-time database.
3. The real-time library expansion method based on a distributed power monitoring system as described in claim 2, characterized in that: In step 1, the sharding mode field content part_mode in the relational database table information table includes data type and identifier; The data type is an enumeration value. When the sharding mode value is 0, it means no sharding; when the sharding mode value is 1, it means sharding by plant / station; and when the sharding mode value is 2, it means sharding by region. When the segmentation mode value is 1, it is identified by the station_id field, and when the segmentation mode value is 2, it is identified by the region_id field.
4. The real-time library expansion method based on a distributed power monitoring system as described in claim 3, characterized in that: The specific steps of constructing relational database sharded data query statements include: Parse the configuration information of the power monitoring system to extract the number of power plants in each segment (stations_one_part) and the number of regions in each segment (regions_one_part); Calculate the shard number of the data recorded in the table based on the sharding pattern value, and construct the SQL_WHERE clause for the relational database sharding query; as follows: If the sharding mode value is equal to 0, the condition for the relational database sharding query will be empty, indicating no sharding; If the sharding mode value is equal to 1, then the conditions for sharded queries in the relational database are met: sql_where="((station_id%100000) / stations_one_part+1)= node_partition_no" Where station_id%100000 represents the remainder when the value of the plant / station identifier field is divided by 100000; If the sharding mode value is equal to 2, then the conditions for relational database sharding queries are met: sql_where="((region_id%1000) / regions_one_part+1)= node_partition_no" Where node_partition_no is the partition number of the server, and region_id%1000 represents the remainder of the region identifier field value divided by 1000.
5. The real-time library expansion method based on a distributed power monitoring system as described in claim 1, characterized in that: In step 2, the master node of each shard server is selected based on priority configuration information, as follows: Calculate the actual order number (real_order) of each shard server node based on server node priority, server role, and node ID: real_oder = run_role*1000000+run_order*10000+node_id Where, run_role is the server node priority; run_order is the server role, which is 1 when the server role is a front-end server, 2 when the server role is a SCADA server, and 3 when the server role is an application server; node_id is the node ID; Sort all server nodes in each shard by their real_order number in ascending order. The first server node in each shard's sorting queue is the master node of the shard server, and the other server nodes are the backup nodes of the shard server.
6. The real-time library expansion method based on a distributed power monitoring system as described in claim 2, characterized in that: In step 3, the specific caching strategy for measurement point fragment information includes: Build a sharded real-time library cache table based on the sharding mode value: If the sharding mode value is equal to 0, the real-time library cache table corresponding to the original table will not be built; If the sharding mode value is equal to 1, then a real-time database cache table corresponding to the original table is constructed. The name of the real-time database cache table is appended with "_part" to the original table name. The fields of the original table include the primary key id, substation ID, and shard number partition_no. The first two fields of the original table are downloaded from the relational database. The value of partition_no is calculated based on the corresponding record station_id, and the calculation method is as follows: partition_no=(station_id%100000) / stations_one_part+1; Among them, stations_one_part represents the number of plants in each segment, and station_id is the plant identification field; If the sharding mode value is equal to 2, then a real-time database cache table corresponding to the original table is constructed. The name of the real-time database cache table is the original table name with "_part" appended. The fields of the original table include the primary key id, substation, and shard number partition_no. The first two fields of the original table are downloaded from the relational database. The value of partition_no is calculated based on the corresponding record region_id, and the calculation method is as follows: partition_no=(region_id%1000) / regions_one_part+1. Among them, regions_one_part represents the number of regions in each shard, and region_id represents the region identifier field.
7. The real-time library expansion method based on a distributed power monitoring system as described in claim 6, characterized in that: In step 4, the real-time data access request includes the measurement point tag key_id_tag. Parsing the measurement point tag yields the table name, record ID, and column name corresponding to the measurement point tag key_id_tag. Real-time data access requests are broken down and combined with the contents of the local real-time database cache table, and then distributed to the master nodes of each shard server. Specifically, this includes: Classify table names and determine whether the corresponding table name (table_name) is sharded based on the sharding mode value; If not segmented, the key_id_tag for this measurement point will be retrieved from the local real-time database; If sharding has been performed, the value of partition_no is retrieved from the local real-time library cache table to obtain the shard number corresponding to the key_id_tag of the measurement point, and the real-time data access request corresponding to the key_id_tag of the measurement point is assigned to the corresponding shard server master node. All measurement point tags (key_id_tag) are processed, and all real-time database data obtained are aggregated in the order requested and returned to the client.
8. A real-time library expansion system based on a distributed power monitoring system, used to implement the real-time library expansion method based on a distributed power monitoring system as described in any one of claims 1-7, characterized in that, include: The download module is used to build a real-time library sharding strategy. Based on this strategy, the power monitoring system measurement point data is sharded and the sharded data is downloaded to the server's real-time library. The node computing module is used to parse the priority configuration information of each server in each shard and select the server master node corresponding to each server in each shard based on the priority configuration information. The caching module is used to construct a caching strategy for measurement point shard information and to cache shard data according to the measurement point shard information caching strategy; The data access module is used to distribute real-time data access requests initiated by the client to the master nodes of each shard server, obtain the requested real-time data from each master node of the shard server, and return the obtained real-time data to the client after aggregation.
9. A terminal, comprising a processor and a storage medium; characterized in that: The storage medium is used to store instructions; The processor is configured to operate according to the instructions to perform the steps of the method according to any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program implements the steps of the method according to any one of claims 1-7.