Communication method and device of distributed energy storage system and electronic equipment

By introducing an election mechanism and a log replication mechanism in the distributed energy storage system, the problems of high complexity, poor fault tolerance and low election efficiency in traditional methods are solved, and the consistency and high availability of the system are achieved.

CN119448578AInactive Publication Date: 2025-02-14GUANGZHOU RIMSEA TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510038764.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-10
Publication Date
2025-02-14
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In traditional distributed energy storage systems, the master-slave election methods have problems such as high complexity, poor fault tolerance and low election efficiency, making it difficult to achieve high consistency and high availability.

Method used

By introducing an election mechanism in a distributed energy storage system, the leader node and follower node are determined from the energy storage device nodes, and the consistency of the system is ensured through the log replication mechanism. The leader node responds to the master node's control information, adds it as a log entry to the local log, and copies it to all follower nodes.

Benefits of technology

The consistency and high real-timeness of each node in the distributed energy storage system are achieved, the system implementation process is simplified, the election efficiency is improved, and the problems of high complexity, poor fault tolerance and low election efficiency in traditional methods are solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119448578A_ABST
    Figure CN119448578A_ABST
Patent Text Reader

Abstract

The invention provides a communication method and device of a distributed energy storage system and electronic equipment, the communication method is applied to the distributed energy storage system, and the distributed energy storage system comprises a master control node and a plurality of energy storage equipment nodes; determining a leader node and a follower node from the plurality of energy storage equipment nodes based on an election mechanism; the leader node adds the control information as a log entry into a local log and copies the control information to all follower nodes, the leader node performs consistency check based on response information of the follower nodes, and if the consistency requirement is not met, the log entry is resent until the log entry is successfully copied to all the follower nodes; the energy storage device nodes as the leader node and the follower node operate synchronously based on the log entries, thereby ensuring that the system can still maintain consistency and high availability under various fault conditions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of energy storage technology, and in particular to a communication method, device and electronic equipment for a distributed energy storage system. Background Art

[0002] In modern photovoltaic and off-grid energy storage systems, multiple energy storage devices (such as battery packs, distributed photovoltaics, etc.) often need to work together to improve system reliability and efficiency. Efficient management and coordination are required between these devices to achieve data consistency, high availability, and scalability. However, traditional master-slave election methods face many challenges in achieving these goals.

[0003] First, although traditional consensus algorithms, such as the Paxos algorithm, can achieve high consistency and high availability in theory, their implementation process is complex and difficult to understand and deploy, especially when embedded chip computing resources are limited. This complexity increases the cost of system development and maintenance, making it difficult to be widely adopted in practical applications.

[0004] In addition, traditional methods may take a long time to elect the master and slave, affecting the real-time response capability and overall performance of the system. The inefficiency of the election process causes the system to take a long time to resume normal operation after the leader fails, which is unacceptable in energy storage systems with high real-time requirements. Summary of the invention

[0005] In view of this, the purpose of the present application is to provide a communication method, device and electronic equipment for a distributed energy storage system, which can ensure the consistency and high real-time performance of each energy storage device node in the energy storage system.

[0006] A communication method for a distributed energy storage system provided in an embodiment of the present application is applied to a distributed energy storage system, wherein the distributed energy storage system includes a master control node and a plurality of energy storage device nodes; the communication method includes: When the distributed energy storage system is started, a leader node is determined from multiple energy storage device nodes based on an election mechanism, and other energy storage device nodes serve as follower nodes; The leader node, in response to receiving the control information sent by the master node, adds the control information as a log entry to the local log of the leader node, and copies the log entry to all follower nodes; the control information is determined by the master node based on the status information of the device in the distributed energy storage system; The follower node generates response information based on the attribute information of the received log entry, and sends the response information to the leader node; the attribute information includes: the current term number of the node, the leader ID, the previous log entry index, the previous log entry term number, and the leader submission index; The leader node performs a consistency check based on the response information of the follower node. When the follower node does not meet the consistency requirement, the leader node resends the log entry until the log entry is successfully replicated to all follower nodes; The energy storage device nodes as leader nodes and follower nodes operate based on the log entries so that all energy storage device nodes operate synchronously according to the control information.

[0007] In some embodiments, in the communication method of the distributed energy storage system, when the distributed energy storage system is started, a leader node is determined from multiple energy storage device nodes based on an election mechanism, and other energy storage device nodes serve as follower nodes, including: When the distributed energy storage system is started, each energy storage device node reads the current term number, voting record and log entry of the node from the persistent storage and restores the last operating state; Each energy storage device node is initialized as a follower node, and the election timeout of the energy storage device node is set to a random value; If a follower node does not receive a heartbeat signal from the leader within the election timeout period, it will convert its state to a candidate node, vote for itself, and send a request-to-vote message to all other nodes; the request-to-vote message includes the node's current term number, candidate node ID, last log entry index, and last log entry term number; Other nodes determine whether the voting conditions are met based on the voting message. If so, other nodes vote for the candidate node. When the candidate node receives votes from more than half of the nodes, the candidate node is converted into a leader node, and the energy storage device nodes other than the leader are determined as follower nodes.

[0008] In some embodiments, in the communication method of the distributed energy storage system, if a follower node does not receive a heartbeat signal from the leader within the election timeout period, it converts its state to a candidate node, votes for itself, and sends a voting request message to all other nodes, including: When a follower node does not receive a heartbeat signal from the leader node within the election timeout period, it is converted to a candidate node and sends a pre-voting request message to all other nodes; the pre-voting request message includes the node's current term number, candidate node ID, last log entry index, and last log entry term number; After receiving the pre-voting request message, other nodes check whether the requester's log entry exceeds or is equal to their own log entry; If yes, the other nodes vote for the candidate node; If the pre-voting request message of the candidate node is supported by more than half of the nodes, the candidate node increases the current term number and formally initiates a request for voting, voting for itself and sending a request for voting message to all other nodes.

[0009] In some embodiments, in the communication method of the distributed energy storage system, the method further includes: When there are multiple candidate nodes in a round of elections and the votes of the multiple candidate nodes are the same, and none of them obtains more than half of the votes, the multiple candidate nodes do not become the leader node, and the multiple candidate nodes wait for their respective election timeouts to exceed and enter the next round of elections; or, The multiple candidate nodes receive the decision signal from the master control node and determine the leader node.

[0010] In some embodiments, in the communication method of the distributed energy storage system, the method further includes: the leader node performs a consistency check based on the response information of the follower node, and when the follower node does not meet the consistency requirement, the leader node resends the log entry until the log entry is successfully copied to all follower nodes, including: The response information of the follower node includes success response information and failure response information, and the failure response information includes the current log information of the follower node; when the leader node determines that the follower node does not meet the consistency requirement based on the failure response information, it sends at least one previous log entry for synchronization; Until the follower node receives a matching log entry, the leader node continues to send log entries after the matching log entry, so that the log entries of all follower nodes are consistent with the leader log entry.

[0011] In some embodiments, in the communication method of the distributed energy storage system, the method further includes: For the follower nodes to be synchronized that are disconnected from the leader node and have not synchronized log entries, when the follower nodes to be synchronized and the leader node are restored to be connected, based on the log synchronization mechanism, the log entries of all the follower nodes to be synchronized are updated to be consistent with the leader node; The follower nodes to be synchronized include energy storage device nodes outside a predetermined target network partition and faulty energy storage device nodes.

[0012] In some embodiments, in the communication method of the distributed energy storage system, the method further comprises: the leader node periodically generates a snapshot, saves the submitted log entries into the snapshot, and deletes the log entries; the snapshot includes the current state of the system and the submitted log entries; Based on the log synchronization mechanism, the log entries of all follower nodes to be synchronized are updated to be consistent with the leader node, including: When the difference between the term numbers of the log entry of the follower node to be synchronized and the log entry of the leader node is greater than a preset difference threshold, the leader node sends the snapshot to the follower node.

[0013] In some embodiments, in the communication method of the distributed energy storage system, when the target information is transmitted between the follower node and the leader node, the energy storage device node modulates the information into a communication carrier, and transmits the communication carrier corresponding to the information based on the power line between the energy storage device nodes; The target information includes log entries, request information and response information.

[0014] In some embodiments, a communication device of a distributed energy storage system is further provided, which is applied to a distributed energy storage system, wherein the distributed energy storage system includes a master control node and a plurality of energy storage device nodes; the communication device includes: A first determination module is used to determine a leader node from a plurality of energy storage device nodes based on an election mechanism when the distributed energy storage system is started, and other energy storage device nodes serve as follower nodes; A replication module, configured to enable the leader node to respond to receiving control information sent by the master control node, add the control information as a log entry to the local log of the leader node, and replicate the log entry to all follower nodes; the control information is determined by the master control node based on status information of the device in the distributed energy storage system; A generation module, configured to enable the follower node to generate response information based on the attribute information of the received log entry, and send the response information to the leader node; the attribute information includes: the current term number of the node, the leader ID, the previous log entry index, the previous log entry term number, and the leader submission index; A consistency check module, configured to enable the leader node to perform a consistency check based on the response information of the follower node, and when the follower node does not meet the consistency requirement, the leader node resends the log entry until the log entry is successfully replicated to all follower nodes; An operation module is used to enable the energy storage device nodes serving as the leader node and the follower node to operate based on the log entry, so that all the energy storage device nodes operate synchronously according to the control information.

[0015] In some embodiments, an electronic device is also provided, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the memory through the bus, and when the machine-readable instructions are executed by the processor, the steps of the communication method of the distributed energy storage system are executed.

[0016] In an embodiment of the present application, a communication method, device, electronic device and medium of a distributed energy storage system are provided. The communication method is applied to a distributed energy storage system, wherein the distributed energy storage system includes a master control node and multiple energy storage device nodes; when the distributed energy storage system is started, a leader node is determined from multiple energy storage device nodes based on an election mechanism, and other energy storage device nodes serve as follower nodes; the leader node adds the control information sent by the master control node as a log entry to the local log of the leader node, and copies the log entry to all follower nodes; the control information is determined by the master control node based on the status information of the device in the distributed energy storage system; the follower node generates response information based on the attribute information of the received log entry, and the leader node generates response information based on the response of the follower node The information is checked for consistency. When the follower node does not meet the consistency requirement, the leader node resends the log entry until the log entry is successfully copied to all follower nodes. The energy storage device nodes as leader nodes and follower nodes operate based on the log entry, so that all energy storage device nodes operate synchronously according to the control information, thereby decomposing complex consistency problems and splitting them into sub-problems such as leadership election, log replication and security assurance, so that the algorithm structure is clear, easy to understand and implement, so that the energy storage device system can significantly improve data consistency and high availability, simplify the system implementation process, improve election efficiency, solve the problems of high complexity, poor fault tolerance and low election efficiency in traditional methods, and ensure that the system can still maintain consistency and high availability under various fault conditions. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 A flow chart showing a communication method for a distributed energy storage system according to an embodiment of the present application is shown; Figure 2A flow chart of a method for determining a leader node from a plurality of energy storage device nodes based on an election mechanism and using other energy storage device nodes as follower nodes according to an embodiment of the present application is shown; Figure 3 A flowchart of a method in which a candidate node votes for itself and sends a voting request message to all other nodes according to an embodiment of the present application is shown; Figure 4 A flow chart showing another communication method of a distributed energy storage system according to an embodiment of the present application is shown; Figure 5 A schematic diagram showing the structure of a communication device for a distributed energy storage system according to an embodiment of the present application is shown; Figure 6 A schematic structural diagram of an electronic device described in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0019] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.

[0020] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0021] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.

[0022] In modern photovoltaic and off-grid energy storage systems, multiple energy storage devices (such as battery packs, distributed photovoltaics, etc.) often need to work together to improve system reliability and efficiency. Efficient management and coordination are required between these devices to achieve data consistency, high availability, and scalability. However, traditional master-slave election methods face many challenges in achieving these goals.

[0023] First, although traditional consensus algorithms, such as the Paxos algorithm, can achieve high consistency and high availability in theory, their implementation process is complex and difficult to understand and deploy, especially when embedded chip computing resources are limited. This complexity increases the cost of system development and maintenance, making it difficult to be widely adopted in practical applications.

[0024] In addition, traditional methods may take a long time to elect the master and slave, affecting the real-time response capability and overall performance of the system. The inefficiency of the election process causes the system to take a long time to resume normal operation after the leader fails, which is unacceptable in energy storage systems with high real-time requirements.

[0025] Based on this, in an embodiment of the present application, a communication method, device, electronic device and medium of a distributed energy storage system are provided, wherein the communication method is applied to a distributed energy storage system, wherein the distributed energy storage system comprises a master control node and multiple energy storage device nodes; when the distributed energy storage system is started, a leader node is determined from multiple energy storage device nodes based on an election mechanism, and other energy storage device nodes serve as follower nodes; the leader node adds the control information sent by the master control node as a log entry to the local log of the leader node, and copies the log entry to all follower nodes; the control information is determined by the master control node based on the status information of the device in the distributed energy storage system; the follower node generates response information based on the attribute information of the received log entry, and the leader node generates response information based on the attribute information of the follower node A consistency check is performed on the response information. When the follower node does not meet the consistency requirement, the leader node resends the log entry until the log entry is successfully copied to all follower nodes. The energy storage device nodes serving as the leader node and the follower node operate based on the log entry so that all the energy storage device nodes operate synchronously according to the control information, thereby decomposing the complex consistency problem into sub-problems such as leadership election, log replication, and security assurance, making the algorithm structure clear, easy to understand and implement, so that the energy storage device system can significantly improve data consistency and high availability, simplify the system implementation process, improve election efficiency, solve the problems of high complexity, poor fault tolerance, and low election efficiency in traditional methods, and ensure that the system can still maintain consistency and high availability under various fault conditions.

[0026] Please refer to Figure 1 , Figure 1 A flow chart of a communication method for a distributed energy storage system according to an embodiment of the present application is shown; the communication method for a distributed energy storage system is applied to a distributed energy storage system, wherein the distributed energy storage system includes a master control node and a plurality of energy storage device nodes; the communication method includes the following steps S101-S105: S101, when the distributed energy storage system is started, a leader node is determined from multiple energy storage device nodes based on an election mechanism, and other energy storage device nodes serve as follower nodes; S102, the leader node responds to receiving the control information sent by the master node, adds the control information as a log entry to the local log of the leader node, and copies the log entry to all follower nodes; the control information is determined by the master node based on the status information of the device in the distributed energy storage system; S103, the follower node generates response information based on the attribute information of the received log entry, and sends the response information to the leader node; the attribute information includes: the current term number of the node, the leader ID, the previous log entry index, the previous log entry term number, and the leader submission index; S104, the leader node performs a consistency check based on the response information of the follower node. When the follower node does not meet the consistency requirement, the leader node resends the log entry until the log entry is successfully copied to all follower nodes; S105. The energy storage device nodes serving as the leader node and the follower node operate based on the log entry, so that all the energy storage device nodes operate synchronously according to the control information.

[0027] Exemplarily, the energy storage device node may be a micro inverter node.

[0028] The energy storage device node includes the following modules: Central Processing Unit (CPU): responsible for executing the core logic of the Raft algorithm, including state management, election process, log replication and fault recovery; Storage module: used to store persistent data such as node logs, term numbers and election status; Communication module: responsible for network communication between nodes, processing RPC messages such as request votes (RequestVote) and append log entries (AppendEntries), not limited to Wi-Fi, LoRa, 4G, Bluetooth and other communication module interactions; Power management module: responsible for managing the charging and discharging operations of battery packs and distributed photovoltaics to ensure the normal operation of the system.

[0029] In step S101, when the distributed energy storage system is started, a leader node is determined from a plurality of energy storage device nodes based on an election mechanism, and other energy storage device nodes serve as follower nodes.

[0030] Please refer to Figure 2 When the distributed energy storage system is started, a leader node is determined from multiple energy storage device nodes based on an election mechanism, and other energy storage device nodes serve as follower nodes, including the following steps S201-S205: S201, when the distributed energy storage system is started, each energy storage device node reads the current term number, voting record and log entry of the node from the persistent storage, and restores the last operating state; S202, each energy storage device node is initialized to a follower node, and the election timeout of the energy storage device node is set to a random value; S203, if the follower node does not receive the heartbeat signal from the leader within the election timeout period, it converts its state to a candidate node, votes for itself, and sends a request-to-vote message to all other nodes; the request-to-vote message includes the node's current term number, candidate node ID, last log entry index, and last log entry term number; S204, other nodes determine whether voting conditions are met based on the voting message, and if so, other nodes vote for the candidate node; S205. When the candidate node receives votes from more than half of the nodes, the candidate node is converted into a leader node, and the energy storage device nodes other than the leader are determined as follower nodes.

[0031] In the embodiment of the present application, each energy storage device node can be in one of the following three states: Follower: Initial state: When a node starts, it enters the follower state by default; Responsibilities: Passively receive messages from leaders or candidates, and do not actively initiate communications; Timeout mechanism: When a follower does not receive a heartbeat signal from the leader within the election timeout, it will be converted to a candidate.

[0032] Candidate: Trigger condition: The follower does not receive a heartbeat signal within the election timeout period and is converted to a candidate; Responsibilities: Initiate elections and strive to become a leader by requesting voting messages; Election process: If a majority of votes are not won within the election timeout period, re-election will be initiated.

[0033] Leader: Trigger condition: The candidate obtains votes from more than half of the nodes in the election and becomes the leader; Responsibilities: Process client requests, append log entries, send heartbeat signals, and maintain system consistency and normal operation.

[0034] Energy device nodes can transition between different states, as follows: Follower to Candidate: Trigger: Election timeout; Action: Increase current term number, reset election timeout, vote for yourself, send request vote message to other nodes; Candidate to Leader: Trigger: Obtain votes from more than half of the nodes; Action: Start sending heartbeat signals, process client requests, and append log entries; Leader to Follower: Trigger: Receive a valid AppendEntries message or RequestVote message from the new leader, and the term number in the message is greater than the current term number; Action: Update the current term number and reset the state to follower.

[0035] Each energy storage device node maintains the following state variables: Node current term number (currentTerm): Description: An incremental number used to distinguish the terms of different leaders; Operation: Increase the term number when the election times out, and update the term number when receiving a message with a higher term number; votedFor: Description: Records the candidate IDs voted for during the current term; Operation: During each term, a node can only vote for one candidate; Log entries: Description: Stores all operation records. Each log entry includes a command and term number. Operation: The leader appends new log entries, and the follower updates the log according to the leader's AppendEntries message; Commit Index (commitIndex): Description: The highest index of the committed log entry; Operation: The leader updates the commit index based on the state of log replication, and the follower updates the commit index through the AppendEntries message; Last applied index (lastApplied): Description: Index of the last log entry applied to the state machine. Action: The node applies the committed log entry to the state machine and updates the last applied index.

[0036] When each node starts, it reads the current term number, voting records, and log entries from the persistent storage and restores the last running state. The initial state is Follower, and the election timeout is set to a random value to reduce the possibility of election conflicts.

[0037] Exemplarily, the state variable initialization process is as follows: currentTerm: Read the current term number from persistent storage.

[0038] votedFor: Reads the candidate IDs voted for in the current term from persistent storage.

[0039] log: Read all log entries from persistent storage.

[0040] commitIndex: Initialized to 0, indicating the highest index of the committed log entry.

[0041] astApplied: Initialized to 0, indicating the index of the log entry last applied to the state machine.

[0042] nextIndex: Only used by the leader node, records the index of the next log entry to be sent for each follower node, initialized to the index of the last entry in the leader log plus 1.

[0043] matchIndex: Only used by the leader node, the index of the highest replication log entry recorded for each follower node, initialized to 0.

[0044] The state variables are persistently stored. Specifically, each time currentTerm or votedFor is updated, it is persistently stored to disk to prevent data loss caused by node failure.

[0045] The log is persistently stored, and each time a new log entry is appended, it is persistently stored on disk to ensure the persistence and consistency of the log entry.

[0046] When the distributed energy storage device is started, the energy storage device nodes are initialized. Each node reads the persistent storage status information at startup, initializes the current term number, voting record and log, and sets the initial state of all nodes to followers.

[0047] If a follower node does not receive a heartbeat signal from the leader within the election timeout, it will be converted to a candidate. The candidate will initiate an election, increase the current term number of the node, reset the election timeout, vote for itself, and send a request to vote message.

[0048] The candidate counts the number of votes received. If it obtains votes from more than half of the nodes, it becomes the leader. The leader starts sending heartbeat signals, processing client requests, and appending log entries.

[0049] Here, the client request is control information sent by the master control node.

[0050] In the embodiment of the present application, the leader status and system stability are ensured through the heartbeat mechanism. The heartbeat signal is periodically sent by the current leader to all follower nodes to indicate that it is still alive and valid. The following are the details of the heartbeat mechanism: the leader node sends a heartbeat signal at a fixed time interval (called the heartbeat interval). The heartbeat interval is usually shorter than the election timeout. The heartbeat signal is sent via the AppendEntries RPC. Even if there are no new log entries to append, the leader will still send an empty AppendEntries message, which serves as a heartbeat. The heartbeat message includes the leader's term number, leader ID, the index and term number of the previous log entry, a list of log entries (empty), and the leader's submitted log index.

[0051] From the receiver's perspective, after receiving the heartbeat signal, the follower node first checks the current term number of the node in the message. If the current term number of the node is greater than or equal to the term number of the current node, the election timeout is reset and the follower state is maintained; if the term number in the heartbeat signal is greater than the term number of the current node, the follower node will update its own term number and reset the voting record.

[0052] The follower node also checks the log entry information in the heartbeat signal to ensure that its log is consistent with the leader. If it is inconsistent, the log is rolled back and rewritten.

[0053] Election trigger: When a follower node fails to receive the leader's heartbeat signal within the specified election timeout, it will consider the leader to be invalid, thus triggering the election process.

[0054] Here are the details of the election trigger.

[0055] The election timeout is the maximum time a follower node waits for a heartbeat signal. If no heartbeat signal is received within this time, the follower will be converted to a candidate.

[0056] In the embodiment of the present application, the election timeout is random: in order to prevent multiple nodes in the cluster from initiating elections at the same time, the election timeout is usually randomly selected within a range, which can reduce election conflicts and increase the probability of successful elections.

[0057] The trigger condition for the election is the lack of a heartbeat signal: if the follower node fails to receive the leader's heartbeat signal within the election timeout, an election is triggered.

[0058] After the election is triggered, the follower node changes its status to candidate and starts a new round of elections.

[0059] The specific process of a follower node converting to a candidate node, voting for itself, and sending a request vote message to all other nodes is as follows: the candidate node increases the current term number of the node (currentTerm += 1) and resets the election timeout; vote for itself. Specifically, the candidate node sets the voting record (votedFor) to its own ID and votes for itself; send a request vote message: the candidate node sends a request vote message (RequestVote RPC) message to all other nodes in the cluster.

[0060] The request vote message (RequestVote RPC), specifically, the request vote message includes the candidate's node current term number, the candidate ID, the candidate's last log entry index and the last log entry term number.

[0061] Last Log Entry Index (lastLogIndex): The index of the last entry in the candidate's log.

[0062] Last log entry term number (lastLogTerm): The term number of the last entry in the candidate log.

[0063] Other nodes determine whether the voting conditions are met based on the voting message. If so, other nodes vote for the candidate node.

[0064] Specifically, after receiving the voting request message, other nodes decide whether to vote for the candidate based on the following conditions: Term number check: If the term number in the voting request message is greater than the term number of the current node, the current node updates the term number and resets the voting record.

[0065] Log entry check: If the last log entry index and term number in the request vote message are greater than or equal to the corresponding values ​​of the current node, the current node votes for the candidate.

[0066] Voting response: The node that receives the request returns the voting result to the candidate through a response message.

[0067] That is to say: the node receiving the request checks the current term number and log entry of the requester's node. If the current term number of the requester's node is greater than the term number of the current node, and the log entry exceeds or equals the current node, the current node votes for the requester (candidate node).

[0068] The log entry exceeds or equals the current node, in other words, the log entry does not lag behind the current node.

[0069] The candidate node decides whether to become a leader based on the voting response results it receives.

[0070] Specific: Counting votes: The candidate node counts the number of votes received. If it receives votes from more than half of the nodes, it becomes the new leader.

[0071] Transition to leader: The candidate node is transformed into a leader and begins to perform the duties of a leader, including sending heartbeat signals and processing client requests.

[0072] Failure processing: If the candidate node fails to obtain a majority of votes within the election timeout period, it will re-enter the next round of elections; after waiting for a random period of time, the candidate node will re-increase the term number, reset the voting record, and send a request to vote message again.

[0073] After becoming a leader, the new leader node needs to perform a series of operations to ensure the consistency and high availability of the system, including: Send heartbeat signals: The leader node periodically sends heartbeat signals (AppendEntries RPC) to all follower nodes to maintain its leadership.

[0074] Processing client requests: The leader node receives and processes the client's operation request, adds it as a log entry to the local log, and replicates the log entry to all follower nodes via AppendEntries RPC.

[0075] Log consistency: The leader node ensures that the logs of all follower nodes are consistent with its own, and achieves data consistency through log replication and submission mechanisms.

[0076] Fault recovery: In the event of network partition or node failure, the leader node can quickly detect and recover, ensuring high availability of the system.

[0077] The leader election process is a key step in ensuring system consistency and high availability. The election process includes steps such as transitioning from a follower to a candidate, requesting votes, processing voting responses, and finally determining the leader.

[0078] Please refer to Figure 3 , the follower node does not receive the leader's heartbeat signal within the election timeout period, converts its state to a candidate node, and votes for itself, sending a request vote message to all other nodes, including the following steps S301-S304: S301. When a follower node does not receive a heartbeat signal from a leader node within the election timeout period, it is converted to a candidate node and sends a pre-voting request message to all other nodes; the pre-voting request message includes the current term number of the node, the candidate node ID, the last log entry index, and the last log entry term number; S302, after receiving the pre-voting request message, other nodes check whether the log entry of the requester exceeds or is equal to their own log entry; S303: If yes, the other nodes vote to support the candidate node; S304: If the pre-voting request message of the candidate node is supported by more than half of the nodes, the candidate node increases the current term number and formally initiates a request for voting, voting for itself and sending a request for voting message to all other nodes.

[0079] In the embodiment of the present application, a pre-voting mechanism is provided to solve the problem of increasing term.

[0080] When a node loses connection and fails to receive the leader's heartbeat signal, the node may continue to increase its own term and frequently initiate elections, causing system instability.

[0081] In the embodiment of the present application, a "pre-election" vote is conducted before the election is formally initiated to ensure that terms are added and the election is formally initiated only when there is indeed hope of winning the election, thereby reducing unnecessary term additions and elections.

[0082] Specifically, when a follower node does not receive a heartbeat signal from the leader within the election timeout period, it does not directly increase the current term number, but instead conducts a preliminary vote first.

[0083] The candidate node sends a PreVote request message (i.e., the pre-voting request message) to all other nodes, including the current term number, candidate ID, index of the last log entry, and term number.

[0084] After receiving the PreVote request, other nodes check whether the requester's log entry exceeds or is equal to their own log entry. If the conditions are met, they vote in favor of the PreVote request.

[0085] The candidate node counts the PreVote results: If the PreVote request is supported by more than half of the nodes, the node increases the current term number and formally initiates a RequestVote request.

[0086] The pre-voting request message structure is as follows: Term number: the term number of the current node; Candidate ID (candidateId): the ID of the current node; Last log entry index (lastLogIndex): the index of the last entry in the current node log; Last log entry term number (lastLogTerm): the term number of the last entry in the current node log; The candidate node processes the response to the pre-vote request message as follows: If the term number of the node in the PreVote response is greater than the term number of the current node, the current node updates its term number to a larger value and continues to act as a follower.

[0087] If the log entry in the PreVote response exceeds or equals the current node's log entry, then the PreVote request is voted for.

[0088] Reduce the frequency of term increases and elections: Specifically, through the PreVote mechanism, a node will increase its term number and formally initiate an election only when it is likely to be successfully elected as a leader, thereby reducing unnecessary term increases and election frequency and improving system stability.

[0089] In the embodiment of the present application, the communication method further includes: when there are multiple candidate nodes in a round of election and the votes of the multiple candidate nodes are the same, and none of them obtains more than half of the votes, the multiple candidate nodes do not become the leader node, and the multiple candidate nodes wait for their respective election timeouts to exceed and enter the next round of election; or, The multiple candidate nodes receive the decision signal from the master control node and determine the leader node.

[0090] Specifically, in some embodiments, if two candidates have the same number of votes in a round of elections, and neither of them has received more than half of the votes, then neither of the two candidates can become the leader. In this case, the entire cluster will wait for the election timeout to expire and enter the next round of elections.

[0091] Assume that candidate A and candidate B receive the same number of votes in a round of elections, and neither of them receives more than half of the votes. This round of elections is invalid, and no new leader is generated. All candidates will wait for the election timeout to end and enter the next round of elections.

[0092] In the next round of elections, Candidate A and Candidate B may still become leaders. Since the election timeout is randomly selected, the timeout for the next round of elections will be different, reducing the possibility of a tie again.

[0093] The multiple candidate nodes receive the decision signal of the master control node and determine the leader node. Specifically, when the votes of multiple candidate nodes are the same, the master control node receives the election results of the candidate nodes and determines a leader node based on a preset decision logic.

[0094] The preset decision logic includes determining the leader node according to target attributes (such as performance, load, etc.) of the candidate nodes, or determining the leader node based on a preset random algorithm.

[0095] After the leader node is determined, multiple candidate nodes receive the decision signal from the master node, which contains information about the leader node determined by the master node. After receiving the decision signal, the candidate node confirms the leader node according to the instructions in the decision signal. If a candidate node is selected as the leader, it begins to perform the duties of the leader. Candidate nodes that are not selected will continue to serve as candidate or follower nodes and need to participate in subsequent elections or collaborations.

[0096] In this way, the multiple candidate nodes receive the decision signal from the master control node and determine the leader node, thereby breaking the tie state in the election and ensuring that the distributed system can continue to operate normally.

[0097] In the step S102, the leader node responds to receiving the control information sent by the master node, adds the control information as a log entry to the local log of the leader node, and copies the log entry to all follower nodes; the control information is determined by the master node based on the status information of the device in the distributed energy storage system; Specifically, after the leader node receives the control information from the master node, it performs the following steps: Create a log entry: convert the control information into a new log entry, which contains the operation command and the current term number of the node, append the new log entry to the local log of the leader node, and assign a unique log index (logIndex) to the new log entry, which increases sequentially.

[0098] The leader node replicates the new log entry to all follower nodes via the AppendEntries RPC. The specific steps are as follows: Construct an AppendEntries message, which includes attribute information of the log entry, as follows: term number (term): the current term number of the leader; leader ID (leaderId): the node ID of the leader; previous log entry index (prevLogIndex): the index of the last log entry before the new log entry; previous log entry term number (prevLogTerm): the term number of the last log entry before the new log entry; log entries (entries[]): a list of new log entries; leader commit index (leaderCommit): the highest index of the log entry submitted by the leader.

[0099] The leader node sends the AppendEntries message to all follower nodes.

[0100] After receiving the AppendEntries message, the follower node checks the index and term number of the previous log entry; if they match, the new log entry is appended to the local log and a success response is returned; if the previous log entry does not match, the follower node returns a failure response and provides its current log information.

[0101] That is, the response information of the follower node includes success response information and failure response information, and the failure response information includes the current log information of the follower node.

[0102] In the step S104, the leader node performs a consistency check based on the response information of the follower node. When the follower node does not meet the consistency requirement, the leader node resends the log entry until the log entry is successfully copied to all follower nodes; The leader node adjusts the index and term number of the previous log entry in the AppendEntries message based on the response of the follower node and resends the message until the log entry is successfully copied to all follower nodes.

[0103] Log inconsistency refers to the log entries between the leader and the follower being out of sync or mismatched. Specifically, it means that the leader's log entries are inconsistent with the log entries of some follower nodes in terms of index or content.

[0104] The reasons for the log inconsistency are as follows: Network partition or delay: some follower nodes fail to receive the log entries sent by the leader in time, causing the log entries of these nodes to lag behind the leader's log; Node failure recovery: After failure recovery, the logs of some follower nodes may lag behind the current leader logs and need to be updated synchronously; Term changes: In a new round of elections, the new leader may find that the log entries of some follower nodes are inconsistent with its own and need to synchronize the logs.

[0105] The leader node ensures that the logs of all nodes are consistent by following these steps: After receiving the AppendEntries message, the follower node checks whether the index and term number of the previous log entry match; if they match, the new log entry is appended to the local log. If they do not match, the current log information is returned; the leader node detects and handles log conflicts based on the response of the follower node; by adjusting the index and term number of the previous log entry in the AppendEntries message, it ensures that the new log entry can be correctly appended to the log of the follower node.

[0106] Specifically, the leader node performs a consistency check based on the response information of the follower node. When the follower node does not meet the consistency requirement, the leader node resends the log entry until the log entry is successfully copied to all follower nodes, including: The response information of the follower node includes success response information and failure response information, and the failure response information includes the current log information of the follower node; when the leader node determines that the follower node does not meet the consistency requirement based on the failure response information, it sends at least one previous log entry for synchronization; Until the follower node receives a matching log entry, the leader node continues to send log entries after the matching log entry, so that the log entries of all follower nodes are consistent with the leader log entry.

[0107] When the new log entry is successfully replicated on the majority of nodes, the leader node performs the following steps to commit the log: Update commit index: The leader node marks the new log entry as committed and updates the commit index (commitIndex); Notify follower nodes; the leader node notifies all follower nodes of the new submission index through the AppendEntries message; After receiving the new commit index, the follower node updates the local commit index and applies the committed log entries to the state machine; Apply log entries: The leader node and follower nodes apply the submitted log entries to the local state machine and perform corresponding operations.

[0108] In the embodiment of the present application, a protection mechanism is provided for the submitted log entries. Specifically, once the log entry is submitted (i.e., successfully replicated on most nodes), it will not be overwritten or deleted. This mechanism ensures the consistency and persistence of data.

[0109] In the embodiment of the present application, the consistency of logs of different nodes and the communication security are guaranteed through term numbers, election restrictions and log consistency constraints. The term number is a continuously increasing number used to identify the term of the leader. Each term may have one leader or no leader (during the election process). Each node maintains a current term number (currentTerm), which increases in the following situations: when the node enters a new round of elections; when the node receives a message with a higher term number.

[0110] The functions of term numbers are as follows: Distinguishing leaders: The term number is used to distinguish leaders of different terms, ensuring that only one leader is valid in a term; Update mechanism: When a node receives a message with a higher term number, it updates its own term number and changes its status to follower; To ensure the security of leader election, in an election, a candidate must obtain votes from more than half of the nodes to become a leader, which ensures that the new leader can submit log entries on most nodes.

[0111] At the same time, a log consistency constraint mechanism is configured, and a candidate must have log entries that are at least as new or updated as the majority of nodes to win the election. This avoids electing a leader without the latest log, thereby protecting the consistency of the log.

[0112] When committing logs, the leader can only commit log entries received during the current term. Even if a log entry has been successfully replicated on the majority of nodes, the leader cannot commit it if it is an entry from a previous term.

[0113] Log application: Once a log entry is committed, the leader and follower nodes apply it to their local state machines, ensuring that the state machines of all nodes are consistent.

[0114] The node maintains a last applied index (lastApplied) to record the index of the last log entry applied to the state machine.

[0115] Matching index and next log entry index: The leader maintains the matching index (matchIndex) and next log entry index (nextIndex) of each follower to ensure the accuracy and effectiveness of log replication; through the matching index and next log entry index, the leader can accurately control the sending and confirmation of log entries to ensure the consistency of the log.

[0116] The log entry confirmation leader updates the matching index and the next log entry index based on the follower's response to ensure that the log entry is committed after being successfully replicated on most nodes; after receiving the AppendEntries message, the follower checks and confirms the log entry and returns a confirmation response.

[0117] Please refer to Figure 4 The communication method described in the embodiment of the present application further includes the following steps S401-S402: S401, for the follower nodes to be synchronized that are disconnected from the leader node and have not synchronized log entries, when the follower nodes to be synchronized and the leader node are restored to be connected, based on the log synchronization mechanism, the log entries of all the follower nodes to be synchronized are updated to be consistent with the leader node; S402. The follower nodes to be synchronized include energy storage device nodes outside a predetermined target network partition and faulty energy storage device nodes.

[0118] The predetermined target network partition is a target network partition determined from a plurality of pre-divided network partitions.

[0119] In the case of network partition, the communication method described in the embodiment of the present application ensures that a new leader is selected in the partition reachable by most nodes to continue processing client requests and log replication. When the network is restored, the status of all nodes is updated to the latest through the log synchronization mechanism to ensure global consistency.

[0120] In the event of a node failure, after the failed node recovers, it updates its state by receiving the latest log entries or snapshots from the leader node to ensure consistency with the leader.

[0121] The leader synchronizes the log status of the failed node to the latest one through AppendEntries messages or snapshots.

[0122] In the communication method described in the embodiment of the present application, the leader node periodically generates a snapshot, saves the submitted log entries into the snapshot, and deletes the log entries; the snapshot includes the current state of the system and the submitted log entries; Based on the log synchronization mechanism, the log entries of all follower nodes to be synchronized are updated to be consistent with the leader node, including: When the difference between the term numbers of the log entry of the follower node to be synchronized and the log entry of the leader node is greater than a preset difference threshold, the leader node sends the snapshot to the follower node.

[0123] A snapshot is a compressed representation of the system state, containing all committed log entries.

[0124] In the embodiment of the present application, in order to prevent the log from growing without limit, the system may generate snapshots periodically. After the snapshot is generated, the system may delete the log entries included in the snapshot to reduce the storage space.

[0125] If the log of a follower node is too far away from the leader's log, the leader will send a snapshot instead of synchronizing the logs one by one through AppendEntries messages.

[0126] After receiving the snapshot, the follower node resets the local state and log and restores the state from the snapshot.

[0127] In some embodiments, when the target information is transmitted between the follower node and the leader node, the energy storage device node modulates the information into a communication carrier, and transmits the communication carrier corresponding to the information based on the power line between the energy storage device nodes; The target information includes log entries, request information and response information.

[0128] Based on the same inventive concept, the embodiments of the present application also provide a communication device for a distributed energy storage system corresponding to the communication method of the distributed energy storage system. Since the principle of solving the problem by the device in the embodiments of the present application is similar to the communication method of the distributed energy storage system in the embodiments of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0129] Please refer to Figure 5 , Figure 5 A schematic diagram of the structure of a communication device of a distributed energy storage system according to an embodiment of the present application is shown; the communication device is applied to a distributed energy storage system, the distributed energy storage system includes a master control node and a plurality of energy storage device nodes; the communication device includes: A first determination module 501 is used to determine a leader node from a plurality of energy storage device nodes based on an election mechanism when the distributed energy storage system is started, and other energy storage device nodes serve as follower nodes; A replication module 502, configured to enable the leader node to respond to receiving control information sent by the master node, add the control information as a log entry to the local log of the leader node, and replicate the log entry to all follower nodes; the control information is determined by the master node based on the status information of the device in the distributed energy storage system; A generation module 503 is used to enable the follower node to generate response information based on the attribute information of the received log entry, and send the response information to the leader node; the attribute information includes: the current term number of the node, the leader ID, the previous log entry index, the previous log entry term number, and the leader submission index; A consistency check module 504, configured to enable the leader node to perform a consistency check based on the response information of the follower node, and when the follower node does not meet the consistency requirement, the leader node resends the log entry until the log entry is successfully replicated to all follower nodes; The operation module 505 is used to enable the energy storage device nodes serving as the leader node and the follower node to operate based on the log entry, so that all the energy storage device nodes operate synchronously according to the control information.

[0130] Based on the same inventive concept, the embodiments of the present application also provide a communication device for a distributed energy storage system corresponding to the communication method of the distributed energy storage system. Since the principle of solving the problem by the device in the embodiments of the present application is similar to the communication method of the distributed energy storage system in the embodiments of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0131] Please refer to Figure 6 , Figure 6 A schematic diagram of the structure of an electronic device described in an embodiment of the present application is shown, wherein the electronic device 600 comprises: a processor 602, a memory 601 and a bus, wherein the memory 601 stores machine-readable instructions executable by the processor 602, and when the electronic device 600 is running, the processor 602 communicates with the memory 601 via the bus, and when the machine-readable instructions are executed by the processor 602, the steps of the communication method of the distributed energy storage system are executed.

[0132] Based on the same inventive concept, the embodiments of the present application also provide a communication device for a distributed energy storage system corresponding to the communication method of the distributed energy storage system. Since the principle of solving the problem by the device in the embodiments of the present application is similar to the communication method of the distributed energy storage system in the embodiments of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0133] A computer-readable storage medium stores a computer program, which executes the steps of the communication method of the distributed energy storage system when executed by a processor.

[0134] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the method embodiment, and will not be repeated in this application. In the several embodiments provided in this application, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.

[0135] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0136] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0137] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a platform server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.

[0138] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A communication method for a distributed energy storage system, characterized in that: Applied to a distributed energy storage system, the distributed energy storage system includes a master control node and multiple energy storage device nodes; the communication method includes: When the distributed energy storage system is started, a leader node is determined from multiple energy storage device nodes based on an election mechanism, and other energy storage device nodes serve as follower nodes; The leader node, in response to receiving the control information sent by the master node, adds the control information as a log entry to the local log of the leader node, and copies the log entry to all follower nodes; the control information is determined by the master node based on the status information of the device in the distributed energy storage system; The follower node generates response information based on the attribute information of the received log entry, and sends the response information to the leader node; the attribute information includes: the current term number of the node, the leader ID, the previous log entry index, the previous log entry term number, and the leader submission index; The leader node performs a consistency check based on the response information of the follower node. When the follower node does not meet the consistency requirement, the leader node resends the log entry until the log entry is successfully replicated to all follower nodes; The energy storage device nodes as leader nodes and follower nodes operate based on the log entries so that all energy storage device nodes operate synchronously according to the control information.

2. The communication method of the distributed energy storage system according to claim 1, characterized in that: When the distributed energy storage system is started, a leader node is determined from multiple energy storage device nodes based on an election mechanism, and other energy storage device nodes serve as follower nodes, including: When the distributed energy storage system is started, each energy storage device node reads the current term number, voting record and log entry of the node from the persistent storage and restores the last operating state; Each energy storage device node is initialized as a follower node, and the election timeout of the energy storage device node is set to a random value; If a follower node does not receive a heartbeat signal from the leader within the election timeout period, it will convert its state to a candidate node, vote for itself, and send a request-to-vote message to all other nodes; the request-to-vote message includes the node's current term number, candidate node ID, last log entry index, and last log entry term number; Other nodes determine whether the voting conditions are met based on the voting message. If so, other nodes vote for the candidate node. When the candidate node receives votes from more than half of the nodes, the candidate node is converted into a leader node, and the energy storage device nodes other than the leader are determined as follower nodes.

3. The communication method of the distributed energy storage system according to claim 2, characterized in that: If a follower node does not receive a heartbeat signal from the leader within the election timeout, it will change its state to a candidate node, vote for itself, and send a request-vote message to all other nodes, including: When a follower node does not receive a heartbeat signal from the leader node within the election timeout period, it is converted to a candidate node and sends a pre-voting request message to all other nodes; the pre-voting request message includes the node's current term number, candidate node ID, last log entry index, and last log entry term number; After receiving the pre-voting request message, other nodes check whether the requester's log entry exceeds or is equal to their own log entry; If yes, the other nodes vote for the candidate node; If the pre-voting request message of the candidate node is supported by more than half of the nodes, the candidate node increases the current term number and formally initiates a request for voting, voting for itself and sending a request for voting message to all other nodes.

4. The communication method of the distributed energy storage system according to claim 2 or 3, characterized in that: The method further comprises: When there are multiple candidate nodes in a round of elections and the votes of the multiple candidate nodes are the same, and none of them obtains more than half of the votes, the multiple candidate nodes do not become the leader node, and the multiple candidate nodes wait for their respective election timeouts to exceed and enter the next round of elections; or, The multiple candidate nodes receive the decision signal from the master control node and determine the leader node.

5. The communication method of the distributed energy storage system according to claim 1, characterized in that: The method further includes: the leader node performs a consistency check based on the response information of the follower node, and when the follower node does not meet the consistency requirement, the leader node resends the log entry until the log entry is successfully copied to all follower nodes, including: The response information of the follower node includes success response information and failure response information, and the failure response information includes the current log information of the follower node; when the leader node determines that the follower node does not meet the consistency requirement based on the failure response information, it sends at least one previous log entry for synchronization; Until the follower node receives a matching log entry, the leader node continues to send log entries after the matching log entry, so that the log entries of all follower nodes are consistent with the leader log entry.

6. The communication method of the distributed energy storage system according to claim 1, characterized in that: The method further comprises: For the follower nodes to be synchronized that are disconnected from the leader node and have not synchronized log entries, when the follower nodes to be synchronized and the leader node are restored to be connected, based on the log synchronization mechanism, the log entries of all the follower nodes to be synchronized are updated to be consistent with the leader node; The follower nodes to be synchronized include energy storage device nodes outside a predetermined target network partition and faulty energy storage device nodes.

7. The communication method of the distributed energy storage system according to claim 6, characterized in that: The method further comprises: the leader node periodically generates a snapshot, saves the submitted log entries into the snapshot, and deletes the log entries; the snapshot includes the current state of the system and the submitted log entries; Based on the log synchronization mechanism, the log entries of all follower nodes to be synchronized are updated to be consistent with the leader node, including: When the difference between the term numbers of the log entry of the follower node to be synchronized and the log entry of the leader node is greater than a preset difference threshold, the leader node sends the snapshot to the follower node.

8. The communication method of the distributed energy storage system according to claim 1, characterized in that: When the target information is transmitted between the follower node and the leader node, the energy storage device node modulates the information into a communication carrier, and transmits the communication carrier corresponding to the information based on the power line between the energy storage device nodes; The target information includes log entries, request information and response information.

9. A communication device for a distributed energy storage system, characterized in that: Applied to a distributed energy storage system, the distributed energy storage system includes a master control node and multiple energy storage device nodes; the communication device includes: A first determination module is used to determine a leader node from a plurality of energy storage device nodes based on an election mechanism when the distributed energy storage system is started, and other energy storage device nodes serve as follower nodes; A replication module, configured to enable the leader node to respond to receiving control information sent by the master control node, add the control information as a log entry to the local log of the leader node, and replicate the log entry to all follower nodes; the control information is determined by the master control node based on status information of the device in the distributed energy storage system; A generation module, configured to enable the follower node to generate response information based on the attribute information of the received log entry, and send the response information to the leader node; the attribute information includes: the current term number of the node, the leader ID, the previous log entry index, the previous log entry term number, and the leader submission index; A consistency check module, configured to enable the leader node to perform a consistency check based on the response information of the follower node, and when the follower node does not meet the consistency requirement, the leader node resends the log entry until the log entry is successfully replicated to all follower nodes; An operation module is used to enable the energy storage device nodes serving as the leader node and the follower node to operate based on the log entry, so that all the energy storage device nodes operate synchronously according to the control information.

10. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the communication method for a distributed energy storage system as described in any one of claims 1 to 8 are performed.

Citation Information

Patent Citations

  • Consensus method based on node state information and distributed system

    CN115277718A

  • Code management method and device, storage medium and electronic equipment

    CN117193855A

  • Distributed storage method based on Raft algorithm and RDMA network

    CN119155307A

  • Method and apparatus for implementing data consistency, server, and terminal

    US20210320977A1