Data acquisition method and device, storage medium and electronic device
By caching frequently requested data sets in the switch, the problem of insufficient storage space in the switch is solved, and the data acquisition efficiency and storage space utilization are improved.
Patent Information
- Application Number
- CN202310264836.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-17
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2043-03-17
AI Technical Summary
In existing technologies, data occupies a large amount of storage space in switches, affecting normal functions, and existing solutions are insufficient.
One method for caching data sets in a switch is to analyze the data request time queue to determine the duration and frequency of data sets not being requested, and then cache only frequently requested data.
This reduces the storage space occupied by data in the switch, and improves data acquisition efficiency and storage space utilization.
Smart Images

Figure CN116319627B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the field of switches, and in particular, to a data acquisition method and device, a storage medium and an electronic device. BACKGROUND
[0002] In the prior art, when acquiring data of a switch, the corresponding data is collected from the switch only when a data collection request is received, or the data is collected in advance in the switch and cached in the switch, and when a data collection request is received, the data is read directly from the cached data. The first method has the problem of low reading efficiency, and the second method has the problem of occupying a large amount of storage space in the switch, and some data may not be frequently requested for acquisition, while the storage space of the switch is small and the amount of stored data is large, which may affect the normal function of the switch.
[0003] There is no effective solution to the problem of a large amount of storage space occupied by data in the switch in the related art. SUMMARY
[0004] Embodiments of the present application provide a data acquisition method and device, a storage medium and an electronic device to at least solve the problem of a large amount of storage space occupied by data in the switch in the related art.
[0005] According to an embodiment of the present application, a data acquisition method is provided, comprising: in a case where a time length during which data of a target data set in a target switch is not requested for acquisition is greater than or equal to a first threshold value, acquiring a first request parameter according to each request time in a target time queue, wherein the request time is a time of requesting the target switch to acquire data of the target data set, and the first request parameter is used to represent a frequency of requesting the target switch to acquire data of the target data set; in a case where the first request parameter and a preset reference request parameter satisfy a preset target matching condition, caching the data of the target data set in the target switch.
[0006] In one exemplary embodiment, the acquiring a first request parameter according to each request time in a target time queue comprises: acquiring a time interval between a first request time and a second request time in the target time queue, to obtain a set of time intervals, wherein each request time in the target time queue is arranged in chronological order of requesting the target switch to acquire data of the target data set, and the first request time is earlier than the second request time; and acquiring the first request parameter according to the set of time intervals.
[0007] In an example embodiment, the obtaining the first request parameter according to the set of time intervals comprises: obtaining, according to each time interval in the set of time intervals, an average difference of the each time interval as the first request parameter.
[0008] In an example embodiment, before the obtaining the first request parameter according to each request time in the target time queue, the method further comprises: obtaining a first difference value between a current detection time and a last request time in the target time queue in time sequence, wherein the current detection time is a time of detecting whether to determine to cache data of the target data set in the target switch, and the current detection time is later than the last request time; and determining that the duration for which the data of the target data set is not requested to be obtained is greater than or equal to the first threshold value in a case where the first difference value is greater than or equal to the first threshold value.
[0009] In an example embodiment, the caching the data of the target data set in the target switch comprises: calling a set of target functions corresponding to the target data set, wherein each data of the target data set has a corresponding function, and each function in the set of target functions is used to collect a plurality of data of the target data set in the target switch; and caching a calling result of each function in the set of target functions in the target switch.
[0010] In an example embodiment, after the caching the data of the target data set in the target switch, the method further comprises: obtaining a target data request at a target request time, wherein the target data request is used to request to obtain target data from the target switch, and the target data request carries a data identifier of the target data; in response to the target data request, determining a data set to which data corresponding to the data identifier of the target data belongs as the target data set; and obtaining the target data from the data of the target data set cached in the target switch.
[0011] In an example embodiment, after the obtaining the target data from the data of the target data set cached in the target switch, the method further comprises: recording the target request time in the target time queue in time sequence according to a time of requesting to obtain the data of the target data set from the target switch, wherein a last request time in the target time queue is the target request time.
[0012] According to another embodiment of the present application, a data acquisition device is provided, comprising: a first acquisition module, configured to acquire a first request parameter according to each request time in a target time queue when a time length during which data of a target data set in a target switch is not requested to be acquired is greater than or equal to a first threshold, wherein the request time is a time of requesting the target switch to acquire data of the target data set, and the first request parameter is used to represent a frequency of requesting the target switch to acquire data of the target data set; and a cache module, configured to cache data of the target data set in the target switch when the first request parameter and a preset reference request parameter satisfy a preset target matching condition.
[0013] According to still another embodiment of the present application, a computer readable storage medium is further provided, and the computer readable storage medium stores a computer program, wherein the computer program is configured to execute steps in any one of the method embodiments when running.
[0014] According to still another embodiment of the present application, an electronic device is further provided, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the computer program to execute steps in any one of the method embodiments.
[0015] According to the embodiments of the present application, when data in a data set in a switch is not requested to be acquired for a long time, whether to cache data in the data set in the switch can be determined according to historical times of requesting the switch to acquire data in the data set, and in this way, data in a data set that is frequently requested to be acquired can be cached in the switch, so that the problem that a storage space occupied by data in the switch is large can be solved, and the effect of reducing the storage space occupied by data in the switch can be achieved. BRIEF DESCRIPTION OF DRAWINGS
[0016] Figure 1 is a hardware structure block diagram of a mobile terminal of a data acquisition method according to an embodiment of the present application;
[0017] Figure 2 is a flow chart of a data acquisition method according to an embodiment of the present application;
[0018] Figure 3 is a schematic diagram of a data acquisition method according to an embodiment of the present application;
[0019] Figure 4 is a schematic diagram of a data acquisition process according to an embodiment of the present application;
[0020] Figure 5 is a structure block diagram of a data acquisition device according to an embodiment of the present application. DETAILED DESCRIPTION
[0021] Hereinafter, the embodiments of the present application will be described in detail with reference to the accompanying drawings and in conjunction with embodiments.
[0022] It should be noted that the terms "first", "second" and the like in the description and claims of the present application and the above drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence.
[0023] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking the case of running on a mobile terminal, Figure 1 is a hardware structure block diagram of a mobile terminal of a data acquisition method according to an embodiment of the present application. As shown in Figure 1 , the mobile terminal can include one or more (only one is shown in Figure 1 ) processor 102 (the processor 102 can include but not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the above-mentioned mobile terminal can also include a transmission device 106 for communication function and an input and output device 108. Those skilled in the art can understand, Figure 1 The structure shown is only schematic, which does not limit the structure of the above-mentioned mobile terminal. For example, the mobile terminal can also include more or less components than those shown in Figure 1 , or have a different configuration from Figure 1 .
[0024] The memory 104 can be used to store computer programs, such as software programs of application software and modules, such as the computer program corresponding to the data acquisition method in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implements the above-mentioned method. The memory 104 can include a high-speed random access memory, and can also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory 104 can further include a memory remotely arranged with respect to the processor 102, which can be connected to the mobile terminal through a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.
[0025] The transmission device 106 is configured to receive or send data via a network. The network can include a wireless network provided by a communication provider of the mobile terminal. In one embodiment, the transmission device 106 includes a network interface controller (NIC) that can be connected to other network devices through a base station to communicate with the Internet. In one embodiment, the transmission device 106 can be a radio frequency (RF) module that is configured to communicate with the Internet through a wireless manner.
[0026] The terms involved in the embodiments of the present application are explained as follows:
[0027] SONiC (Software for Open Networking in the Cloud): SONiC and its companion SAI (Switch Abstraction Interface) are two open source projects in the field of open cloud networking led by Microsoft in recent years. Traditional network devices are completely unable to meet the needs of cloud management platforms in the cloud computing era, such as open interface, software definition, modular construction, and rapid iteration. Microsoft led the establishment of the SONiC / SAI open source project, aiming to rebuild an open network system software based on the standard Linux kernel for the needs of Azure for network. In order to comply with the historical trend of cloud computing, software definition, and open source, Microsoft did not make this system closed and private, but operated in an open, open source, and community mode.
[0028] SNMP (Simple Network Management Protocol): There are various types of network devices, and the management interfaces (such as command line interfaces) provided by different device manufacturers are different, which makes network management more complex. To solve this problem, SNMP was born. As a widely used network management standard protocol in TCP / IP networks, SNMP provides a unified interface, thereby realizing the unified management of network devices of different types and manufacturers. SNMP is a standard protocol designed specifically for managing network nodes (servers, workstations, routers, switches) on IP networks. It is an application layer protocol. SNMP enables network administrators to manage network performance, discover and resolve network problems, and plan network growth. Network management systems receive random messages (and event reports) through SNMP to learn about network problems.
[0029] MIB (Management Information Base) in SNMP: MIB in SNMP is a tree database, the object managed by MIB is the end node of the tree, each node has a unique position and a unique name. IETF specifies that the OID (Object Identifier) uniquely specifies the management information base object identifier, and the naming rule is that the name of the parent node is prefixed to the name of the child node.
[0030] SNMP Agent: SNMP Agent is an agent process in the managed device, which is used to maintain the information data of the managed device and respond to the request from NMS (Network Management System) to report the management data to the NMS sending the request.
[0031] In the embodiment, a data acquisition method running on the mobile terminal is provided, Figure 2 is a flowchart of the data acquisition method according to the embodiment of the application, as Figure 2 shown, the flow includes the following steps:
[0032] Step S202, in the case where the time length during which the data of the target data set in the target switch is not requested to be acquired is greater than or equal to the first threshold value, the first request parameter is acquired according to each request time in the target time queue, wherein the request time is the time of requesting to acquire the data of the target data set in the target switch, and the first request parameter is used to indicate the frequency of requesting to acquire the data of the target data set in the target switch;
[0033] Step S204, in the case where the first request parameter and the preset reference request parameter satisfy the preset target matching condition, the data of the target data set in the target switch is cached.
[0034] Figure 3 is a schematic diagram of a data acquisition method according to an embodiment of the application, as Figure 3 shown, the storage space 202-1 in the target switch 202 caches the data set 1 and the time queue 1 (t1, t2, t3, t4) corresponding to the data set 1, the data set 2 and the time queue 2 (t5, t6, t7, t8) corresponding to the data set 2, and the data set 3 and the time queue 3 (t10, t11, t12, t13) corresponding to the data set 3. The data acquisition process in the embodiment of the application can be explained and described by taking the data set 3 as the target data set, which can be applied to the embodiment of the application.
[0035] In a case where the time length during which the data of the data set 3 (i.e., the target data set) in the target switch 202 is not requested to be acquired is greater than or equal to the first threshold, the first request parameter is acquired according to the request times (t10, t11, t12, t13) in the time queue 3 (i.e., the target time queue), and in a case where the first request parameter and the preset reference request parameter satisfy the preset target matching condition, the data of the data set 3 is cached in the storage space 202-1 of the target switch 202.
[0036] Through the above steps, in a case where the data in a data set in a switch is not requested to be acquired for a long time, whether the data in the data set is cached in the switch can be determined according to the historical time when the data in the data set is requested to be acquired from the switch. In this way, the data in the data set that is frequently requested to be acquired is cached in the switch, so that the problem that the storage space occupied by the data in the switch is large can be solved, and the effect of reducing the storage space occupied by the data in the switch is achieved.
[0037] The execution subject of the above steps can be a terminal or the like, but is not limited thereto.
[0038] The execution order of steps S202 and S204 can be interchanged, i.e., step S204 can be executed first, and then step S202 can be executed.
[0039] In the technical solution provided in the above step S202, the target switch can include but is not limited to a plurality of data sets. The data in the target switch can be divided into a plurality of data sets in a manner such as a type of data or data with high correlation, etc. For example, the data can be divided into a CPU-related data set, a memory-related data set, etc.
[0040] Optionally, in this embodiment, in a case where the time length during which the data of the target data set in the target switch is not requested to be acquired is greater than or equal to the first threshold, it can be indicated that the data in the target data set has not been requested to be acquired for a long time. In this case, the first request parameter indicating the frequency of requesting the data in the target data set from the target switch can be acquired, and then it is determined whether the data in the target data set is cached in the target switch.
[0041] Optionally, in this embodiment, each data set in the target switch has a corresponding time queue for recording the time when the data in the data set is requested to be acquired from the target switch. The time queue can be but is not limited to a FIFO (first in first out) queue. The maximum number of request times that can be recorded by the time queue can be but is not limited to 10, or 8, or 20, etc., which is not limited in the present application.
[0042] In an exemplary embodiment, the first request parameter can be obtained according to each request time in the target time queue, but not limited to, by: obtaining a set of time intervals between time intervals between a first request time and a second request time in the target time queue, wherein each request time in the target time queue is arranged in chronological order of time when the target switch is requested to obtain data in the target data set, and the first request time is earlier than the second request time; and obtaining the first request parameter according to the set of time intervals.
[0043] Optionally, in this embodiment, the time interval between the first request time and the second request time in the target time queue can be obtained, but not limited to, such as: for the time queue 3 (t10, t11, t12, t13) of the data set 3, the time queue 3 can be but not limited to a FIFO (first in first out) queue, that is, t10 is earlier than t11, t11 is earlier than t12, t12 is earlier than t13, and t13 is the last request time recorded in the time queue 3. In this case, the difference between t11 and t10, the difference between t12 and t11, and the difference between t13 and t12 can be obtained, but not limited to, to obtain a set of time intervals.
[0044] In an exemplary embodiment, the first request parameter can be obtained according to the set of time intervals, but not limited to, by: obtaining the average difference of each time interval in the set of time intervals as the first request parameter.
[0045] Optionally, in this embodiment, the average difference of each time interval can be obtained as the first request parameter, but not limited to, in which case, the average difference between the time intervals when the target switch is requested to obtain data in the target data set can be used to represent the frequency of requesting the target switch to obtain data in the target data set.
[0046] Optionally, in this embodiment, the average difference of the time interval can be inversely proportional to the frequency of requesting the target switch to obtain data in the target data set, that is, the larger the average difference between the request times in the target time queue, the lower the frequency of requesting the target switch to obtain data in the target data set, that is, the data in the target data set is not frequently requested to be obtained.
[0047] Optionally, in the embodiment, the first request parameter is determined to satisfy the preset target matching condition with the preset reference request parameter, but not limited to, in the case that the average difference of each time interval is less than or equal to a second threshold value (such as 30, or 20, or 10, etc., which is not limited in the application).
[0048] In an exemplary embodiment, whether the data of the target data set in the target switch is frequently requested to be acquired can be determined, but not limited to, by the following way: obtaining a first difference value between a current detection time and a last request time in the target time queue in chronological order, wherein the current detection time is the time for detecting whether the data of the target data set in the target switch is determined to be cached, and the current detection time is later than the last request time; in the case that the first difference value is greater than or equal to the first threshold value, it is determined that the data of the target data set is not requested to be acquired for a time period greater than or equal to the first threshold value.
[0049] Optionally, in the embodiment, in the case that the first difference value is greater than or equal to the first threshold value, it is determined that the data of the target data set is not requested to be acquired for a time period greater than or equal to the first threshold value, in which case it can be indicated that the data in the target data set in the target switch has not been requested to be acquired for a long time. In the case that the first difference value is less than the first threshold value, it is determined that the data of the target data set is not requested to be acquired for a time period less than the first threshold value, in which case it can be indicated that the data in the target data set in the target switch is still frequently requested to be acquired.
[0050] Optionally, in the embodiment, the process of determining whether the data of the target data set in the target switch is frequently requested to be acquired in the embodiment can be explained and described, but not limited to, by taking the data set 3 as the target data set and the time queue 3 corresponding to the data set 3 as the target time queue, which can be applied to the embodiment, but not limited to.
[0051] The time queue 3 (t10, t11, t12, t13) of the data set 3 can be, but not limited to, a FIFO (first in first out) queue, t10 is earlier than t11, t11 is earlier than t12, t12 is earlier than t13, t13 is the last request time recorded in the time queue 3, in the case that the difference (i.e. the first difference value) between the current detection time and t13 is greater than or equal to the first threshold value (which can be, but not limited to, 600s, or 700s, or 500s, etc., which is not limited in the application), it is determined that the data of the data set 3 is not requested to be acquired for a time period greater than or equal to the first threshold value.
[0052] In a case where a difference between the current detection time and t13 (i.e., a first difference) is less than a first threshold (which can be but is not limited to 600s, or 700s, or 500s, etc., and the present application does not limit this), it is determined that a duration for which data of the data set 3 is not requested to be acquired is less than the first threshold.
[0053] In the technical solution provided in step S204, in a case where the first request parameter and the preset reference request parameter satisfy a preset target matching condition, it can be indicated that data of the target data set in the target switch is frequently requested to be acquired, and in such a case, the data of the target data set can be but is not limited to pre-cached in the target switch, so that in a case where the data of the target data set is requested to be acquired, the required data can be directly read from the cached data of the target data set, and the data acquisition efficiency is improved.
[0054] Optionally, in the present embodiment, by pre-caching data of frequently requested data sets in the target switch, on one hand, caching of data of all data sets (such as data of some data sets that are not frequently accessed or even not accessed) in the target switch is avoided, and in this way, the utilization rate of the storage space in the target switch is improved. On the other hand, pre-caching of data of frequently requested data sets in the target switch can ensure that frequently requested data is frequently updated, and the update efficiency of these data is improved.
[0055] In an exemplary embodiment, the data of the target data set can be but is not limited to cached in the target switch by: calling a group of target functions corresponding to the target data set, wherein each data of the target data set has a corresponding function, and each function in the group of target functions is used to collect a plurality of data of the target data set in the target switch; and caching a calling result of each function in the group of target functions in the target switch.
[0056] Optionally, in the present embodiment, each data of the target data set can but is not limited to have a different collection manner, and the collection of each data of the target data set can be but is not limited to implemented by calling a group of update functions corresponding to the target data set, wherein each data of the target data set has a corresponding update function; and a calling result of each update function in the group of update functions can be but is not limited to cached in the target switch.
[0057] In an exemplary embodiment, the data of the target data set can be acquired in the following manner, but not limited thereto: at a target request time, a target data request is acquired, wherein the target data request is used to request the target switch to acquire target data, and the target data request carries a data identifier of the target data; in response to the target data request, a data set to which the data corresponding to the data identifier of the target data belongs is determined as the target data set; and the target data is acquired from the data of the target data set cached in the target switch.
[0058] Optionally, in the embodiment, in the case that the target data request is acquired at the target request time, it can be indicated that the target data is expected to be requested from the target switch, and in this case, the data set to which the data corresponding to the data identifier of the target data belongs can be determined as the target data set in response to the target data request, and the target data can be acquired from the data of the target data set cached in the target switch. In this way, the target data expected to be acquired can be directly read from the data of the target data set pre-cached in the target switch, and real-time collection of the data expected to be acquired is avoided in the case that the target data request is acquired, so that the data acquisition efficiency is greatly improved.
[0059] In an exemplary embodiment, the target request time can be recorded in the target time queue in the following manner, but not limited thereto: the target request time is recorded in the target time queue according to the time sequence of requesting the target switch to acquire the data of the target data set, wherein the last request time in the target time queue is the target request time.
[0060] Optionally, in the embodiment, the target time queue can be a first in first out (FIFO) queue, and the target request time can be recorded in the target time queue according to the time sequence of requesting the target switch to acquire the data of the target data set. In this way, the request parameter used to represent the frequency of requesting the target switch to acquire the data of the target data set can be acquired according to the request times recorded in the target time queue in the case that it is next time to determine whether the data of the target data set is cached in the target switch.
[0061] In order to better understand the above processes of reading the data cached in the target switch and recording the request times, the data acquisition method in the embodiments of the present application is explained and described below in combination with optional embodiments, which can be applied to the embodiments of the present application, but not limited thereto.
[0062] Figure 4is a schematic diagram of a data acquisition process according to an embodiment of the present application, as shown Figure 4 The storage space 202-1 of the target switch 202 stores data of a plurality of data sets and a time queue corresponding to each data set. For example, the data set 3 is taken as a target data set, and the time queue 3 corresponding to the data set 3 is taken as a target time queue.
[0063] The time queue 3 originally records (t10, t11, t12, t13), t10 is earlier than t11, t11 is earlier than t12, and t12 is earlier than t13. The target switch 202 acquires a target data request at the target request time t14. The target data request is used to request the target switch 202 to acquire the data 3 (i.e., target data). The target data request carries the data identifier of the data 3. In this case, the switch can respond to the target data request, determine the data set 3 to which the data corresponding to the data identifier of the data 3 belongs as a target data set, acquire the data 3 from the data of the data set 3 cached in the storage space 202-1 of the target switch 202, return the acquired data 3, and record the target request time t14 in the time queue 3 according to the time sequence of the target switch 202 requesting to acquire the data of the data set 3. The last request time in the time queue 3 is the target request time t14.
[0064] In order to better understand the above process of reading data in the cache of the target switch and recording the request time, the data acquisition method in the embodiment of the present application is explained and described by taking the target switch running the SONiC (Software for Open Networking in the Cloud) system as an example, the target switch is managed by the SNMP protocol, the target switch needs to be accessed every certain period of time, and the data is periodically requested to be acquired for management. The NMS requests the target switch to acquire data, and the SNMP Agent responds to the request of the NMS and returns the data requested by the NMS. The data acquisition method in the embodiment of the present application can be applied to the embodiment of the present application. The data acquisition method in the embodiment of the present application can be implemented by the following steps:
[0065] Step 1: An mib_base class includes an update function, a time stamp FIFO queue with a length of 10, and a flag bit start_update, which is False by default, indicating that no data is collected.
[0066] Step 2: Create a class for each MIB, inherit the class in Step 1, that is, each class created in Step 2, after inheriting the class in Step 1, has the same flag bit (default False), the same length of timestamp FIFO queue, and the update function as the mib_base class generated in Step 1, and implements the update function as needed by the MIB. When the update function is called, the data required by the MIB is updated.
[0067] It should be noted that one mib corresponds to one data set (such as a memory-related data set, a CPU-related data set, etc.), each mib has a mib instance object, each mib instance object corresponds to a FIFO time queue (which is used to record the time of requesting the data corresponding to the instance object from the switch), and each mib instance object corresponds to the collection method of all data in the data set.
[0068] Step 3: A set of mib instances is used to store all mib instance objects.
[0069] Step 4: A factory is used to produce a corresponding instance object for all MIBs using the class in Step 2 according to the OID of the MIB, and add it to the set in Step 3.
[0070] Step 5: An update data thread is used to traverse the set in Step 3, create a thread for each instance MIB object, periodically check the start_update flag, and in the case of start_update flag being True, call the update function to collect data in the switch; in the case of start_update flag being False, skip the MIB instance.
[0071] Step 6: In the case that the SNMP agent in the switch (i.e. the target switch) receives a get or get_next request (i.e. the target data request described above), traverse the set in Step 3, find the corresponding MIB instance object (i.e. the target data set described above) according to the OID (i.e. the data identifier of the target data described above), and add the time of receiving the get or get_next request to the timestamp queue (i.e. the target time queue described above).
[0072] Step 7: One thread, traversing the set of step 3, periodically checks the time stamp queue in the MIB instance object, if the difference between the last request time in the time stamp queue and the current detection time is greater than 600 seconds (i.e. the first threshold value), subtracts the last item from the first item in the time stamp queue (i.e. the time interval between the first request time and the second request time in time), obtains all time intervals (i.e. a set of time intervals), then calculates the average difference, if the average difference is not greater than 30, it is considered that the MIB instance object is periodically accessed, and the start_update flag is set to True; otherwise, it is set to False. If the difference between the last request time in the time stamp queue and the current detection time is less than 600 seconds, it can be indicated that the MIB instance object is periodically accessed, and the start_update flag is set to True.
[0073] Through the above embodiment, if there is no get or get_next request for a MIB instance object within a period of time, the operation of updating the data of the MIB instance object in the switch is stopped, and the system resources of the switch are saved. In addition, the data of the data set in the switch is updated based on the MIB, a thread is created for each MIB, and when a user uses SNMP to manage a device, the user usually has targeted and periodic access to some MIBs, and other MIBs are not concerned. Based on the MIB, the data is updated, and the fine-grained allocation of switch resources is realized.
[0074] Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiment can be realized by means of software and the necessary general hardware platform, and of course it can also be realized by hardware, but in many cases the former is a better embodiment. Based on such understanding, the technical solutions of the embodiments of the present application can be embodied in the form of a software product, which is stored in a storage medium (such as a ROM / RAM, a magnetic disk, an optical disk), and includes a plurality of instructions for causing a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the method described in each embodiment of the present application.
[0075] In the present embodiment, a data acquisition device is also provided, which is used to implement the above embodiments and preferred embodiments, and will not be described again. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware, or a combination of software and hardware is also possible and contemplated.
[0076] Figure 5 is a structure block diagram of the data acquisition device according to the embodiments of the present application, as Figure 5As shown, the apparatus comprises:
[0077] The first obtaining module 502 is configured to, in a case where a time length during which data of a target data set in a target switch is not requested to be obtained is greater than or equal to a first threshold, obtain a first request parameter according to each request time in a target time queue, wherein the request time is a time of requesting to obtain data of the target data set in the target switch, and the first request parameter is used to indicate a frequency of requesting to obtain data of the target data set in the target switch.
[0078] The caching module 504 is configured to, in a case where the first request parameter and a preset reference request parameter satisfy a preset target matching condition, cache data of the target data set in the target switch.
[0079] According to the embodiments of the present application, in a case where data in a data set in a switch is not requested to be obtained for a long time, whether to cache the data in the data set in the switch can be determined according to historical times of requesting to obtain the data in the data set in the switch. In this way, the data in the data set that is frequently requested to be obtained is cached in the switch, and thus the problem that a storage space occupied by data in the switch is large can be solved, and the effect of reducing the storage space occupied by the data in the switch is achieved.
[0080] In one exemplary embodiment, the first obtaining module comprises:
[0081] The first obtaining unit is configured to obtain a time interval between a first request time and a second request time that are adjacent in time in the target time queue, to obtain a group of time intervals, wherein each request time in the target time queue is arranged in a time sequence of requesting to obtain data of the target data set in the target switch, and the first request time is earlier than the second request time.
[0082] The second obtaining unit is configured to obtain the first request parameter according to the group of time intervals.
[0083] In one exemplary embodiment, the second obtaining unit is configured to:
[0084] obtain, according to each time interval in the group of time intervals, an average difference of the each time interval as the first request parameter.
[0085] In one exemplary embodiment, the apparatus further comprises:
[0086] The second obtaining module is configured to, before the first request parameter is obtained according to each request time in the target time queue, obtain a first difference value between a current detection time and a last request time in the target time queue in chronological order, wherein the current detection time is a time for detecting whether the target data set is cached in the target switch, and the current detection time is later than the last request time.
[0087] The first determining module is configured to, in a case where the first difference value is greater than or equal to the first threshold value, determine that the data of the target data set is not requested to be obtained for a time length greater than or equal to the first threshold value.
[0088] In an exemplary embodiment, the caching module comprises:
[0089] The calling unit is configured to call a group of target functions corresponding to the target data set, wherein each data of the target data set has a corresponding function, and each function in the group of target functions is used to collect a plurality of data of the target data set in the target switch.
[0090] The caching unit is configured to cache a calling result of each function in the group of target functions in the target switch.
[0091] In an exemplary embodiment, the apparatus further comprises:
[0092] The third obtaining module is configured to, after the data of the target data set is cached in the target switch, obtain a target data request at a target request time, wherein the target data request is used to request the target switch to obtain target data, and the target data request carries a data identifier of the target data.
[0093] The second determining module is configured to, in response to the target data request, determine a data set to which data corresponding to the data identifier of the target data belongs as the target data set.
[0094] The fourth obtaining module is configured to obtain the target data from the data of the target data set cached in the target switch.
[0095] In an exemplary embodiment, the apparatus further comprises:
[0096] A recording module is configured to record the target request time in the target time queue according to the time sequence of the target request time after obtaining the target data from the target data set cached in the target switch.
[0097] It should be noted that the above modules can be implemented by software or hardware, and the hardware can be implemented by the following manners, but is not limited to: all the modules are located in the same processor; or the modules are located in different processors in any combination.
[0098] Embodiments of the present application also provide a computer readable storage medium, which stores a computer program, and the computer program is configured to execute the steps in any of the above method embodiments when running.
[0099] In an example embodiment, the computer readable storage medium can include, but is not limited to: a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store computer programs.
[0100] Embodiments of the present application also provide an electronic device, which includes a memory storing a computer program and a processor configured to execute the computer program to perform the steps in any of the above method embodiments.
[0101] In an example embodiment, the electronic device can further include a transmission device connected to the processor and an input / output device connected to the processor.
[0102] The specific examples in the present embodiment can refer to the examples described in the above embodiments and example embodiments, and the present embodiment will not be described here.
[0103] Obviously, those skilled in the art should understand that each module or each step of the above-mentioned embodiments of the present application can be realized by a general computing device, which can be centralized on a single computing device or distributed on a network composed of multiple computing devices, and can be realized by program codes executable by the computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in different order, or they can be respectively manufactured into each integrated circuit module, or multiple modules or steps among them can be manufactured into a single integrated circuit module. Thus, the embodiments of the present application are not limited to any specific combination of hardware and software.
[0104] The above only describes the preferred embodiments of the present application and is not intended to limit the embodiments of the present application. For those skilled in the art, the present application can have various modifications and changes. Any modification, equivalent replacement, improvement, etc. within the principles of the embodiments of the present application shall be included in the protection scope of the embodiments of the present application.
Claims
1. A data acquisition method characterized by comprising: The method comprises the following steps: In the case that the duration of the data of the target data set in the target switch not being requested to obtain is greater than or equal to a first threshold, obtaining a first request parameter according to each request time in a target time queue, wherein the request time is the time of requesting the target switch to obtain the data of the target data set, and the first request parameter is used to represent the frequency of requesting the target switch to obtain the data of the target data set; In the case that the first request parameter and a preset reference request parameter satisfy a preset target matching condition, caching the data of the target data set in the target switch; Wherein, the first request parameter is obtained according to each request time in the target time queue, comprising: obtaining the time interval between the first request time and the second request time in the target time queue, to obtain a set of time intervals, wherein each request time in the target time queue is arranged in the order of time of requesting the target switch to obtain the data of the target data set, and the first request time is earlier than the second request time; the first request parameter is obtained according to the set of time intervals.
2. The method of claim 1, wherein, The first request parameter is obtained according to the set of time intervals, comprising: According to each time interval in the set of time intervals, the average difference of each time interval is obtained as the first request parameter.
3. The method of claim 1, wherein, Before the first request parameter is obtained according to each request time in the target time queue, the method further comprises: Obtaining a first difference value between the current detection time and the last request time in the target time queue according to the time sequence, wherein the current detection time is the time of detecting whether to determine to cache the data of the target data set in the target switch, and the current detection time is later than the last request time; In the case that the first difference value is greater than or equal to the first threshold, it is determined that the duration of the data of the target data set not being requested to obtain is greater than or equal to the first threshold.
4. The method of claim 1, wherein, The data of the target data set is cached in the target switch, comprising: Calling a set of target functions corresponding to the target data set, wherein each data of the target data set has a corresponding function, and each function in the set of target functions is used to collect a plurality of data of the target data set in the target switch; The calling results of each function in the set of target functions are cached in the target switch.
5. The method of claim 1, wherein, After the data of the target data set is cached in the target switch, the method further comprises: Obtaining a target data request at a target request time, wherein the target data request is used to request the target switch to obtain target data, and the target data request carries the data identifier of the target data; In response to the target data request, the data set to which the data corresponding to the data identifier of the target data belongs is determined as the target data set; acquire the target data from data of the target data set cached in the target switch.
6. The method of claim 5, wherein, After the target data is acquired from the data of the target data set cached in the target switch, the method further comprises: record the target request time in the target time queue according to a time sequence of requesting the target switch to acquire the data of the target data set, wherein a last request time in the target time queue is the target request time.
7. An apparatus for acquiring data, characterized by comprising: comprise: The first acquisition module is configured to acquire a first request parameter according to each request time in the target time queue when a time length for which data of a target data set in a target switch is not requested to be acquired is greater than or equal to a first threshold, wherein the request time is a time of requesting the target switch to acquire the data of the target data set, and the first request parameter is used to indicate a frequency of requesting the target switch to acquire the data of the target data set. The cache module is configured to cache the data of the target data set in the target switch when the first request parameter and a preset reference request parameter satisfy a preset target matching condition. The first acquisition module comprises: a first acquisition unit configured to acquire a time interval between a first request time and a second request time that are adjacent in time in the target time queue to obtain a group of time intervals, wherein each request time in the target time queue is arranged according to a time sequence of requesting the target switch to acquire the data of the target data set, and the first request time is earlier than the second request time; and a second acquisition unit configured to acquire the first request parameter according to the group of time intervals.
8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, wherein the computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 6.
9. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to implement the steps of the method in any one of claims 1 to 6.
Citation Information
Patent Citations
Method and device for data exchange in virtual machine environment
CN103793330A
Asynchronous calling method and system between services
CN108259595A