Data recovery method and device, electronic equipment and storage medium

By acquiring configuration information when the virtual gateway agent restarts, detecting and loading the availability of local cache files, and controlling the recovery strategy with static and dynamic configuration items, the poor startup performance and data consistency issues during virtual gateway agent restarts are resolved, achieving efficient and reliable data recovery.

CN122027477APending Publication Date: 2026-05-12BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
Filing Date
2026-03-06
Publication Date
2026-05-12

Smart Images

  • Figure CN122027477A_ABST
    Figure CN122027477A_ABST
Patent Text Reader

Abstract

The invention relates to a data recovery method and device, electronic equipment and a storage medium. The method comprises the steps of obtaining first configuration information when a process of a virtual gateway proxy is restarted, responding to the first configuration information to indicate that network configuration data is not synchronized from a remote server in a full-amount mode, detecting the availability of a local cache file, responding to the fact that the local cache file is determined to meet an available condition, and transmitting the network configuration data to the virtual gateway proxy. And loading the network configuration data in the local cache file. Compared with the prior art, according to the embodiment of the invention, when the process of the virtual gateway agent is restarted, the first configuration information is acquired, and under the condition that the first configuration information indicates incomplete synchronization, efficient local recovery is preferentially tried to solve the problem of slow starting, and meanwhile, through preposed availability detection and local loading recovery, the starting speed of the virtual gateway agent is improved. The starting performance of the virtual gateway agent can be improved, and the data consistency is ensured, so that the reliability is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of data recovery technology, and in particular to a data recovery method, apparatus, electronic device and storage medium. Background Technology

[0002] In a cloud computing virtual network environment, the virtual gateway agent, as a key component connecting the control plane and the data plane, needs to manage massive amounts of network resource configuration data, such as virtual private networks, virtual interfaces, and routing rules. To improve access performance, this data is typically stored as a primary copy on a remote server, and a cached copy is maintained in the virtual gateway agent's local memory.

[0003] When a virtual gateway agent process needs to restart due to upgrades, fault recovery, or configuration changes, a critical issue arises: how to quickly restore its locally cached data. Currently, traditional solutions have the following shortcomings: 1) Full synchronization from the remote server every time. After the agent restarts, the local state is completely discarded, and all data is pulled from the remote server again. This solution can ensure that the data is up-to-date, but the startup performance is extremely poor, especially in large-scale deployment environments, where the synchronization process may take tens of minutes, consuming a lot of network bandwidth and increasing server pressure.

[0004] 2) Relies entirely on local caching, forcing recovery from local storage. After the agent restarts, it unconditionally loads cached data from local disk files. This approach has a fast startup speed, but it carries serious risks: data may become outdated due to prolonged lack of synchronization; if local files are corrupted or format incompatible, it will cause the agent to fail to start or behave abnormally.

[0005] In summary, existing technical solutions suffer from poor startup performance, difficulty in guaranteeing data consistency, and inflexible recovery strategies for locally cached data. Summary of the Invention

[0006] To address the aforementioned technical problems, this disclosure provides a data recovery method, apparatus, electronic device, and storage medium.

[0007] In a first aspect, embodiments of this disclosure provide a data recovery method applied to a virtual gateway proxy, the method comprising: When the process of the virtual gateway agent restarts, it obtains first configuration information, which is used to indicate whether to fully synchronize network configuration data from the remote server. In response to the first configuration information indicating not to fully synchronize network configuration data from the remote server, the availability of the local cache file is checked; the local cache file is a persistent file located on the host machine where the virtual gateway proxy is located, used to store the network configuration data; In response to determining that the local cache file meets the availability conditions, network configuration data in the local cache file is loaded; Alternatively, in response to the first configuration information instruction to perform a full synchronization, the network configuration data is fully synchronized from the remote server.

[0008] In some embodiments, obtaining the first configuration information includes: Get the first configuration item in the local configuration file. The first configuration item is used to statically configure whether to enable full synchronization. If the first configuration item indicates that full synchronization is not enabled, then the second configuration item in the local cache file is queried through the remote procedure call interface. The second configuration item is used to dynamically configure whether full synchronization is enabled. Before synchronizing the network configuration data in full from the remote server, the method further includes: If either the first configuration item or the second configuration item indicates that full synchronization is enabled, then it is determined that the first configuration information indicates that network configuration data is fully synchronized from the remote server.

[0009] In some embodiments, detecting the availability of local cache files includes: Check if the storage path of the local cache file exists; If the storage path exists, check whether the current process of the virtual gateway proxy has permission to read the local cache file; If the current process has read permission, it reads the local cache file based on the storage path and obtains a read result, which is used to indicate whether the local cache file exists. In response to the read result indicating the existence of the local cache file, it is determined that the local cache file meets the availability condition.

[0010] In some embodiments, loading the network configuration data from the local cache file includes: Open the local cache file in binary read mode; Read the file content of the local cache file and parse the file content into a preset structured data format; If the parsing is successful, the parsed data in the preset structured data format will be loaded as network configuration data into the runtime memory of the virtual gateway proxy. If an exception occurs during the opening, reading, or parsing process, it is determined that the network configuration data failed to load, and an error log is recorded.

[0011] In some embodiments, the method further includes: In response to determining that the local cache file does not meet the availability conditions, or in the event that the network configuration data fails to load, a degradation process is performed to trigger a full synchronization of the network configuration data from the remote server.

[0012] In some embodiments, the method further includes: In response to an update event of the network configuration data managed by the virtual gateway proxy, the updated network configuration data is serialized into data in a preset structured data format; The data in the preset structured data format is saved to the local cache file through an atomic write operation to update the local cache file; Create a timestamped copy of the local cache file and save the copy as a historical backup file.

[0013] In some embodiments, performing the degradation process includes: Returns a predefined empty cache data structure that indicates the operation of performing a full data synchronization. The empty cache data structure has the same top-level structure as the non-empty cache data and contains fields associated with the cached content, which are initialized to null values. Based on the empty cache data structure, all data in the remote server is fully synchronized to the running memory of the virtual gateway proxy to complete the recovery of the network configuration data.

[0014] Secondly, embodiments of this disclosure provide a data recovery apparatus applied to a virtual gateway proxy, the apparatus comprising: The acquisition module is used to acquire first configuration information when the process of the virtual gateway agent is restarted. The first configuration information is used to indicate whether to fully synchronize network configuration data from a remote server. The detection module is used to detect the availability of a local cache file in response to the first configuration information indicating that network configuration data should not be fully synchronized from the remote server; the local cache file is a persistent file located on the host machine where the virtual gateway proxy is located, used to store the network configuration data; The recovery module is configured to load network configuration data from the local cache file in response to determining that the local cache file meets the availability conditions; or, in response to the first configuration information indicating full synchronization, trigger a full synchronization of network configuration data from the remote server.

[0015] Thirdly, embodiments of this disclosure provide an electronic device, including: Memory; Processor; and Computer programs; The computer program is stored in memory and configured to be executed by a processor to implement the method as described in the first aspect.

[0016] Fourthly, embodiments of this disclosure provide a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the method as described in the first aspect.

[0017] Fifthly, embodiments of this disclosure also provide a computer program product comprising a computer program or instructions that, when executed by a processor, implement the method as described in the first aspect.

[0018] The data recovery method, apparatus, electronic device, and storage medium provided in this disclosure acquire first configuration information when the virtual gateway agent process restarts. This first configuration information indicates whether to fully synchronize network configuration data from a remote server. In response to the first configuration information indicating no full synchronization of network configuration data from the remote server, the availability of a local cache file is detected. In response to determining that the local cache file meets the availability condition, the network configuration data in the local cache file is loaded. Alternatively, in response to the first configuration information indicating full synchronization, a full synchronization of network configuration data from the remote server is triggered. Compared to existing technologies, this disclosure, by acquiring the first configuration information when the virtual gateway agent process restarts, prioritizes efficient local recovery to address the slow startup issue when the first configuration information indicates no full synchronization. Simultaneously, through pre-emptive availability detection and local loading recovery, the startup performance of the virtual gateway agent can be improved, data consistency can be guaranteed, and thus reliability can be ensured. Attached Figure Description

[0019] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0020] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 A flowchart of a data recovery method provided in this embodiment of the disclosure; Figure 2 A flowchart of a data recovery method provided in another embodiment of this disclosure; Figure 3 A flowchart of a data recovery method provided in another embodiment of this disclosure; Figure 4 This is a schematic diagram of the structure of the data recovery device provided in the embodiments of this disclosure; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0022] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.

[0023] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.

[0024] In a cloud computing virtual network environment, the virtual gateway agent, as a key component connecting the control plane and the data plane, needs to manage massive amounts of network resource configuration data, such as virtual private networks, virtual interfaces, and routing rules. To improve access performance, this data is typically stored as a primary copy on a remote server, and a cached copy is maintained in the virtual gateway agent's local memory.

[0025] When a virtual gateway agent process needs to restart due to upgrades, fault recovery, or configuration changes, a critical issue arises: how to quickly restore its locally cached data. Currently, traditional solutions have the following shortcomings: 1) Full synchronization from the remote server every time. After the agent restarts, the local state is completely discarded, and all data is pulled from the remote server again. This solution can ensure that the data is up-to-date, but the startup performance is extremely poor, especially in large-scale deployment environments, where the synchronization process may take tens of minutes, consuming a lot of network bandwidth and increasing server pressure.

[0026] 2) Relies entirely on local caching, forcing recovery from local storage. After the agent restarts, it unconditionally loads cached data from local disk files. This approach has a fast startup speed, but it carries serious risks: data may become outdated due to prolonged lack of synchronization; if local files are corrupted or format incompatible, it will cause the agent to fail to start or behave abnormally.

[0027] In summary, existing technical solutions suffer from poor startup performance, difficulty in guaranteeing data consistency, and inflexible recovery strategies for locally cached data.

[0028] To address this problem, this disclosure provides a data recovery method, which will be described below with reference to specific embodiments.

[0029] Figure 1This is a flowchart illustrating a data recovery method provided in an embodiment of this disclosure. The method is executed by an electronic device, which can be a portable mobile device such as a smartphone, tablet, laptop, in-vehicle navigation device, or smart sports equipment; or a fixed device such as a personal computer, smart home appliance, or server. The server can be a single server, a server cluster, a distributed cluster, or a centralized cluster. This method can be applied to scenarios involving data recovery.

[0030] It is understood that the data recovery method provided in this disclosure can also be applied in other scenarios.

[0031] The following is about Figure 1 The data recovery method shown is described below. This method can be applied to electronic devices, specifically virtual gateway proxies. The specific steps included in this method are as follows: S101. When the process of the virtual gateway agent is restarted, first configuration information is obtained, which is used to indicate whether to fully synchronize network configuration data from the remote server.

[0032] In this step, when the virtual gateway agent's process restarts, it obtains first configuration information. This first configuration information indicates whether to fully synchronize network configuration data from a remote server. This first configuration information is the master switch that determines the logical flow of the recovery strategy. It indicates whether it is necessary to bypass all local recovery attempts and directly perform full data synchronization from the remote server. Its acquisition logic is the starting point of the intelligent recovery strategy. If the first configuration information indicates that full synchronization is not required, step S102 is executed. In some embodiments, if the first configuration information indicates that full synchronization is required, remote synchronization is triggered.

[0033] S102. In response to the first configuration information indicating that network configuration data should not be fully synchronized from the remote server, the availability of the local cache file is checked.

[0034] The local cache file is a persistent file located on the host machine where the virtual gateway agent is located, used to store the network configuration data.

[0035] In this step, if the first configuration information indicates that network configuration data should not be fully synchronized from the remote server, the virtual gateway agent checks the availability of the local cached file. Specifically, when the first configuration information indicates that network configuration data should not be fully synchronized from the remote server, it means that the virtual gateway agent allows attempts to use the local cache. At this time, the file is not loaded immediately; instead, an availability check is performed first. This step is a key improvement to avoid startup failures caused by complete reliance on the local cache. Availability checks not only check if the file exists but also check if the file is readable, if the format is as expected, etc., thereby identifying potential problems in advance and preparing for subsequent handling.

[0036] S103. In response to determining that the local cache file meets the availability conditions, load the network configuration data in the local cache file.

[0037] In this step, after confirming that the local cache file meets the availability requirements, a loading operation is performed. This step reads persistent data from the disk (such as JSON-formatted text) into memory and deserializes it into a program-manageable data structure (such as a Python dictionary) to obtain the network configuration data. This process is crucial for performance improvement because loading data from the local disk is much faster than fetching it from a remote server. Further, after the network configuration data is successfully loaded, data recovery is confirmed to be complete. Specifically, it is populated into the virtual gateway agent's runtime memory, replacing or initializing the cached data structures in memory. At this point, the virtual gateway agent has quickly completed startup recovery using the network configuration data in the local cache file and can immediately perform network management functions based on this data without waiting for a lengthy remote synchronization process.

[0038] S104. In response to the first configuration information instruction to perform full synchronization, perform full synchronization of network configuration data from the remote server.

[0039] In this step, when the first configuration information indicates full synchronization, the virtual gateway agent will fully synchronize network configuration data from the remote server.

[0040] This embodiment of the present disclosure obtains first configuration information when the virtual gateway agent process restarts. The first configuration information indicates whether to fully synchronize network configuration data from a remote server. In response to the first configuration information indicating not to fully synchronize network configuration data from the remote server, the availability of a local cache file is detected. In response to determining that the local cache file meets the availability condition, the network configuration data in the local cache file is loaded; or, in response to the first configuration information indicating full synchronization, a full synchronization of network configuration data from the remote server is triggered. Compared to the prior art, this embodiment of the present disclosure, by obtaining the first configuration information when the virtual gateway agent process restarts, prioritizes efficient local recovery to solve the slow startup problem when the first configuration information indicates not to fully synchronize. Simultaneously, through pre-emptive availability detection and local loading recovery, the startup performance of the virtual gateway agent can be improved, data consistency can be guaranteed, and thus reliability can be ensured.

[0041] Figure 2 A flowchart of a data recovery method provided in another embodiment of this disclosure is shown below. Figure 2 As shown, the method includes the following steps: S201. Obtain the first configuration item in the local configuration file. The first configuration item is used to statically configure whether full synchronization is enabled.

[0042] In this step, the virtual gateway agent reads the first configuration item in its local configuration file. For example, it reads the ` / etc / neutron / vgw_agent.ini` configuration file and looks for the `enable_vgw_agent_full_restart` item. This item is a static configuration and has the highest priority. If its value is `True`, it directly determines that the first configuration information indicates a full synchronization is required. This provides administrators with a deterministic and immediately effective control method, suitable for planned maintenance scenarios (such as data structure changes after version upgrades), and solves the need for forced data refresh at specific maintenance times.

[0043] S202. If the first configuration item indicates that full synchronization is not enabled, then the second configuration item in the local cache file is queried through the remote procedure call interface. The second configuration item is used to dynamically configure whether full synchronization is enabled.

[0044] In this step, if the first configuration item indicates that full synchronization is not enabled (e.g., the first configuration item is False or not set), the second configuration item is queried via the Remote Procedure Call (RPC) interface. For example, the agent calls the interface provided by Neutron Server to query the dynamic configuration `enable_vgw_agent_full_restart`. This item is a dynamic configuration and has lower priority. The second configuration item is used to dynamically configure whether full synchronization is enabled. If the second configuration item is True, it indicates that full synchronization is enabled; if it is False or not set, it indicates that full synchronization is not enabled.

[0045] This embodiment achieves comprehensive control granularity, ranging from coarse to fine and from fixed to flexible, through a two-tiered control system of static configuration files and dynamic RPC configuration. Static configuration ensures that explicit commands can be executed immediately upon virtual gateway agent startup; dynamic configuration provides the ability to adjust policies in real time during the virtual gateway agent's runtime, enabling recovery policies to adapt to complex and ever-changing operational needs.

[0046] In some embodiments, Figure 2 Steps S201 and S202 shown can be used as Figure 1 A specific implementation of step S101 shown.

[0047] S203. Check if the storage path of the local cache file exists.

[0048] In this step, the virtual gateway agent checks if the storage path for local cached files exists. For example, it uses the `os.path.exists(file_path)` function to check the path. This is the most basic check; if the path does not exist (e.g., during initial deployment or if the file was accidentally deleted), the application is directly deemed unusable.

[0049] S204. If the storage path exists, check whether the current process of the virtual gateway proxy has permission to read the local cache file.

[0050] In this step, if the storage path exists, the read permissions of the current process are checked. An attempt is made to access the file in read-only mode, catching any PermissionErrors. This resolves the issue of the virtual gateway proxy being unable to read local cached files due to permission changes.

[0051] S205. If the current process has read permission, it reads the local cache file based on the storage path and obtains a read result, which is used to indicate whether the local cache file exists.

[0052] If authorized, the local cache file is read based on the storage path, and the read result is used to indicate whether the local cache file exists.

[0053] S206. In response to the reading result indicating that the local cache file exists, determine that the local cache file meets the availability condition.

[0054] Furthermore, if the local cache file exists based on the reading results, then the local cache file is determined to meet the availability criteria.

[0055] S207. In response to determining that the local cache file meets the availability conditions, load the network configuration data in the local cache file.

[0056] Specifically, the implementation process and principle of S207 and S103 are the same, and will not be repeated here.

[0057] S208. If either the first configuration item or the second configuration item indicates that full synchronization is enabled, then it is determined that the first configuration information indicates that network configuration data is fully synchronized from the remote server.

[0058] In this step, if either the first or second configuration item indicates that full synchronization is enabled, the virtual gateway agent determines that the first configuration information indicates that network configuration data should be fully synchronized from the remote server. Similarly, if the second configuration item indicates that full synchronization is enabled (set to True), then a full synchronization is also required. This provides runtime dynamic control capabilities, suitable for emergency or large-scale operation and maintenance scenarios, eliminating the need to modify configuration files individually and greatly improving operational flexibility.

[0059] S209. In response to the first configuration information instruction to perform full synchronization, perform full synchronization of network configuration data from the remote server.

[0060] Specifically, the implementation process and principle of S209 and S104 are the same, and will not be repeated here.

[0061] This embodiment of the disclosure obtains a first configuration item from a local configuration file. This first configuration item is used to statically configure whether full synchronization is enabled. If the first configuration item indicates that full synchronization is not enabled, a second configuration item is queried from the local cache file via a remote procedure call interface. This second configuration item is used to dynamically configure whether full synchronization is enabled. Then, it checks whether the storage path of the local cache file exists. If the storage path exists, it checks whether the current process of the virtual gateway proxy has permission to read the local cache file. Further, if the current process has read permission, it reads the local cache file based on the storage path and obtains a read result. The read result indicates whether the local cache file exists. In response to the read result indicating that the local cache file exists, it is determined that the local cache file meets the availability condition. Then, in response to determining that the local cache file meets the availability condition, network configuration data in the local cache file is loaded. If either the first configuration item or the second configuration item indicates that full synchronization is enabled, it is determined that the first configuration information indicates that network configuration data is fully synchronized from a remote server. In response to the first configuration information indicating full synchronization, network configuration data is fully synchronized from the remote server. By employing this method, embodiments of this disclosure extend a simple file existence check to a comprehensive availability detection that includes path verification, permission verification, and file read results. This defensive programming strategy can detect and mitigate most problems caused by abnormal file system states before data is loaded, transforming potential runtime crashes into controllable process branches and improving reliability.

[0062] Figure 3 A flowchart of a data recovery method provided in another embodiment of this disclosure is shown below. Figure 3 As shown, the method includes the following steps: S301. When the process of the virtual gateway agent is restarted, first configuration information is obtained, the first configuration information being used to indicate whether to fully synchronize network configuration data from the remote server.

[0063] Specifically, the implementation process and principle of S301 and S101 are the same, and will not be repeated here.

[0064] S302. In response to the first configuration information indicating that network configuration data should not be fully synchronized from the remote server, the availability of the local cache file is checked.

[0065] Specifically, the implementation process and principle of S302 and S102 are the same, and will not be repeated here.

[0066] S303. In response to determining that the local cache file meets the availability conditions, load the network configuration data in the local cache file.

[0067] Specifically, the implementation process and principle of S303 and S103 are the same, and will not be repeated here.

[0068] In some embodiments, loading network configuration data from the local cache file in S303 may include S3031, S3032, S3033, and S3034: S3031. Open the local cache file in binary read mode.

[0069] In this step, the file is opened in binary reading mode to avoid potential problems caused by text encoding.

[0070] S3032. Read the file content of the local cache file and parse the file content into a preset structured data format.

[0071] In this step, the file content is read and parsed into a preset structured data format. For example, the file content (JSON string) is parsed into a Python dictionary object using json.loads() to improve readability, cross-language compatibility, and security.

[0072] S3033. If the parsing is successful, the parsed data in the preset structured data format is loaded as network configuration data into the running memory of the virtual gateway proxy.

[0073] In this step, it is determined whether the parsing was successful. If the parsing is successful, the parsed data in the preset structured data format is loaded as network configuration data into the runtime memory of the virtual gateway proxy.

[0074] S3034. If an exception occurs during the opening, reading, or parsing process, it is determined that the network configuration data failed to load, and an error log is recorded.

[0075] In this step, if an exception occurs during the opening, reading, or parsing process, including JSON format errors, data corruption, disk I / O errors, or files being in use, the loading is considered to have failed, and a detailed error log is recorded. The log includes exception stack information to facilitate subsequent troubleshooting.

[0076] This embodiment clarifies the specific operations and fault tolerance mechanisms of the loading process. Using a preset structured data format enhances data maintainability and version compatibility. Capturing and logging any anomalies (opening, reading, parsing) during the loading process ensures that even if the cached file content itself is problematic, it will not cause the data recovery process to crash.

[0077] S304. In response to determining that the local cache file does not meet the availability conditions, or in the case that the network configuration data loading fails, a degradation process is performed, wherein the degradation process is used to trigger a full synchronization of network configuration data from the remote server.

[0078] In this step, if it is determined that the local cache file does not meet the availability conditions, or if the network configuration data loading fails, a degradation process is performed. This degradation process triggers a full synchronization of network configuration data from the remote server. Essentially, the degradation process recovers from local failure by changing the recovery strategy to full synchronization. Specifically, if a file is detected as unavailable, or if loading fails in S103, degradation processing is performed in either case, fetching the latest data from a remote server (such as Redis) to ensure data consistency and system startup.

[0079] In some embodiments, a degradation process is performed in S304, including S3041 and S3042: S3041. Return a predefined empty cache data structure, which is used to indicate the operation of performing a full data synchronization; The empty cache data structure has the same top-level structure as the non-empty cache data structure, and the empty cache data structure contains a field associated with the cached content and the field is initialized to an empty value.

[0080] This step returns a predefined empty cache data structure. In some embodiments, a fixed Python dictionary is returned: {"domains": {}}. This structure is simple, lightweight, and compatible with normal cache data structures. The empty cache data structure is used to indicate the need to perform a full data synchronization operation.

[0081] S3042. Based on the empty cache data structure, the data in the remote server is fully synchronized to the running memory of the virtual gateway proxy to complete the recovery of the network configuration data.

[0082] In this step, a full synchronization is triggered based on an empty cache data structure. When an empty cache data structure (or a specific flag) is detected, a full data retrieval from the remote server is initiated, and the retrieved data is loaded into the runtime memory to complete the restoration of the network configuration data.

[0083] "Returning an empty cache" is a clever design pattern. It unifies the exit points for various abnormal situations, providing a clear and consistent trigger signal for upper-layer synchronization logic. Essentially, it's a "sentinel value" or "flag" that instructs the virtual gateway agent to perform remote full synchronization. In this embodiment, a degradation mechanism ensures a reliable backup path to restore service in various abnormal scenarios (file loss, corruption, permission issues, format errors), achieving high availability.

[0084] S305. In response to the first configuration information instruction to perform full synchronization, perform full synchronization of network configuration data from the remote server.

[0085] In this step, when the first configuration information indicates full synchronization, the virtual gateway agent will fully synchronize network configuration data from the remote server.

[0086] In some embodiments, when the first configuration information indicates a full data synchronization, the virtual gateway proxy returns a predefined empty cache data structure, which is used to indicate the operation of performing a full data synchronization. When an empty cache data structure (or a specific flag) is detected, a full data retrieval from the remote server is initiated, and the retrieved data is loaded into the local cache to restore the local cache data.

[0087] This embodiment implements degradation processing in two scenarios: when the local cached file does not meet the availability conditions or when network configuration data loading fails. It also covers the direct triggering scenario of full synchronization indicated by the first configuration information, constructing a complete and comprehensive fault handling and enforcement path. This ensures that regardless of any abnormal circumstances (missing files, corruption, insufficient permissions) or management requirements, the service can ultimately be restored through remote full synchronization, thereby greatly improving the availability and robustness of the entire system.

[0088] S306. In response to an update event of the network configuration data managed by the virtual gateway agent, the updated network configuration data is serialized into data in a preset structured data format.

[0089] In this step, during the operation of the virtual gateway agent, when the network configuration data managed by the virtual gateway agent is updated (e.g., upon receiving a configuration update RPC from a remote server), a persistence step is executed. Specifically, the system listens for network configuration data update events managed by the virtual gateway agent. This can be achieved automatically by linking with configuration overload functions through decorators (such as `gen_conf_file`). Furthermore, the updated network configuration data is serialized into a preset structured data format. For example, a dictionary object in memory can be serialized into a JSON string.

[0090] S307. The data in the preset structured data format is saved to the local cache file through an atomic write operation to update the local cache file.

[0091] In this step, the local cache file is updated through atomic write operations. For example, by using the method of "writing a temporary file → atomically replacing the original file" (such as l_utils.replace_file()), it is ensured that the original cache file will not be corrupted in the event of a crash or interruption during the write process, thus guaranteeing the integrity of the file content.

[0092] S308. Create a timestamped copy of the local cache file and save the copy as a historical backup file.

[0093] This step creates a timestamped historical backup file. For example, copy the file written this time and name it vgw_local_cache_file.time_102030. This preserves the cached historical version, and the creation of historical backup files greatly facilitates troubleshooting, data auditing, and manual recovery.

[0094] This embodiment of the disclosure obtains first configuration information when the virtual gateway agent process restarts. This first configuration information indicates whether to fully synchronize network configuration data from a remote server. In response to the first configuration information indicating not to fully synchronize network configuration data from the remote server, the availability of a local cache file is detected. Then, in response to determining that the local cache file meets the availability conditions, the network configuration data in the local cache file is loaded. In response to determining that the local cache file does not meet the availability conditions, or if the network configuration data loading fails, a degradation process is performed, which triggers a full synchronization of network configuration data from the remote server. In response to the first configuration information indicating full synchronization, a full synchronization of network configuration data from the remote server is triggered. Next, in response to an update event of the network configuration data managed by the virtual gateway agent, the updated network configuration data is serialized into data in a preset structured data format. The data in the preset structured data format is saved to the local cache file through an atomic write operation to update the local cache file. A timestamped copy of the local cache file is created and saved as a historical backup file. Compared to the prior art, this embodiment of the disclosure provides a reliable and efficient persistence mechanism. Atomicity writes eliminate the risk of file corruption. When the local cached data is updated, the local cache file is updated, ensuring consistency between memory and disk cache without additional management. The creation of historical backup files greatly facilitates troubleshooting, data auditing, and manual recovery, improving maintainability.

[0095] The solutions in the various embodiments of this disclosure can be used individually or in combination without conflict. For example, in S208, if either the first configuration item or the second configuration item indicates that full synchronization is enabled, it is determined that the first configuration information indicates full synchronization of network configuration data from a remote server. In response to determining that the local cache file does not meet the availability conditions, or in the case that the network configuration data loading fails, a degradation process is performed. The degradation process is used to trigger full synchronization of network configuration data from the remote server. These solutions can be used in combination and are not specifically limited here.

[0096] Figure 4 This is a schematic diagram of the structure of a data recovery apparatus provided in an embodiment of this disclosure. The data recovery apparatus can be an electronic device as described in the above embodiment, or it can be a component or assembly within that electronic device. The data recovery apparatus provided in this embodiment can execute the processing flow provided in the data recovery method embodiment, such as... Figure 4 As shown, the data recovery device is applied to a virtual gateway agent. The data recovery device 50 includes: an acquisition module 51, a detection module 52, and a recovery module 53. The acquisition module 51 acquires first configuration information when the process of the virtual gateway agent restarts. The first configuration information indicates whether to fully synchronize network configuration data from a remote server. The detection module 52 detects the availability of a local cache file in response to the first configuration information indicating not to fully synchronize network configuration data from the remote server. The local cache file is a persistent file located on the host machine where the virtual gateway agent resides, used to store the network configuration data. The recovery module 53 loads the network configuration data from the local cache file in response to determining that the local cache file meets the availability conditions; or, in response to the first configuration information indicating full synchronization, fully synchronizes the network configuration data from the remote server.

[0097] Optionally, when the acquisition module 51 acquires the first configuration information, it is specifically used to: acquire the first configuration item in the local configuration file, the first configuration item being used to statically configure whether full synchronization is enabled; if the first configuration item indicates that full synchronization is not enabled, then query the second configuration item in the local cache file through the remote procedure call interface, the second configuration item being used to dynamically configure whether full synchronization is enabled; Before the recovery module 53 fully synchronizes network configuration data from the remote server, it is further configured to: if either the first configuration item or the second configuration item indicates that full synchronization is enabled, determine that the first configuration information indicates that network configuration data is fully synchronized from the remote server.

[0098] Optionally, when the detection module 52 detects the availability of the local cache file, it is specifically used to: check whether the storage path of the local cache file exists; if the storage path exists, check whether the current process of the virtual gateway proxy has permission to read the local cache file; if the current process has read permission, read the local cache file based on the storage path to obtain a read result, the read result being used to indicate whether the local cache file exists; in response to the read result indicating that the local cache file exists, determine that the local cache file meets the availability conditions.

[0099] Optionally, when the recovery module 53 loads the network configuration data in the local cache file, it is specifically configured to: open the local cache file in binary read mode; read the file content of the local cache file and parse the file content into a preset structured data format; if the parsing is successful, load the parsed data in the preset structured data format as network configuration data into the running memory of the virtual gateway proxy; if an exception occurs during the opening, reading, or parsing process, determine that the network configuration data loading has failed and record an error log.

[0100] Optionally, the recovery module 53 is further configured to: in response to determining that the local cache file does not meet the availability conditions, or in the case of failure to load the network configuration data, perform a degradation process, the degradation process being used to trigger a full synchronization of network configuration data from the remote server.

[0101] Optionally, the device 50 further includes: a writing module 54; the writing module 54 is configured to, in response to an update event of the network configuration data managed by the virtual gateway agent, serialize the updated network configuration data into data in a preset structured data format; save the data in the preset structured data format to the local cache file through an atomic write operation to update the local cache file; create a timestamped copy of the local cache file, and save the copy as a historical backup file.

[0102] Optionally, when the recovery module 53 performs the downgrade process, it is specifically used to: return a predefined empty cache data structure, the empty cache data structure being used to indicate the operation of performing a full data synchronization, the empty cache data structure having the same top-level structure as the non-empty cache data, the empty cache data structure containing a field associated with the cached content and the field being initialized to an empty value; based on the empty cache data structure, fully synchronize the data in the remote server to the running memory of the virtual gateway proxy to complete the recovery of the network configuration data.

[0103] Figure 4The data recovery device shown in the embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and will not be described again here.

[0104] Figure 5 This is a schematic diagram of the structure of an electronic device according to an embodiment of this disclosure. See below for details. Figure 5 It shows a schematic diagram of a structure suitable for implementing the electronic device 600 in the embodiments of this disclosure. Figure 5 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0105] like Figure 5 As shown, electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 601, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 602 or a program loaded from storage device 608 into random access memory (RAM) 603 to implement the data recovery method as described in the embodiments of this disclosure. The RAM 603 also stores various programs and data required for the operation of electronic device 600. The processing device 601, ROM 602, and RAM 603 are interconnected via bus 604. An input / output (I / O) interface 605 is also connected to bus 604.

[0106] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, magnetic tapes, hard disks, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 5 An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0107] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts, thereby implementing the data recovery method described above. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, it performs the functions defined in the methods of embodiments of this disclosure.

[0108] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0109] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.

[0110] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.

[0111] The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: When the process of the virtual gateway agent restarts, it obtains first configuration information, which is used to indicate whether to fully synchronize network configuration data from the remote server. In response to the first configuration information indicating not to fully synchronize network configuration data from the remote server, the availability of the local cache file is checked; the local cache file is a persistent file located on the host machine where the virtual gateway proxy is located, used to store the network configuration data; In response to determining that the local cache file meets the availability conditions, network configuration data in the local cache file is loaded; Alternatively, in response to the first configuration information instruction to perform a full synchronization, the network configuration data is fully synchronized from the remote server.

[0112] Optionally, when one or more of the above-described procedures are executed by the electronic device, the electronic device may also execute other steps of the above embodiments.

[0113] Computer program code for performing the operations of this disclosure can be written in one or more programming languages ​​or a combination thereof, including but not limited to object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed 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 remote computers, the remote computer can 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 can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0114] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0115] The units described in the embodiments of this disclosure can be implemented in software or hardware. The names of the units are not, in some cases, intended to limit the specific unit.

[0116] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), and so on.

[0117] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0118] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

[0119] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0120] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.

Claims

1. A data recovery method, characterized in that, Applied to virtual gateway proxies, the method includes: When the process of the virtual gateway agent restarts, it obtains first configuration information, which is used to indicate whether to fully synchronize network configuration data from the remote server. In response to the first configuration information indicating not to fully synchronize network configuration data from the remote server, the availability of the local cache file is checked; the local cache file is a persistent file located on the host machine where the virtual gateway proxy is located, used to store the network configuration data; In response to determining that the local cache file meets the availability conditions, network configuration data in the local cache file is loaded; Alternatively, in response to the first configuration information instruction to perform a full synchronization, the network configuration data is fully synchronized from the remote server.

2. The method according to claim 1, characterized in that, The process of obtaining the first configuration information includes: Get the first configuration item in the local configuration file. The first configuration item is used to statically configure whether to enable full synchronization. If the first configuration item indicates that full synchronization is not enabled, then the second configuration item in the local cache file is queried through the remote procedure call interface. The second configuration item is used to dynamically configure whether full synchronization is enabled. Before synchronizing the network configuration data in full from the remote server, the method further includes: If either the first configuration item or the second configuration item indicates that full synchronization is enabled, then it is determined that the first configuration information indicates that network configuration data is fully synchronized from the remote server.

3. The method according to any one of claims 1 or 2, characterized in that, The detection of the availability of local cache files includes: Check if the storage path of the local cache file exists; If the storage path exists, check whether the current process of the virtual gateway proxy has permission to read the local cache file; If the current process has read permission, it reads the local cache file based on the storage path and obtains a read result, which is used to indicate whether the local cache file exists. In response to the read result indicating the existence of the local cache file, it is determined that the local cache file meets the availability condition.

4. The method according to claim 1, characterized in that, The loading of network configuration data from the local cache file includes: Open the local cache file in binary read mode; Read the file content of the local cache file and parse the file content into a preset structured data format; If the parsing is successful, the parsed data in the preset structured data format will be loaded as network configuration data into the runtime memory of the virtual gateway proxy. If an exception occurs during the opening, reading, or parsing process, it is determined that the network configuration data failed to load, and an error log is recorded.

5. The method according to claim 1, characterized in that, The method further includes: In response to determining that the local cache file does not meet the availability conditions, or in the event that the network configuration data fails to load, a degradation process is performed to trigger a full synchronization of the network configuration data from the remote server.

6. The method according to claim 1, characterized in that, The method further includes: In response to an update event of the network configuration data managed by the virtual gateway agent, the updated network configuration data is serialized into data in a preset structured data format; The data in the preset structured data format is saved to the local cache file through an atomic write operation to update the local cache file; Create a timestamped copy of the local cache file and save the copy as a historical backup file.

7. The method according to claim 5, characterized in that, The degradation process includes: Returns a predefined empty cache data structure that indicates the operation of performing a full data synchronization. The empty cache data structure has the same top-level structure as the non-empty cache data and contains fields associated with the cached content, which are initialized to null values. Based on the empty cache data structure, all data in the remote server is fully synchronized to the running memory of the virtual gateway proxy to complete the recovery of the network configuration data.

8. A data recovery device, characterized in that, The device, used for virtual gateway proxies, includes: The acquisition module is used to acquire first configuration information when the process of the virtual gateway agent is restarted. The first configuration information is used to indicate whether to fully synchronize network configuration data from a remote server. The detection module is used to detect the availability of a local cache file in response to the first configuration information indicating that network configuration data should not be fully synchronized from the remote server; the local cache file is a persistent file located on the host machine where the virtual gateway proxy is located, used to store the network configuration data; The recovery module is configured to load network configuration data from the local cache file in response to determining that the local cache file meets the availability conditions; or, in response to the first configuration information indicating full synchronization, trigger a full synchronization of network configuration data from the remote server.

9. An electronic device, characterized in that, include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and configured to be executed by the processor to implement the method as described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-7.