A data access method and apparatus
By configuring corresponding containers for different types of data and setting refresh intervals, the problem of insufficient data timeliness in the existing technology is solved, and the timeliness and accuracy of data access are achieved.
Patent Information
- Application Number
- CN202210078450.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-24
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2042-01-24
AI Technical Summary
In the prior art, the data access method based on SNMP cannot meet the data demand with high timeliness requirements, resulting in large errors in the acquired data.
By mapping different types of data to different containers and pre-configuring a refresh time for each container, the effective time of the cached data in the container is no longer than the refresh time, and the target data is read from the target container.
It ensures the timeliness of data, reduces data errors, and ensures that the data obtained by network devices meets the timeliness requirements.
Smart Images

Figure CN114489943B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a data access method and device. Background Art
[0002] With the rapid development of the Internet, network devices are increasing in number. Therefore, the management of network devices is becoming increasingly important. The Simple Network Management Protocol (SNMP) defines a unified interface and protocol for network devices, allowing network management devices to manage network devices using a unified standard.
[0003] Currently, network management devices can send access requests to network devices based on SNMP, allowing the network devices to retrieve the required data from their cache and return it to the network management device. However, this approach may not meet the needs of data with high timeliness requirements. For data that is updated quickly, the data read from the cache by the network device may not be the latest data, resulting in large data errors.
[0004] Therefore, it is hoped to provide a data access method to meet the timeliness requirements of data and thus reduce errors. Summary of the Invention
[0005] The present application provides a data access method and device to meet the timeliness requirements of data and reduce data errors.
[0006] On the first aspect, the present application provides a data access method, which can be executed by a network device, or can also be executed by a component configured in the network device (such as a chip, a chip system, etc.), and the present application does not limit this.
[0007] Exemplarily, the method includes: receiving a first read request from a network management device, the first read request being used to request reading target data in the network device, the network device storing at least one type of data, the at least one type of data corresponding one-to-one to at least one container, each container being used to cache data of the corresponding type, and each container corresponding to a refresh duration, the effective duration of the cached data in each container being no greater than the corresponding refresh duration; determining the corresponding target container based on the type of the target data; reading the target data from the target container; and sending the target data to the network management device.
[0008] In the above technical solution, different types of data are mapped to different containers, and a refresh duration is preconfigured for each container, so that the effective duration of the data cached in the container is no longer than the refresh duration, thereby ensuring the timeliness of the data in the container and ensuring that the data obtained from the container by the network device meets the timeliness requirements, thereby effectively reducing errors.
[0009] In combination with the first aspect, in a possible implementation of the first aspect, reading the target data from the target container includes: determining whether the write duration of the cached data in the target container reaches the refresh duration; and if the write duration of the cached data does not reach the refresh duration, reading the target data from the target container; or if the write duration of the cached data reaches the refresh duration, writing all data of the type to which the target data belongs, read from the memory of the network device, into the target container, and reading the target data from the target container.
[0010] In combination with the first aspect, in a possible implementation of the first aspect, before determining whether the write duration of the cached data in the target container reaches the refresh duration, the method further includes: determining whether the cached data is stored in the target container; and determining whether the write duration of the cached data in the target container reaches the refresh duration includes: if the cached data is stored in the target container, determining whether the write duration of the cached data reaches the refresh duration.
[0011] In combination with the first aspect, in a possible implementation of the first aspect, after sending the target data to the network management device, the method further includes: clearing the cached data when the write duration of the cached data reaches the refresh duration.
[0012] In combination with the first aspect, in a possible implementation of the first aspect, the method further includes: creating a thread for one or more read requests including the first read request, the thread being used to read the target data from the target container.
[0013] In combination with the first aspect, in a possible implementation of the first aspect, the first read request includes an object identifier (OID) of the target data, the OID includes a type identifier and a data identifier, the type identifier is used to identify the type of the target data, and in the data of the same type in the network device, each data identifier corresponds to a piece of data.
[0014] In combination with the first aspect, in a possible implementation of the first aspect, determining the corresponding target container based on the type of the target data includes: determining the type of the target data based on the type identifier in the OID in the first read request; and determining the target container corresponding to the type based on a pre-stored mapping relationship between at least one type and at least one container.
[0015] In a second aspect, the present application provides a data access device, comprising a unit for implementing the method described in the first aspect and any possible implementation manner of the first aspect.
[0016] In a third aspect, the present application provides a data access device, comprising a processor coupled to a memory, and configured to execute a computer program in the memory to implement the method described in the first aspect and any possible implementation of the first aspect.
[0017] Optionally, the device in the third aspect further includes a memory.
[0018] Optionally, the apparatus in the third aspect further includes a communication interface, and the processor is coupled to the communication interface.
[0019] In a fourth aspect, the present application provides a chip system comprising at least one processor for supporting the implementation of the functions involved in the above-mentioned first aspect and any possible implementation method of the first aspect, for example, receiving or processing the data involved in the above-mentioned method.
[0020] In one possible design, the chip system further includes a memory, which is used to store program instructions and data, and the memory is located inside or outside the processor.
[0021] The chip system can be composed of chips, or can include chips and other discrete devices.
[0022] In a fifth aspect, the present application provides a computer-readable storage medium, on which a computer program (also referred to as code, or instructions) is stored. When the computer program is executed by a processor, the method in the above-mentioned first aspect and any possible implementation of the first aspect is executed.
[0023] In a sixth aspect, the present application provides a computer program product, comprising: a computer program (also referred to as code, or instructions), which, when run, enables the method in the above-mentioned first aspect and any possible implementation of the first aspect to be executed.
[0024] It should be understood that the second aspect to the sixth aspect of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation manners are similar, and will not be repeated. BRIEF DESCRIPTION OF DRAWINGS
[0025] Figure 1 is a scenario diagram suitable for the method provided by the embodiments of the present application;
[0026] Figure 2 is a schematic flow chart of the data access method provided by the embodiments of the present application;
[0027] Figure 3 is a schematic diagram of the relationship between the container and the thread provided by the embodiments of the present application;
[0028] Figure 4 is a flow diagram of the network device reading target data from a target container provided by the embodiments of the present application;
[0029] Figure 5 is a schematic block diagram of the data access device provided by the embodiments of the present application;
[0030] Figure 6 is another schematic block diagram of the data access device provided by the embodiments of the present application. DETAILED DESCRIPTION
[0031] The exemplary embodiments will be described in detail herein with reference to the drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of apparatuses and methods consistent with some aspects of the present application as detailed in the appended claims.
[0032] In order to better understand the data access method provided by the embodiments of the present application, first, the terms involved in the present application are briefly described.
[0033] 1. SNMP: a simple network management protocol for network device management, which belongs to an application layer protocol. SNMP can define a unified interface and protocol for different types of devices, devices produced by different manufacturers, and devices of different models, so that administrators can manage network devices located in different physical spaces through a network, thereby greatly improving the management efficiency of network devices.
[0034] 2. Network Management System (NMS): Also known as a management station, it can be responsible for issuing network management commands, data storage, and data analysis. The NMS is the initiator of network management operations. In this application, the NMS can be deployed on a network management device, for example, on a server, which can perform management tasks on network devices. An SNMP agent runs on each monitored network device to enable communication between the network device and the network management device. Therefore, the interaction between the network management device and the network device described below can be regarded as the interaction between the NMS and the SNMP agent. The following describes the data access method provided by this application from the perspective of the interaction between the network management device and the network device.
[0035] 3. Management Information Base (MIB): NM devices and network devices interface with each other through the MIB. The MIB defines the managed data in network devices. Both the NM device and the network device define corresponding MIB data, allowing each to identify the other's data and achieve communication. The NM device requests the data defined in the MIB from the network device. After the network device identifies the data, it converts the requested data into the format defined by the MIB and sends it to the NM device, completing a management operation. The MIB stores the correspondence between data and OIDs.
[0036] In this application, the OID of data includes a type identifier and a data identifier. The type identifier is used to identify the type of data, and the data identifier is used to identify different data within the same type. Each data identifier corresponds to a piece of data. For example, the data identifier can be an identifier generated based on a key-value pair of the data.
[0037] 4. Vector: A sequence container that encapsulates a dynamically sized array. Like any other type of container, it can store objects of various types. In the embodiments of this application, the containers described below may be, for example, vectors, each of which corresponds to a single type of data.
[0038] To facilitate understanding of the data access method provided in the embodiments of the present application, the application scenarios of the data access method provided in the embodiments of the present application are described below. It is understood that the application scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application.
[0039] Figure 1 This is a schematic diagram of a scenario applicable to the method provided in the embodiment of this application. Figure 1As shown, the network management device 110 can communicate with network devices such as the switch 120 and the router 130 based on SNMP, thereby realizing the management of the network devices. It should be noted that the above-mentioned switch 120 and router 130 both support the SNMP function. In addition, the network devices mentioned in the embodiments of the present application may refer to network devices that support the SNMP function. For example, if the network management device 110 needs to obtain data from the switch 120, it can send a request to the switch 120. After receiving the above-mentioned request, the switch 120 returns the data to the network management device 110, so that the network management device 110 obtains the required data.
[0040] It should be understood that Figure 1 The network devices shown are merely examples, and the present embodiments do not limit the number or type of network devices. For example, network devices may include bridges, wireless access points, or hubs. Another example is a computer that supports SNMP. In other words, any device that supports SNMP will suffice. Furthermore, network management device 110 may be, for example, a server that manages network devices.
[0041] Currently, a known technique involves a network management device sending a read request to a network device when it needs to obtain data. The network device then receives the read request. Furthermore, the network device searches a cache for the data it needs to find. If the data exists in the cache, the network device sends the data to the network management device. It is understandable that for data with high timeliness requirements, i.e., data that is updated in real time, the data in the cache may not be the most recently updated data. In other words, the data obtained from the cache using the above method is not the latest data, and therefore, the timeliness requirements of the data cannot be met.
[0042] Therefore, this application provides a data access method that maps different types of data to different containers and preconfigures a refresh time for each container, ensuring that the effective duration of the data cached in the container is no longer than the refresh time. A network device reads the target data from the target container corresponding to the target data type and returns it to the network management device. This ensures that the data obtained by the network management device meets the timeliness requirements, thereby reducing errors.
[0043] The data access method provided by the embodiment of the present application will be described in detail below with reference to the accompanying drawings. It should be understood that the embodiment shown below describes the method from the perspective of the interaction between the network management device and the network device. It should also be understood that although the embodiment shown below describes the interaction between the network management device and the network device as an example, it should not constitute any limitation on the execution subject of the method. As long as the program that records the code of the method provided by the embodiment of the present application can be run, the method provided by the embodiment of the present application can be executed. For example, the network device can also be replaced by a component configured in the network device (such as a chip, a chip system, etc.), or other functional modules that can call and execute a program. The embodiment of the present application does not limit this.
[0044] Figure 2 This is a schematic flow chart of the data access method provided in the embodiment of the present application. Figure 2 The data access method 200 shown may include steps 210 to 240. Each step in the method 200 is described in detail below.
[0045] In step 210, the network management device sends a first read request to the network device. Correspondingly, the network device receives the first read request from the network management device.
[0046] The above-mentioned network device stores at least one type of data, and the at least one type of data corresponds one-to-one to at least one container. Each container is used to cache data of the corresponding type, and each container corresponds to a refresh duration. The effective duration of the cached data in each container is no longer than the corresponding refresh duration. In an embodiment of the present application, there can be one or more network management devices. Each network management device can send one or more read requests. Therefore, the network device may receive one or more read requests. In the case where the network device receives multiple read requests, the multiple read requests may come from different network management devices or from the same network management device, and the embodiment of the present application is not limited to this.
[0047] Exemplarily, the data stored in the aforementioned network device includes routing data and device information data. Routing data may be, for example, a routing table, and device information data may be, for example, relevant information about the device. Routing data corresponds to a container, designated as the first container, for caching routing data, and device information data corresponds to a container, designated as the second container, for caching device information-related data. Furthermore, the first container and the second container each correspond to a refresh duration, and the effective duration of the cached data in each container is no longer than the corresponding refresh duration. The effective duration of the cached data begins when the data is written to the container.
[0048] Optionally, the network device may create a thread for one or more read requests including the first read request, where the thread is used to read target data from the target container.
[0049] Among them, the one or more read requests including the first read request are read requests from the same network management device and are read requests for the same target data. The network device can create a thread for the one or more read requests. Therefore, after receiving the first read request, the network device first determines whether to create a thread for the first read request. For example, the Agent in the network device can determine whether a thread has been created for the first read request. If the network device has already created a thread for a read request other than the first read request among the one or more read requests, the first read request can reuse the above thread, that is, the target data can be obtained by reusing the already created thread. If the network device has not created a thread for a read request other than the first read request among the one or more read requests, a new thread is created for the first read request.
[0050] One possible implementation is that the network device can determine whether to create a thread for the first read request based on the Internet Protocol (IP) address of the message carrying the first read request. Specifically, after receiving the message carrying the first read request, the network device determines the IP address of the message. If a thread corresponding to the IP address already exists among multiple threads, there is no need to create a new thread. In other words, the network device has already created threads for one or more read requests, including the first read request, and the network device can obtain the target data by reusing the already created threads. If a thread corresponding to the IP address does not exist among the multiple threads, a new thread is created for the first read request.
[0051] It should be understood that the network device may also create different threads for read requests from different network management devices. For example, if network management device 1 and network management device 2 send read request 1 and read request 2 to the network device respectively, the network device may create thread 1 and thread 2 for the read request 1 and read request 2 respectively.
[0052] In step 220 , the network device determines a corresponding target container based on the type of the target data.
[0053] As previously mentioned, at least one type of data corresponds to at least one container. This mapping relationship between the at least one type of data and the at least one container can be pre-stored in the network device. Upon receiving a first read request, the network device can determine the corresponding target container based on the aforementioned mapping relationship and the type of the target data to be read in the first read request.
[0054] Exemplarily, the network device parses the first read request and determines the type of the target data to be read. For example, if the target data is device information data, the network device can determine the target container corresponding to the target data, which contains the target data. In other words, the network device can read the target data from the target container.
[0055] Optionally, the first read request may include the OID of the target data, so as to determine the target container corresponding to the target data.
[0056] The OID includes a type identifier and a data identifier. The type identifier is used to identify the type of target data. For data of the same type in the network device, each data identifier corresponds to a piece of data. For example, the data identifier can be an identifier generated based on a key-value pair of the data.
[0057] The network device may determine the type of the target data based on the type identifier in the OID in the first read request, and determine the target container corresponding to the type based on a pre-stored mapping relationship between at least one type and at least one container.
[0058] Exemplarily, the MIB of the network device stores a correspondence between OIDs and data types, as well as a mapping between data types and containers. After receiving the first read request, the network device determines the data type corresponding to the type identifier from the MIB based on the type identifier in the OID carried in the first read request. Furthermore, based on a pre-stored mapping between data types and containers, the network device determines the target container corresponding to the target data, thereby facilitating reading the target data from the target container.
[0059] Optionally, the above-mentioned first read request can be a read (get) request or a read next (getnext) request. It should be understood that the network device can also receive other types of requests from the network management device. For example, it can receive write requests from the network management device, such as configuration (set) requests, which are not limited in this embodiment of the present application. Among them, the get request is sent by the network management device to the network device, and is used by the network management device to extract a piece of data from the network device; the getnext request is sent by the network management device to the network device, and is used by the network management device to extract the next data following the current data from the network device; the set request is sent by the network management device to the network device, and is used to set one or more data of the network device, so the network management device can use the set request to remotely set the data of the network device.
[0060] Figure 3 This is a diagram showing the relationship between containers and threads provided in the embodiment of the present application. Figure 3As shown, the network device receives multiple read requests, each corresponding to a thread, such as threads 1 to n shown in the figure. The network device includes multiple containers, such as containers 1 to m. The data types in the multiple read requests correspond to container 2, that is, the network device needs to read data from container 2. Here, n and m are both positive integers. The size of m depends on the number of data types in the network device, and each type of data corresponds to a container. It should be understood that the multiple threads can also access different containers, such as thread 1 accessing container 1, threads 2 and 3 accessing container 2, etc., and this embodiment of the present application is not limited to this.
[0061] In step 230 , the network device reads the target data from the target container.
[0062] After the network device determines the target container, it reads the target data from the target container so as to send it to the network management device.
[0063] One possible implementation method is that the network device determines whether the write duration of the cached data in the target container reaches the refresh duration. In the case that the write duration of the cached data does not reach the refresh duration, the network device can directly read the target data from the target container; in the case that the write duration of the cached data reaches the refresh duration, the network device can write all data of the type of the target data read from the memory into the target container, and read the target data from the target container. Among them, the write duration of the cached data reaches the refresh duration means that the write duration of the cached data is greater than or equal to the refresh duration, and the write duration of the cached data does not reach the refresh duration means that the write duration of the cached data is less than the refresh duration.
[0064] It should be noted that the network device determining whether the write duration of the cached data in the target container reaches the refresh duration can also be replaced by the network device determining whether the write duration of the cached data in the target container exceeds the refresh duration. Moreover, in the case where the write duration of the cached data does not exceed the refresh duration, the network device can directly read the target data from the target container; in the case where the write duration of the cached data exceeds the refresh duration, the network device can write all data of the type to which the target data read from the memory belongs to the target container, and read the target data from the target container. Among them, the write duration exceeds the refresh duration means that the write duration is greater than the refresh duration, and the write duration does not exceed the refresh duration means that the write duration is less than or equal to the refresh duration.
[0065] As mentioned above, for each read request, there is a corresponding thread to perform corresponding processing. In this embodiment, the step of reading the target data can be specifically implemented by the thread corresponding to the read request.
[0066] It can be understood that the valid time length of the cached data in the target container is not greater than the refresh time length, and in the case that the write time length of the cached data reaches the refresh time length, the data of the target container needs to be updated. In addition, in the case that the write time length of the cached data reaches the refresh time length, the network device writes all data of the type to which the target data belongs in the memory of the network device into the target container, so that the newly written data will cover the data in the original target container, that is, the data with the write time length exceeding the valid time length is refreshed.
[0067] Exemplarily, all data of the type to which the target data belongs in the memory of the network device is written into the target container to ensure the timeliness of the data read by the network device from the target container. For example, the data type of the target data is routing data, and in the case that the write time length of the cached data reaches the refresh time length, the network device writes all routing data in the memory into the target container so as to obtain the target data from the target container.
[0068] It should be understood that in the above process, the network device writes all data of the type to which the target data belongs into the target container only as an example, and the network device can also read the target data from the memory and write the target data into the target container to read the target data from the target container. Wherein, writing all data of the type to which the target data belongs into the target container can make other threads read the same type of data without writing the data of the type again, avoiding frequent writing of data into the target container.
[0069] Optionally, before determining whether the write time length of the cached data in the target container reaches the refresh time length, the method further comprises: determining whether the target container stores the cached data; and accordingly, determining whether the write time length of the cached data in the target container exceeds the refresh time length, which can specifically comprise: in the case that the target container stores the cached data, determining whether the write time length of the cached data reaches the refresh time length.
[0070] It can be understood that the network device can also determine whether the target container stores the cached data, and if the target container stores the cached data, further determine whether the write time length of the cached data reaches the refresh time length, and if the target container does not store the cached data, directly write all data of the type to which the target data belongs into the target container.
[0071] In step 240, the network device sends the target data to the network management device. Accordingly, the network management device receives the target data from the network device.
[0072] After the network device reads the target data from the target container, the network device packages the target data and sends the data packet to the network management device, and then the network management device obtains the target data.
[0073] Optionally, after sending the target data to the network management device, the method further includes: the network device clearing the cached data when the write duration of the cached data reaches the refresh duration.
[0074] After the network device sends the target data, if the write time of the cached data reaches the refresh time, the cached data is cleared, which helps to reduce the memory usage of the target container and reduce memory overhead.
[0075] In one possible implementation, the network device determines whether the write duration of the cached data has reached the refresh duration. If so, the network device clears the cached data in the target container; if not, the network device terminates the first read request.
[0076] In another possible implementation, the network device can determine whether to clear the target container based on the number of read threads and the OID corresponding to the target data. It will be appreciated that the OID includes a type identifier and a data identifier. While the type identifiers in the target container are identical, different data can be distinguished based on the data identifiers. Each piece of data corresponds to a data identifier.
[0077] Exemplarily, when the number of read threads is 0 and the OID of the target data is the last OID in the target container, the network device clears the cached data in the target container. The OID of the target data being the last OID in the target container refers to whether, with respect to the data identifier portion of the OID, the data identifier corresponding to the target data is the last of multiple data identifiers in the target container.
[0078] Figure 4 This is an example of a network device providing an embodiment of the present application reading target data from a target container.
[0079] like Figure 4 As shown, in step 410, the network device determines whether cached data is stored in the target container.
[0080] After determining the target container, the network device further determines whether cached data is stored in the target container. For example, the determination of whether cached data is stored in the target container is based on the amount of data in the target container. If the amount of data in the target container is 0, the network device determines that no cached data is stored in the target container. If the amount of data in the target container is not 0, the network device determines that cached data is stored in the target container.
[0081] If the network device determines that cached data is stored in the target container, it executes step 420 to determine whether the write duration of the cached data in the target container reaches the refresh duration; if it determines that no cached data is stored in the target container, it executes step 430.
[0082] In step 420 , the network device determines whether the write duration of the cached data in the target container reaches the refresh duration.
[0083] If the writing time of the data in the target container reaches the refresh time, the network device executes step 430 ; if the writing time of the data in the target container does not reach the refresh time, the network device executes step 440 .
[0084] In step 430 , the network device writes all data of the type to which the target data belongs into the target container and updates the time of writing the data.
[0085] It is understood that before writing all data of the target data type into the target container, the network device may add a write lock to the data so that other threads cannot write to the data at the same time. In addition, after writing the data into the target container, the network device releases the write lock.
[0086] In step 440 , the network device increases the read thread count by one.
[0087] If cached data is stored in the target container and the write duration of the cached data has not reached the refresh duration, the network device increases the read thread count by 1 and reads the target data. It should be understood that the network device can also add a read lock to the data to facilitate reading the target data.
[0088] In step 450 , the network device reads the target data from the target container.
[0089] After adding 1 to the read thread count, the network device reads the target data from the target container.
[0090] In step 460, the network device sends the target data to the network management device.
[0091] After the network device reads the target data, it packages the target data and sends it to the network management device. At the same time, the reading thread count is reduced by 1.
[0092] In step 470, the network device determines whether the OID of the target data is the last OID in the target container. If so, step 480 is executed to determine whether the read thread count is 0; if not, the read request is terminated.
[0093] In step 480 , the network device determines whether the read thread count is zero.
[0094] If so, the network device executes step 490 to clear the data in the target container. If not, the read request is terminated. Before clearing the data in the target container, the network device may apply a write lock to prevent other threads from performing write operations on the data. Furthermore, after clearing the data in the target container, the network device releases the write lock.
[0095] It is understood that if the type of request received by the network device from the network management device is a set request, the network device will add a write lock, configure the data in the network device's memory, and update it to the target container. In addition, after updating the target data to the target container, the network device releases the write lock.
[0096] It should be noted that Figure 4 The method shown is only exemplary. In actual application scenarios, the network device may also include more or fewer steps to read the target data from the target container. As long as the target data is read from the target container, the embodiment of the present application does not limit this. Figure 4 The order of steps shown in is only an example. In some embodiments, Figure 4 The steps of the method shown can also have other orders. For example, step 470 and step 480 can be exchanged in order.
[0097] Based on the above technical solution, by mapping different types of data to different containers and pre-configuring a refresh period for each container, the effective period of the data cached in the container is no longer than the refresh period, thereby ensuring the timeliness of the data in the container and ensuring that the data obtained from the container by the network device meets the timeliness requirements, thereby effectively reducing data errors.
[0098] The following will be combined Figure 5 and Figure 6 The data access device provided in the embodiment of the present application is described in detail.
[0099] Figure 5 Schematic block diagram of the data access device 500 provided in the embodiment of the present application. Figure 5 As shown, the device 500 may include: a transceiver unit 510 and a processing unit 520. Each unit in the device 500 may be used to implement Figures 2 to 4 The method described in any one of the embodiments shown.
[0100] For example, when the apparatus 500 is used to implement Figure 2When the network device functions in the method 200 shown, the transceiver unit 510 can be used to receive a first read request from the network management device, where the first read request is used to request to read the target data in the network device, where the network device stores at least one type of data, and the at least one type of data corresponds one-to-one to at least one container, each container is used to cache data of the corresponding type, and each container corresponds to a refresh duration, and the effective duration of the cached data in each container is no greater than the corresponding refresh duration; the processing unit 520 can be used to determine the corresponding target container based on the type of the target data, and read the target data from the target container; the transceiver unit 510 is also used to send the target data to the network management device.
[0101] Optionally, the processing unit 520 is specifically configured to determine whether the write duration of the cached data in the target container reaches the refresh duration; and if the write duration of the cached data does not reach the refresh duration, read the target data from the target container; or if the write duration of the cached data reaches the refresh duration, write all data of the type of the target data read from the memory of the network device into the target container, and read the target data from the target container.
[0102] Optionally, the processing unit 520 is further configured to determine whether the cached data is stored in the target container; and determining whether the write duration of the cached data in the target container reaches the refresh duration, including: when the cached data is stored in the target container, determining whether the write duration of the cached data reaches the refresh duration.
[0103] Optionally, the processing unit 520 is further configured to clear the cache data when the write duration of the cache data reaches the refresh duration.
[0104] Optionally, the processing unit 520 is further configured to create a thread for one or more read requests including the first read request, where the thread is used to read the target data from the target container.
[0105] Optionally, the first read request includes the OID of the target data, the OID includes a type identifier and a data identifier, the type identifier is used to identify the type of the target data, and in the data of the same type in the network device, each data identifier corresponds to a piece of data.
[0106] Optionally, the processing unit 520 is specifically configured to determine the type of the target data based on the type identifier in the OID in the first read request; determine the target container corresponding to the type based on a pre-stored mapping relationship between at least one type and at least one container;
[0107] It should be understood that the division of units in the embodiments of the present application is illustrative and is merely a logical functional division. In actual implementation, other division methods may be used. Furthermore, the functional units in the various embodiments of the present application may be integrated into a single processor, or may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0108] Figure 6 This is another schematic block diagram of the data access device provided in an embodiment of the present application.
[0109] like Figure 6 As shown, the data access device 600 may include at least one processor 610 for implementing Figures 2 to 4 The method described in any one of the embodiments shown in .
[0110] For example, when the data access device 600 is used to implement Figure 2 When the network device functions in the illustrated method 200, the processor 610 may be configured to receive a first read request from a network management device, the first read request being configured to request reading target data from the network device, the network device storing at least one type of data, the at least one type of data corresponding to at least one container, each container being configured to cache data of the corresponding type, and each container being associated with a refresh duration, the effective duration of the cached data in each container being no longer than the corresponding refresh duration; determine a corresponding target container based on the type of the target data; read the target data from the target container; and send the target data to the network management device. For details, please refer to the detailed description of the method embodiment, which is not detailed here.
[0111] The data access device 600 may also include at least one memory 620, which may be used to store program instructions and / or monitoring information. The memory 620 is coupled to the processor 610. The coupling in the embodiments of the present application is an indirect coupling or communication connection between devices, units, or modules, which may be electrical, mechanical, or other forms, and is used for information exchange between the devices, units, or modules. The processor 610 may operate in conjunction with the memory 620. The processor 610 may execute program instructions stored in the memory 620. At least one of the at least one memory may be included in the processor.
[0112] The data access device 600 may also include a communication interface 630 for communicating with other devices via a transmission medium, so that the device 600 can communicate with other devices. The communication interface 630 may be, for example, a transceiver, an interface, a bus, a circuit, or a device capable of implementing transceiver functions. The processor 610 may use the communication interface 630 to send and receive data and / or information, and to implement Figures 2 to 4 The method described in any one of the embodiments shown.
[0113] The specific connection medium between the processor 610, the memory 620 and the communication interface 630 is not limited in the embodiment of the present application. Figure 6 The processor 610, the memory 620 and the communication interface 630 are connected via a bus 640. The bus 640 is connected to the Figure 6 The connections between the other components are shown in bold lines, which are only for illustration and are not intended to be limiting. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.
[0114] The present application also provides a computer program product, which includes: a computer program (also referred to as code or instruction), which, when executed, causes a computer to execute the following Figures 2 to 4 The method of any one of the embodiments shown.
[0115] The present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program (also referred to as code or instruction). When the computer program is executed, the computer executes the following Figures 2 to 4 The method of any one of the embodiments shown.
[0116] It should be understood that the processor in the embodiments of the present application can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above-mentioned method embodiment can be completed by hardware integrated logic circuits in the processor or by software instructions. The above-mentioned processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The various methods, steps, and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of the present application can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in the memory, and the processor reads the information in the memory and, in conjunction with its hardware, completes the steps of the above-mentioned method.
[0117] It should also be understood that the memory in the embodiments of the present application can be a volatile memory or a nonvolatile memory, or can include both volatile and nonvolatile memory. Among them, the nonvolatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically EPROM (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM) used as an external cache. By way of example, and not limitation, many forms of RAM can be used, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchlink DRAM (SLDRAM), and direct rambus RAM (DRAM). It should be noted that the memory of the system and method described herein is intended to include, but not be limited to, these and any other suitable types of memory.
[0118] The terms "unit", "module" and the like used in the specification can be used to represent a computer-related entity, hardware, firmware, a combination of hardware and software, software, or software in execution. The units and modules in the embodiments of the present application have the same meaning and can be used interchangeably.
[0119] Those skilled in the art will appreciate that the various illustrative logical blocks and steps described in conjunction with the embodiments disclosed herein can be implemented using electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application. In the several embodiments provided in this application, it should be understood that the disclosed devices, equipment, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not performed. In addition, the coupling or direct coupling or communication connection shown or discussed can be through some interface, indirect coupling or communication connection of devices or units, and can be electrical, mechanical, or other forms.
[0120] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0121] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0122] In the above embodiments, the functions of each functional unit can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions (programs). When the computer program instructions (program) are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated therein. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital versatile disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).
[0123] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.
[0124] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A data access method, characterized in that: include: Receive a first read request from a network management device, the first read request being used to request reading target data in the network device, the first read request including an object identifier (OID) of the target data, the OID including a type identifier and a data identifier, the type identifier being used to identify a type of the target data, each data identifier corresponding to a piece of data of the same type in the network device, the network device storing at least one type of data, the at least one type of data corresponding one-to-one to at least one container, each container being used to cache data of the corresponding type, each container corresponding to a refresh duration, and the effective duration of the cached data in each container being no greater than the corresponding refresh duration; Determining a corresponding target container based on the type of the target data; Reading the target data from the target container; Sending the target data to the network management device; The reading the target data from the target container includes: When the write duration of the cached data does not reach the refresh duration, the network device directly reads the target data from the target container; When the write duration of the cached data reaches the refresh duration, the network device writes data of the type of the target data read from the memory into the target container, and reads the target data from the target container; The write duration of the cached data reaches the refresh duration, which means that the write duration of the cached data is greater than or equal to the refresh duration; the write duration of the cached data does not reach the refresh duration, which means that the write duration of the cached data is less than the refresh duration.
2. The method according to claim 1, wherein Before determining whether the write duration of the cached data in the target container reaches the refresh duration, the method further includes: Determining whether the cached data is stored in the target container; and The determining whether the write duration of the cached data in the target container reaches the refresh duration includes: In a case where the cache data is stored in the target container, it is determined whether the write duration of the cache data reaches the refresh duration.
3. The method according to claim 2, wherein After sending the target data to the network management device, the method further includes: When the writing time of the cache data reaches the refresh time, the cache data is cleared.
4. The method according to claim 1, wherein The method further comprises: A thread is created for one or more read requests including the first read request, where the thread is used to read the target data from the target container.
5. The method according to claim 1, wherein The determining a corresponding target container based on the type of the target data includes: Determining the type of the target data based on the type identifier in the OID in the first read request; Based on a pre-stored mapping relationship between at least one type and at least one container, the target container corresponding to the type is determined.
6. A data access device, characterized in that: The method comprises means for performing the method according to any one of claims 1 to 5.
7. A data access device, characterized in that: The method comprises a processor configured to execute the method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that The invention comprises a computer program which, when being run on a computer, causes the computer to execute the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Network equipment configuration management method and device, computing equipment and storage medium
CN111416736A
Cache acceleration method and device, equipment and readable storage medium
CN113918508A