Network element data persistence method and device, computer equipment and storage medium
By creating a child process when the network element is first run, the problem of inefficient data persistence in traditional solutions is solved, and more efficient resource utilization and data persistence are achieved.
Patent Information
- Application Number
- CN202411634612.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-15
- Publication Date
- 2025-02-28
AI Technical Summary
When traditional data persistence solutions process large-scale data, the function call time is long and the resource consumption is large, which may lead to server failures, delays and inefficiency.
Create a child process when the network element is first run, read counter parameter information through the child process and write to the persistent template file to form a target file and persist, reducing the load of the main process. Load the last persisted target file when run again.
The child process data persistence tasks can be processed, the main process load is reduced, resource usage is reduced, data persistence efficiency is improved, and the server resource usage in traditional solutions is avoided.
Smart Images

Figure CN119536943A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a network element data persistence method, apparatus, computer equipment, storage medium and computer program product. Background Art
[0002] With the development of Internet technology, computers need to process large amounts of complex data, and the amount of data processing has increased significantly. In order to improve the flexibility of data processing, it is often necessary to cache and persist specific data. Therefore, how to achieve data persistence has become one of the problems to be solved.
[0003] In traditional solutions, a branch function is usually called to perform actual data persistence work. For example, a branch function is called to execute a data persistence instruction, store specific data in the server into a cache area, and then store it persistently.
[0004] However, when the data set is large, traditional solutions may need to call multiple branch functions, which leads to long function call time, high resource usage, and may also cause server failures and delays, resulting in inefficient data persistence. Summary of the invention
[0005] Based on this, it is necessary to provide a network data persistence method, apparatus, computer equipment and computer-readable storage medium that can improve data persistence efficiency in response to the above technical problems.
[0006] In a first aspect, the present application provides a method for persisting network data. The method comprises:
[0007] When the network element is running for the first time, a subprocess for data persistence is created;
[0008] Run the subprocess, and when the subprocess is run, perform the following steps: read the counter parameter information of the network element, write the read counter parameter information into a preset persistent template file, obtain the target file of the network element, and persist the target file;
[0009] When the network element is run again, the target file persisted during the last run of the network element is loaded.
[0010] In a second aspect, the present application also provides a network element data persistence device. The device includes:
[0011] The process creation module is used to create a subprocess for data persistence when the network element is running for the first time;
[0012] A data writing module is used to run the sub-process, and the sub-process performs the following steps when being run: reading the counter parameter information of the network element, writing the read counter parameter information into a preset persistent template file, obtaining the target file of the network element, and persisting the target file;
[0013] The data loading module is used to load the target file persisted when the network element was last run when the network element is run again.
[0014] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps in the above-mentioned embodiments of the network element data persistence method are implemented.
[0015] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps in the above-mentioned embodiments of the network element data persistence method are implemented.
[0016] In a fifth aspect, the present application further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned network element data persistence method embodiments are implemented.
[0017] The above-mentioned network element data persistence method, device, computer equipment, storage medium and computer program product can reduce the load of the main process by creating a subprocess to handle the data persistence task when the network element is running for the first time, so that the main process can focus on other tasks and reduce the occupation of the overall server resources by the persistence task. Furthermore, in the running subprocess, the counter parameter information of the network element is first read, and then the read counter parameter information is written into the preset persistence template object to form a target file in a targeted manner and persist the target file. This targeted persistence of specific data further reduces the occupation of server resources by the data persistence task. Different from the traditional solution of calling multiple branch functions to persist data, this solution will not excessively affect the main process when the subprocess executes the persistence task, and the subprocess can persist the data written by the main process while the main process writes data, thereby improving the efficiency of data persistence. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] FIG1 is an application environment diagram of a network element data persistence method in one embodiment;
[0019] Figure 2 A schematic diagram of a flow chart of a method for persisting network data in an embodiment;
[0020] Figure 3A schematic flow chart of steps for generating a target file in one embodiment;
[0021] Figure 4 It is a flowchart of a method for persisting network data in another embodiment;
[0022] Figure 5 A schematic diagram of a flow chart of a method for persisting network data in a detailed embodiment;
[0023] Figure 6 is a structural block diagram of a network element data persistence device in an embodiment;
[0024] Figure 7 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0026] The network data persistence method provided in the embodiment of the present application can be applied in the application environment shown in FIG1. In which, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers.
[0027] Specifically, the operator may deploy a persistence program on the server 104 through the terminal 102. When the network element is run for the first time, the server 104 creates a sub-process for data persistence and then runs the sub-process. When the sub-process is run, the following steps are performed: the server 104 reads the counter parameter information of the network element, writes the read counter parameter information into a preset persistence template file, obtains the target file of the network element, and finally persists the target file. When the network element is run again, the server 104 loads the target file that was persisted when the network element was last run.
[0028] The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, and portable wearable devices. The IoT devices may be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. The portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. The server 104 may be implemented as an independent server or a server cluster consisting of multiple servers.
[0029] In one embodiment, Figure 2As shown, a method for persisting network data is provided, which is described by taking the method applied to the server 104 in FIG. 1 as an example, and includes the following steps:
[0030] S100: When the network element is running for the first time, a subprocess for data persistence is created.
[0031] It should be noted that the following text is explained by taking the application of this application scheme in SDN (Software Defined Network) as an example. SDN is a network architecture design that separates the network controller and data forwarding. Under the SDN network architecture, NFV (Network Functions Virtualization) technology is further used to decouple network functions from dedicated hardware devices, and implement network functions with software on standard general-purpose servers through VNF (Virtual Network Functions).
[0032] Among them, network element refers to the basic building block of network equipment. The network element in this application refers to NFV network element. The first operation refers to the state of the network element being activated and executed for the first time after installation or restart. Data persistence refers to saving data in a specific storage space so that the data will not be lost when the network element is restarted or upgraded. A subprocess is similar to an independent execution unit, created by the main process, and the subprocess will not affect the working state of the main process when it is running.
[0033] For example, when a network element runs for the first time, some specific data needs to be persisted, so the main process of the network element creates a child process, such as using the fork function to create a child process, and sets the child process specifically for performing data persistence tasks without affecting the running status and performance of the main process of the network element. After the child process persists the specific data, it will not be easy to lose this specific data when the network element is started next time.
[0034] S200, running a subprocess, the subprocess executes the following steps when being run: reading counter parameter information of a network element, writing the read counter parameter information into a preset persistent template file, obtaining a target file of the network element, and persisting the target file.
[0035] The counter parameter information includes but is not limited to counter identifiers, counter values and other information. The counter parameter information represents the values of each counter in the network element and the counter records. Furthermore, the counter value can represent the statistical data of the network element during operation, such as the number of data packets, the number of errors and other information. The persistent template file is a pre-set standardized data file structure, which defines the type of data to be persisted, the data format and the data location.
[0036] Exemplarily, after the child process is started, a series of data reading and writing operations will be performed. First, the counter parameter information is read, where the counter parameter information characterizes the usage of the network element during runtime system, error statistics, number of specific data packets, number of users, data throughput, etc., and then the counter information is written into the preset persistent template file to obtain the target file. This process can use the copy-on-write technology to minimize the impact of the child process on the main process. Furthermore, the target file can be written to a disk or a specific storage space to persist the target file. It should be noted that in addition to writing the counter parameter information of the counter into the preset persistent template file, other memory data in the server that is not related to the server configuration can also be written into the corresponding template, and the memory data is also loaded when the network element runs again in the future.
[0037] S300, when the network element is running again, load the target file persisted when the network element was last running.
[0038] Following the above steps, when the NE is started or restarted again, the main process of the NE can load the target file persisted when the NE was last running. If the target file is not loaded, the counter value collected by the watchdog in the NE may be smaller than the counter value collected when the NE was last running. Loading the target file can make the counter value of the NE consistent with the counter value when the NE was last shut down, so that the NE can quickly recover to the working state consistent with the last shutdown.
[0039] The above network element data persistence method can reduce the load of the main process by creating a subprocess to handle the data persistence task when the network element is running for the first time, so that the main process can focus on other tasks and reduce the occupation of the overall server resources by the persistence task. Furthermore, in the running subprocess, the counter parameter information of the network element is first read, and then the read counter parameter information is written into the preset persistence template object to form a target file in a targeted manner and persist the target file. This targeted persistence of specific data further reduces the occupation of server resources by the data persistence task. Different from the traditional solution of calling multiple branch functions to persist data, this solution will not excessively affect the main process when the subprocess executes the persistence task, and the subprocess can persist the data written by the main process while the main process is writing data, thereby improving the efficiency of data persistence.
[0040] In one embodiment, the counter parameter information includes a counter identifier and a counter value, such as Figure 3 As shown, the read counter parameter information is written into the preset persistent template file to obtain the target file of the network element, including:
[0041] S210, generating a key-value pair according to the counter identifier and the counter value, and determining a checksum of the key-value pair.
[0042] S220, obtain the network element version number of the network element, write the network element version number, key-value pair, preset terminator, and checksum into the preset persistent file template file, update the update time of the preset persistent file template file, and obtain the target file of the network element.
[0043] Among them, the counter identifier is a unique identifier, which is equivalent to the name of the counter and is used to mark a specific counter. The counter value is the current data recorded by the counter, which can represent information such as network throughput and number of data packet transmissions. A key-value pair is a form of data storage. In this embodiment, the key represents the counter identifier and the value represents the counter value. The checksum is used to verify the integrity of the key-value pair. It can be calculated according to specific rules to generate a numerical value to detect whether an error occurs in the key-value pair during transmission or storage. The network element version number is used to identify the current version of the network element. The preset terminator is a special identifier used to indicate the end of the data. The update time refers to the timestamp when the persistent file was last modified.
[0044] Specifically, a key-value pair is first generated based on the read counter identifier and counter value, with the counter identifier as the "key" in the key-value pair and the counter value as the "value" in the key-value pair. Further, a checksum is calculated based on the key-value pair. The generation of the checksum can be based on a variety of algorithms, such as a cyclic redundancy check method, etc. The final calculated checksum also needs to be written into a preset persistent template file, so that if the data is damaged during storage or transmission, the server can also detect data changes through the checksum, thereby improving the security and integrity of the target file.
[0045] Furthermore, the preset persistent file template file may be as shown in Table 1:
[0046] Table 1 Persistent file template file
[0047]
[0048] In Table 1, the string type is agreed to be "VNF", which is used to determine whether the target file is a persistent file of the network element. The network element version number is used for compatibility checking, and the update timestamp is used to record the time of the last update. The counter identifier can be used to record the name of the counter, and the counter value can be used to record the actual value of the counter (unit64 type). Since there may be multiple counters in the network element, multiple keys and values can be written in the Data part to form multiple key-value pairs. EOF can be preset to 0xFF to mark the end of the key-value pair, and Checksum can also be a string of unit64 type to verify the integrity of the data.
[0049] The network element version number, key-value pair, preset end character, and checksum are written into the persistent file template file shown in Table 1, and the update timestamp of the persistent file template file is updated to obtain the target file of the network element.
[0050] In this embodiment, by recording the network element version number, counter parameter information, checksum and other data, the target file not only records the running status of the network element when it was last running, but also verifies the integrity and compatibility of the target file, so that when the network element is restarted, the running status of the network element can be accurately restored to the last running state by loading the target file.
[0051] In one embodiment, S300 includes: when the network element is running again, searching for the target file in a preset directory, loading the target file if the target file is found, and exiting the loading process if the target file is not found.
[0052] The storage path pre-set by the server is used to store the target file, and the preset directory is used to centrally store and manage the target files of the network element, so that the target file can be quickly located.
[0053] Continuing with the above embodiment, when the network element runs again, the server first searches the preset directory for the target file generated during the last network element operation. If the target file is found, the server will load the target file. During the process of loading the target file, the server will parse the content in the target file and extract the counter identifier, counter value, network element version number, checksum and other information. Then, the server will assign values to the counters of the network elements based on the extracted data to restore the network element to the state of the last operation.
[0054] If the target file generated when the network element was last run is not found in the preset directory, it means that the network element may be running for the first time, or the previous target file has been moved or deleted. At this time, the server will exit the loading process and will not continue the recovery operation.
[0055] In this embodiment, when the target file is found and successfully loaded, the network element can quickly recover to the state of the last operation, reducing data disconnection caused by the restart of the network element. If the target file is not found, the loading process is directly exited without affecting other processes in the server, thereby improving the stability of the network element operation.
[0056] In one embodiment, Figure 4 As shown, S300 includes:
[0057] S310, when the network element is running again, search for the target file in the preset directory, and when the target file is found, parse the target file to determine the string type, network element version number, counter number, key-value pair, and checksum of the target file.
[0058] S320, performing an XOR operation on the key-value pair to obtain an operation result.
[0059] S330, based on the string type, the network element version number, the counter number, the checksum, and the calculation result, load the target file that was persisted when the network element was last run.
[0060] The string type is a format identifier for recording data in the target file. In this embodiment, the string type is VNF. XOR operation is a logical operation that can be used to verify data. In this embodiment, the integrity of the data is determined by performing XOR operation on the key-value pair and then comparing the XOR operation result with the checksum.
[0061] Continuing with the above embodiment, after the server finds the target file, it first parses the target file content and extracts key field information. Specifically, the server first reads the header information of the target file to obtain the string type of the target file to identify the format of the data recorded in the target file, thereby determining whether the characters in the target file can be correctly read during parsing, and reading the network element version number to determine whether the target file is compatible with the current network element. In addition, it is also necessary to read key data such as the number of counters, key-value pairs, and checksums. Furthermore, the server performs an XOR operation on the key-value pairs extracted from the target file to obtain an operation result, which can be used for comparison with the checksum. If the two are consistent, it means that the data of the target file has not been tampered with during the storage or transmission of the target file. If the two are inconsistent, it means that the data in the target file may be incomplete, and the loading process should be exited.
[0062] Finally, after parsing and extracting the above data from the target file, verify the compatibility and integrity of the target file based on the string type, network element version number, number of counters, checksum, and calculation results. After confirming that the target file is compatible and not damaged, perform the loading operation, otherwise exit the loading process.
[0063] In this embodiment, by checking the compatibility and integrity of the target file before loading the target file, the security of the target file loading process is improved, and the abnormal situations caused by damage or incompatibility of the target file are reduced, so that the server has stronger fault tolerance and data recovery capabilities.
[0064] In one embodiment, S330 includes assigning a value to a counter of a network element according to a key-value pair when all of the following items are met: first, the string type matches a preset string type; second, the network element version number is less than the current network element version number; third, the counter number is not a preset value; fourth, the calculation result is consistent with the checksum; if any of the above items is not met, the loading process is exited.
[0065] Following the above embodiment, after extracting the above data from the target file, the server will determine whether to assign a value to the counter of the current network element based on the following conditions: First, determine whether the string type of the target file matches the preset string type. In this embodiment, the preset string type is "VNF". If the string type of the target file is also "VNF", it is considered that the two match. Otherwise, the server will exit the loading process. Second, determine whether the network element version number is less than the current network element version number. This is because the current network element can be compatible with a lower version of the target file, but may not be compatible with a higher version of the target file. For example, assuming that the network element version number of the current network element is "V1.2" and the version number of the target file is "V1.1", this judgment condition is met. If the version number of the target file is "V1.3", this judgment condition is not met, and the loading process is exited. Third, whether the number of the counter is a preset value. In this embodiment, the preset value is 0, that is, when the number of the counter is 0, the server exits the loading process. The fourth item determines whether the operation result is consistent with the checksum. The server performs an XOR operation on the key-value pairs in the target file to generate an operation result. If the operation result is consistent with the checksum, it means that the target file is complete. If the two are inconsistent, it means that the target file may be damaged or tampered with. At this time, the server exits the loading process.
[0066] Furthermore, if the above four judgment conditions are all met, the server will assign a value to the counter of the current network element according to the key-value pair extracted from the target file. Specifically, since the key-value pair contains a counter identifier and a counter value, it is only necessary to assign a value to the counter in the current network element that matches the counter identifier to the corresponding counter value in the key-value pair.
[0067] In this embodiment, by setting the above judgment conditions, the server will assign values to the counter only when all target files meet the judgment conditions, thereby improving the data integrity and compatibility of the target files.
[0068] In one embodiment, the child process further performs the following steps during operation: after persisting the target file, sending a process recycling signal to the main process to instruct the main process to recycle the child process.
[0069] The process recovery signal is used to instruct the main process to recover the child process, such as cleaning up the child process's memory, resources, etc. Specifically, after persisting the target file, such as writing the target file to the disk, the child process sends a process recovery signal to the main process. After receiving the signal, the main process will execute the child process recovery operation to release the system resources occupied by the child process.
[0070] In this embodiment, after the sub-process completes the persistence task, the sub-process is recycled in time to achieve resource recycling, reduce unnecessary memory usage, and improve the utilization efficiency of system resources.
[0071] In one embodiment, S100 includes periodically creating a sub-process for data persistence when the network element is running for the first time.
[0072] Specifically, a timer can be deployed in the server to create a subprocess at a set time interval. The subprocess performs the persistence task after being created. For example, the server can create a subprocess for performing the persistence task every five minutes. As the counter value of the counter may change as the main process runs, by periodically creating a subprocess for data persistence, the subprocess can persist the latest data.
[0073] In this embodiment, by periodically creating a sub-process to perform data persistence, the sub-process can persist the latest data each time, so that when the target file is loaded subsequently, the latest target file can also be loaded when the network element runs again, thereby improving the continuity and real-time nature of the data and providing guarantee for data recovery.
[0074] In order to make a clearer description of the network data persistence method provided by the present application, the following is a specific embodiment and the attached Figure 5 To illustrate, this specific embodiment includes the following steps:
[0075] S501, when the network element is running for the first time, a sub-process for data persistence is regularly created and the sub-process is run.
[0076] S502, read the counter parameter information of the network element, generate a key-value pair according to the counter identifier and the counter value, and determine the checksum of the key-value pair.
[0077] S503, obtain the network element version number of the network element, write the network element version number, key-value pair, preset end character, and checksum into the preset persistent file template file, update the update time of the preset persistent file template file, and obtain the target file of the network element.
[0078] S504, persist the target file, and after persisting the target file, send a process recovery signal to the main process.
[0079] S505, when the network element is running again, searching for the target file in the preset directory, and exiting the loading process if the target file is not found.
[0080] S506, when the target file is found, the target file is parsed to determine the string type, network element version number, counter number, key-value pair, and checksum of the target file.
[0081] S507, performing an XOR operation on the key-value pair to obtain an operation result, and based on the string type, the network element version number, the counter number, the checksum, and the operation result, loading the target file that was persisted when the network element was last run.
[0082] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0083] Based on the same inventive concept, the embodiment of the present application also provides a network data persistence device for implementing the network data persistence method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more network data persistence device embodiments provided below can refer to the limitations of the network data persistence method above, and will not be repeated here.
[0084] In one embodiment, Figure 6 As shown, a network element data persistence device 600 is provided, including: a process creation module 610, a data writing module 620 and a data loading module 630, wherein:
[0085] The process creation module 610 is used to create a sub-process for data persistence when the network element is running for the first time.
[0086] The data writing module 620 is used to run the sub-process. When the sub-process is run, the following steps are performed: read the counter parameter information of the network element, write the read counter parameter information into a preset persistent template file, obtain the target file of the network element, and persist the target file.
[0087] The data loading module 630 is used to load the target file persisted during the last operation of the network element when the network element is operated again.
[0088] In one embodiment, the counter parameter information includes a counter identifier and a counter value. The data writing module 620 is also used to generate a key-value pair based on the counter identifier and the counter value, determine the checksum of the key-value pair, obtain the network element version number of the network element, write the network element version number, key-value pair, preset terminator, and checksum into a preset persistent file template file, update the update time of the preset persistent file template file, and obtain the target file of the network element.
[0089] In one embodiment, the data loading module 630 is also used to search for the target file in the preset directory when the network element runs again, load the target file if the target file is found, and exit the loading process if the target file is not found.
[0090] In one embodiment, the data loading module 630 is also used to parse the target file when the target file is found, determine the string type, network element version number, number of counters, key-value pairs, and checksum of the target file, perform an XOR operation on the key-value pairs to obtain the operation result, and based on the string type, network element version number, number of counters, checksum, and operation result, load the target file that was persisted when the network element was last run.
[0091] In one embodiment, the data loading module 630 is also used to assign a value to the counter of the network element according to the key-value pair when all of the following items are met: the first item, the string type matches the preset string type; the second item, the network element version number is less than the current network element version number; the third item, the counter number is not a preset value; the fourth item, the calculation result is consistent with the checksum; if any of the above items is not met, the loading process is exited.
[0092] In one embodiment, the data writing module 620 is further configured to send a process reclaiming signal to the main process after persisting the target file, so as to instruct the main process to reclaim the subprocess.
[0093] In one embodiment, the process creation module 610 is further used to periodically create a sub-process for data persistence when the network element is running for the first time.
[0094] Each module in the above-mentioned network data persistence device can be implemented in whole or in part by software, hardware and their combination. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0095] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 7 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as counter parameter information. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a network element data persistence method is implemented.
[0096] Those skilled in the art will understand that Figure 7 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0097] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in the above-mentioned network element data persistence method embodiments when executing the computer program.
[0098] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned network element data persistence method embodiments are implemented.
[0099] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above-mentioned network element data persistence method embodiments when executed by a processor.
[0100] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0101] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0102] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0103] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for persisting network data, characterized in that: The method comprises: When the network element is running for the first time, a subprocess for data persistence is created; Run the subprocess, and when the subprocess is run, perform the following steps: read the counter parameter information of the network element, write the read counter parameter information into a preset persistent template file, obtain the target file of the network element, and persist the target file; When the network element is run again, the target file persisted during the last run of the network element is loaded.
2. The method according to claim 1, characterized in that The counter parameter information includes a calculator identifier and a counter value; the read counter parameter information is written into a preset persistent template file to obtain a target file of the network element, including: Generate a key-value pair according to the counter identifier and the counter value; determining a checksum of the key-value pair; Obtain the network element version number of the network element, write the network element version number, the key-value pair, the preset end character, and the checksum into a preset persistent file template file, update the update time of the preset persistent file template file, and obtain the target file of the network element.
3. The method according to claim 1, characterized in that The loading of the persistent target file of the last operation of the network element includes: When the network element is running again, searching for the target file in a preset directory; When the target file is found, loading the target file; If the target file is not found, the loading process is exited.
4. The method according to claim 3, characterized in that: The loading of the target file persisted during the last operation of the network element comprises: When the target file is found, the target file is parsed to determine the string type, network element version number, counter number, key-value pair, and checksum of the target file; Performing an XOR operation on the key-value pair to obtain an operation result; Based on the string type, the network element version number, the counter number, the checksum, and the calculation result, the target file persisted when the network element was last run is loaded.
5. The method according to claim 4, characterized in that The loading of the target file persisted during the last operation of the network element based on the string type, the network element version number, the counter number, the checksum, and the operation result includes: When all of the following items are met, assign a value to the counter of the network element according to the key-value pair: First, the string type matches the preset string type; The second item, the network element version number is less than the current network element version number; The third item is that the counter number is not a preset value; The fourth item is that the operation result is consistent with the checksum; If any of the above conditions are not met, the loading process is exited.
6. The method according to any one of claims 1 to 5, characterized in that: The subprocess also performs the following steps during operation: After the target file is persisted, a process recovery signal is sent to the main process to instruct the main process to recover the child process.
7. The method according to any one of claims 1 to 5, characterized in that: When the network element is run for the first time, a subprocess for data persistence is created, including: When the network element is running for the first time, a subprocess for data persistence is created regularly.
8. A network data persistence device, characterized in that: The device comprises: The process creation module is used to create a subprocess for data persistence when the network element is running for the first time; A data writing module is used to run the sub-process, and the sub-process performs the following steps when being run: reading the counter parameter information of the network element, writing the read counter parameter information into a preset persistent template file, obtaining the target file of the network element, and persisting the target file; The data loading module is used to load the target file persisted when the network element was last run when the network element is run again.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.