A data updating method, device and switch
By setting boolean and time variables in the SNMP agent to control data update operations, the problem of resource waste in the SNMP service when there are no access requests is solved, achieving fast response and resource saving.
Patent Information
- Application Number
- CN202310920642.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-25
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-07-25
AI Technical Summary
In existing technologies, SNMP services continuously update data even when no access request is received, leading to a waste of resources.
By setting the boolean variables begin_to_update and last_get_time, the update operation of the SNMP agent can be controlled, and data updates will only be performed when a query message is received or no query message is received within a preset time.
This effectively avoids repeatedly performing data update operations when no query message is received for a long time, reducing resource waste, while ensuring the fast response mechanism of the SNMP agent.
Smart Images

Figure CN117061343B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing, specifically to a data update method, apparatus, and switch. Background Technology
[0002] SNMP (Simple Network Management Protocol) technology helps network administrators manage network devices and monitor their operational status in real time, even when the device is not physically present, in large-scale network management. Automated collection of network status information using SNMP is the most widely used method. Typically, SNMP message response time should be between a few milliseconds and several hundred milliseconds. However, if network conditions are poor or device load is high, the response time may be longer. Therefore, current community implementations do not impose any restrictions on the data update process; the SNMP service starts updating data freely and periodically upon startup, regardless of whether there are SNMP query requests. This way, the SNMP service continuously caches data after startup, ensuring data accuracy and validity, and enabling timely responses to messages.
[0003] However, with such a technical solution, continuously updating data when no access requests are received is unnecessary. Therefore, how to control SNMP service data updates and reduce resource waste remains a problem that urgently needs to be solved. Summary of the Invention
[0004] One objective of this application is to provide a data updating method to solve, or at least partially solve, the problem of resource waste caused by freely and periodically updating data in related technologies. A second objective of this application is to provide a data updating device, and a third objective is to provide a switch.
[0005] To achieve the above objectives, the technical solution of this application is as follows:
[0006] A data update method, comprising:
[0007] The first function is called to determine whether the value of the first variable is true; the first variable is used to indicate whether a data update operation should be performed, and the first variable is updated according to the second variable, which is used to indicate the time when the query message was last received; the first function is used to perform the data update operation.
[0008] If the value of the first variable is determined to be true, data is retrieved from the database to update the data cached by the network management agent; the database is used to store attribute information of the network device to which the network management agent belongs.
[0009] Optionally, the above methods also include:
[0010] Check whether the query message has been received;
[0011] If it is confirmed that the query message has been received, the value of the first variable is adjusted to true;
[0012] Set the reception time of the query message to the value of the second variable.
[0013] Optionally, the first variable may be updated based on the second variable according to the following steps:
[0014] Determine whether the second variable is a preset value;
[0015] If the second variable is the preset value, determine whether the value of the first variable is true;
[0016] If the value of the first variable is true, a second function is called to adjust the value of the first variable to false. The second function is used to adjust the value of the first variable.
[0017] Optionally, the above methods also include:
[0018] If the second variable is not the preset value, calculate the time difference between the current time and the value of the second variable;
[0019] If the time difference is greater than a first preset time threshold, the value of the first variable is adjusted to false.
[0020] Optionally, the above methods also include:
[0021] Call the third function to check the duration for which the current value of the first variable is false;
[0022] If the duration is determined to be greater than a second preset time threshold, data is retrieved from the database to perform the data update operation on the data cached by the network management agent.
[0023] Optionally, the above methods also include:
[0024] Call the third function to check the duration for which the current value of the first variable is false;
[0025] If it is determined that the duration is greater than the second preset time threshold, the value of the first variable is adjusted to true.
[0026] Optionally, the above methods also include:
[0027] If the first function determines that the value of the first variable is false, the data update operation is abandoned.
[0028] Call the first function again to evaluate the value of the first variable.
[0029] A data updating apparatus, the apparatus comprising:
[0030] The module is used to call a first function to determine whether the value of a first variable is true; the first variable is used to indicate whether a data update operation should be performed, and the first variable is updated according to a second variable, which is used to indicate the time when the query message was last received; the first function is used to perform the data update operation.
[0031] The update module is used to retrieve data from the database to update the data cached by the network management agent when the first variable is determined to be true; the database is used to store the attribute information of the network device to which the network management agent belongs.
[0032] Optionally, the above-mentioned device further includes:
[0033] The detection module is used to detect whether the query message has been received;
[0034] The first assignment module is used to adjust the value of the first variable to true when it is determined that the query message has been received;
[0035] The second assignment module is used to set the reception time of the query request message to the value of the second variable.
[0036] A switch having a network management agent deployed thereon, wherein the network management agent, when running, executes the aforementioned data update method.
[0037] The beneficial effects of this application are:
[0038] This application determines whether a first variable is true by calling a first function. The first variable indicates whether a data update operation should be performed. The first variable is updated based on a second variable, which indicates the time when the query message was last received. The first function performs the data update operation. If the first variable is determined to be true, data is retrieved from the database to update the data cached by the network management agent. The database stores attribute information of the network devices to which the network management agent belongs. In this application, the decision to perform a data update operation is based on the first variable, which is updated based on the time when the query message was last received. Therefore, this application avoids the resource waste caused by repeatedly performing update operations when no query message has been received for a long time. Attached Figure Description
[0039] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0040] Figure 1 This is a flowchart of the data update method described in one embodiment of this application;
[0041] Figure 2 This is a schematic diagram of the architecture of the data update method described in one embodiment of this application;
[0042] Figure 3 This is a partial logic diagram of the data update method described in one embodiment of this application;
[0043] Figure 4 This is a schematic diagram of the data update device described in one embodiment of this application.
[0044] Reference numerals: 400 - Data update device, 401 - Determining module, 402 - Update module. Detailed Implementation
[0045] The embodiments of this application will be described below with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of this application from the content disclosed in this specification. This application can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this application. It should be understood that the preferred embodiments are only for illustrating this application and are not intended to limit the scope of protection of this application.
[0046] The definitions are as follows:
[0047] NMS (Network Management System): NMS is the network manager, a system that uses the SNMP protocol to manage / monitor network devices, and runs on an NMS server. NMS can send requests to the SNMP agent on the device to query or modify one or more specific parameter values.
[0048] SNMP Agent: An SNMP agent is an agent process within the managed device. It maintains the device's information data and responds to request messages from the NMS, reporting management data to the NMS that sent the request. Upon receiving a request message from the NMS, the SNMP agent executes the corresponding instructions using the MIB (Management Information Base) and returns the results to the NMS. When a device malfunctions or experiences other events, it will proactively send SNMP Traps to the NMS through the SNMP agent to report changes in its current status.
[0049] MIB (Management Information Base): A database that specifies the variables maintained by managed devices. The MIB defines a series of attributes for the managed devices: object name, object status, object access permissions, and object data type, etc. The MIB can also be seen as an interface between the NMS and the SNMP agent, through which the NMS can query and set the variables maintained by the managed devices. The MIB is stored in a tree structure. Each node in the tree represents a managed object, which can be uniquely identified by a path starting from the root node; this path is called the OID.
[0050] Get operation: NMS uses this operation to retrieve one or more parameter values from the SNMP agent.
[0051] GetNext operation: NMS uses this operation to retrieve the next parameter value for one or more parameters from the SNMP agent.
[0052] In related technologies, network devices equipped with the Sonic (Software for Open Networking in the Cloud) system can provide SNMP services. Because SNMP services require a fast response mechanism, they need to return results quickly when a query request is received. To prevent exceeding the default SNMP timeout, data needs to be cached continuously. For example, a dictionary or list is maintained to store the data, and this data is continuously updated to ensure its accuracy and validity.
[0053] The data update process continues after the SNMP service starts, but if no access request is received, the update operation during this period has no actual effect. For example, when there is a 4K route on the machine, the ipRouteDest node defined in RFC1213 will continuously maintain and refresh the data stored in the dictionary. If there are no access requests for a day or a week, the memory occupied by the update operation during this period is wasted. Therefore, this application proposes to set a boolean variable to control the update operation of the SNMP agent.
[0054] Specifically, refer to Figure 1 , Figure 1 This is a flowchart of a data update method in one embodiment of this application. In one embodiment of this application, the data update method is executed by a network management agent, which includes an SNMP agent and can be regarded as a process or a module in the SNMP service.
[0055] In this embodiment, the data update method may be performed according to the following steps:
[0056] Step S101: Call the first function to determine whether the value of the first variable is true; the first variable is used to indicate whether to perform a data update operation, and the first variable is updated according to the second variable, which is used to indicate the time when the query message was last received; the first function is used to perform the data update operation.
[0057] In related technologies, the mib.py file of an SNMP agent contains a parent class MIBUpdater, which defines the update_data function to perform data update operations. SNMP agents typically use a custom update_data function to perform data update operations, which periodically retrieve data from the MIB (Management Information Base) and update it accordingly.
[0058] Specifically, in this embodiment, the first function is the `update_data` function in the SNMP agent. Calling the first function first determines whether the value of the first variable is true. The first variable is a boolean variable, which can be defined as `begin_to_update` in a parent class `MIBUpdater` in the `mib.py` file of the SNMP agent. The value of the `begin_to_update` variable includes `true` and `false`.
[0059] The value of the `begin_to_update` variable is adjusted based on the value of a second variable, which indicates the time when the query message was last received. For example, a second variable, `last_get_time`, is added to an SNMP agent to record the time when the last query message was received, and this second variable is updated based on the received query messages.
[0060] In this embodiment, before the first function performs the data update operation, it is first determined whether the value of the first variable is true, and the current periodic, spontaneous data update operation is controlled.
[0061] In one feasible implementation, specifically, the value of the first variable can be updated according to the second variable as follows:
[0062] Determine if the second variable is a preset value;
[0063] Given that the second variable is a preset value, determine whether the value of the first variable is true;
[0064] If the value of the first variable is true, the second function is called to adjust the value of the first variable to false. The second function is used to adjust the value of the first variable.
[0065] In this embodiment, the value of the second variable is divided into two cases: one is the time of the last received query message, and the other is a preset value.
[0066] The preset value can be set to 0 or other fixed values. By detecting whether the second variable is the preset value, it can be determined whether no query messages have been received within the preset time period. If the second variable is the preset value, it indicates that the time interval between the last received query message and the current time has exceeded the first preset time threshold. That is, no query messages have been received within the first preset time period.
[0067] Therefore, given that the second variable is a preset value, the value of the first variable can be obtained to further determine whether the value of the first variable is true. If the value of the first variable is true, then the second function adjusts the value of the first variable to false. It can be understood that if the second variable is a preset value at this point, and the value of the first variable is false, then there is no need to adjust the value of the first variable further.
[0068] In practical applications, the second function can be set to `re_to_update`, or other assignable functions, to check whether the preset conditions are met. If the preset conditions are met, the value of the first variable is adjusted. The preset conditions may include at least one of the following: the time during which no query message has been received exceeds a first preset time threshold, a query message has been received, or the second variable is a preset value.
[0069] In this embodiment, since the second variable is assigned a value based on the time of the last received query message, after updating the value of the first variable based on the second variable, the first function determines whether to perform a data update operation by determining the value of the first variable, which can avoid performing useless data update operations for a long time.
[0070] Optionally, this embodiment also includes the following steps:
[0071] If the second variable is not a preset value, calculate the time difference between the current time and the value of the second variable; if the time difference is greater than the first preset time threshold, adjust the value of the first variable to false.
[0072] Specifically, if the second variable is not a preset value (i.e., its value is the time of the last received query message), then the time difference between the current time and the value of the second variable is calculated based on the current time and the time recorded by the second variable. This time difference represents the time during which no query message has been received. If this time difference is greater than a first preset time threshold, it indicates that no query message has been received for a long time, and the data update operation should be stopped. Therefore, if the time difference is greater than the first preset time threshold, the value of the first variable is set to false.
[0073] Next, after the first function determines that the value of the first variable is true, step S102 can be executed.
[0074] Step S102: If the value of the first variable is determined to be true, data is retrieved from the database to update the data cached by the network management agent; the database is used to store attribute information of the network device to which the network management agent belongs.
[0075] Specifically, if the value of the first variable `begin_to_update` is true at this point, it means that the data update operation can continue. The first function retrieves data from the database and updates the data cached by the network management agent. The database includes the Management Information Base (MIB), which stores variables maintained by the managed device (the network device to which the network management agent belongs), defining a series of attributes of the managed device (the network device to which the network management agent belongs), such as the object's name, object status, object access permissions, and object data type.
[0076] In this embodiment, a first function is called to determine whether the value of a first variable is true. The first variable indicates whether a data update operation should be performed. The first variable is updated based on a second variable, which indicates the time when the query message was last received. The first function is used to perform the data update operation. If the value of the first variable is determined to be true, data is retrieved from the database to update the data cached by the network management agent. The database stores the attribute information of the network devices to which the network management agent belongs. This application changes the original method of freely updating data by setting a first variable to control whether a data update operation is performed. Furthermore, the first variable is adjusted based on the second variable, which indicates the time when the query message was last received. Based on the time the query message was received, the decision to perform a data update operation is further determined without hindering the original process. This ensures the normal response of the SNMP service while avoiding resource waste caused by repeatedly performing update operations when no query message is received for a long time.
[0077] Reference Figure 2 , Figure 2 This is a schematic diagram of the architecture of a data processing method in one embodiment of this application. Figure 2 The network management system is an NMS (Network Management System), and the managed devices are network devices such as switches. Each managed device has a network management agent. When the network management agent receives a query message from the network management system, it can retrieve data from its cache using Get and GetNext operations. The data cached in the network management agent's cache is updated to be correct data by continuously retrieving data from the management information base using the update_data function. In this embodiment, the data update method can be executed as follows:
[0078] Step S201: Check whether a query message has been received.
[0079] Specifically, in this embodiment, the NMS (Network Management System) sends query messages to the network devices to which the network management agent belongs. Optionally, the network management agent can determine from the message queue whether a new query message has been received, or when a query message is received, set a trigger event to perform the next operation based on the received query message.
[0080] Step S202: If it is determined that a query message has been received, the value of the first variable is adjusted to true.
[0081] Specifically, in related technologies, the network management agent, by continuously updating the data in the cache, can quickly retrieve the correct information from the cache and return it to the NMS (Network Management System). In this embodiment, if a query message is received, it indicates that the packet transmission is in an active phase. To ensure the network management agent's rapid response mechanism, the data in the cache should be updated promptly. Therefore, upon receiving a query message, if the value of the first variable is false, the value of the first variable is adjusted to true; if the value of the first variable is true, no adjustment is needed. It can be understood that, upon receiving a query message, the time difference between the value of the second variable and the current time is less than a first preset time threshold; therefore, there is no need to repeatedly adjust the value of the first variable, and step S203 is then executed.
[0082] Step S203: Set the reception time of the query message to the value of the second variable.
[0083] Specifically, after receiving a query message, the reception time of the latest received query message is set as the value of the second variable. That is, the value of the second variable is updated immediately after each new query message is received.
[0084] Step S204: Call the first function to determine whether the value of the first variable is true; the first variable is used to indicate whether to perform a data update operation, and the first variable is updated according to the second variable, which is used to indicate the time when the query message was last received; the first function is used to perform the data update operation.
[0085] If the first variable is determined to be true, proceed to step S205; if the first variable is determined to be false, proceed to step S206.
[0086] Specifically, step S204 can refer to step S101 in the above embodiment, and will not be repeated here.
[0087] Step S205: If the first variable is determined to be true, data is retrieved from the database to update the data cached by the network management agent; the database is used to store attribute information of the network device to which the network management agent belongs.
[0088] Specifically, step S205 can refer to step S102 in the above embodiment, and will not be repeated here. The attribute information of the network device is generally the data requested and returned by the NMS (Network Management System) so as to manage the managed device based on this data.
[0089] Step S206: If the first function determines that the value of the first variable is false, abandon the data update operation; call the first function again to judge the value of the first variable.
[0090] Specifically, if the value of the first variable is false, it indicates that no query message has been received for a long time. Therefore, the data update operation should be stopped to avoid wasting resources. In step S206, the first function is made to abandon the repeated execution of the data update operation, eliminating the need to repeatedly initialize and call the first function. Before performing a data update, the first function first checks the value of the first variable. If the conditions for continuing the data update operation are met, the data update operation is executed. If the conditions for continuing the data update operation are not met, the check of the value of the first variable is repeated. In this way, control over the data update operation is achieved.
[0091] For example, in `MIBUpdater`, the variable `self.begin_to_update` is defined with a value of `False`. Each node's subclass `SUBupdater` inherits from the parent class `MIBUpdater`. The `update_data` function of the subclass `SUBupdater` first checks if `begin_to_update` is `True`. If it is, nothing is done, and the `update_data` function performs the data update operation normally. If it is `False`, it simply returns. In this way, when no request is received, the default value of `begin_to_update` is `False`. Then, each node's `SUBupdater` performs an update, first checking if it is `False`, and then returning directly. This avoids a looping data update operation when the SNMP service starts.
[0092] In this embodiment, the original periodic start function of the first function is still used, but before performing the data update operation, the value of the first variable is checked to see if it is true. This can reduce the waste of update operation and ensure the fast response mechanism of the SNMP agent.
[0093] In related technologies, if network conditions are poor or network device load is too high, the SNMP agent's message response time may be longer. Generally, the default timeout for an SNMP agent is 6 seconds; exceeding this default time will result in a "No response," and theoretically, this possibility exists. In a feasible implementation, to further ensure the SNMP agent's fast response mechanism, the aforementioned data update method also includes the following steps:
[0094] Call the third function to check the duration for which the current value of the first variable is false;
[0095] If the duration is determined to be greater than a second preset time threshold, data is retrieved from the database to perform the update operation on the data cached by the SNMP agent.
[0096] Specifically, the second preset time threshold should exceed the first preset time threshold. Assume the first preset time threshold is 10 minutes, and the second preset threshold is 24 hours. The third function is called to detect the duration for which the current value of the first variable is false. This duration can be obtained by calculating the time interval between the current time and the last time the value of the first variable was adjusted to zero.
[0097] If the value of the first variable remains false, and the time since the value of the first variable has been false has exceeded the second preset time threshold, there will be a large amount of new / changed data in the management information database during this period (e.g., one month or longer). If a query message is suddenly received at this time, it will take more time to retrieve data from the management information database, update the data in the cache, and then respond to the query message and return data to the NMS (Network Management System), which will affect the speed of the response message.
[0098] Therefore, to prevent this problem, a second preset time threshold is set. If the duration for which the value of the first variable is determined to be false exceeds the second preset time threshold, a data update operation is directly performed to retrieve data from the database and update the data cached by the SNMP agent. By determining the duration for which the value of the first variable is false and performing a data update operation directly when the duration exceeds the second preset time threshold, the changed or added data in the management information database within the second preset time is cached first, which reduces the time of the next data update operation and enables a faster response to query messages.
[0099] Alternatively, in another feasible implementation, to ensure the rapid response mechanism of the SNMP agent, the above data update method also needs to perform the following steps:
[0100] Call the third function to check the duration for which the current value of the first variable is false;
[0101] If the duration is determined to be greater than the second preset time threshold, the value of the first variable is adjusted to true.
[0102] In this embodiment, the third function is used to control the execution of a data update operation when the duration of the current value of the first variable being false exceeds a second preset time threshold. By first adjusting the value of the first variable to true when the duration is determined to be greater than the second preset time threshold, and then calling the first function, the data update operation can continue to be executed based on the current value of the first variable being true. This avoids the problem of too much data needing to be updated and the data update operation taking too long to complete, which affects the speed of responding to query messages, and is conducive to fast response to query messages.
[0103] In one embodiment of this application, reference is made to Figure 3 , Figure 3 This is a partial logic diagram of the data update method in one embodiment of this application. In the SNMP agent, a boolean variable `begin_to_update` (i.e., the first variable) is set to indicate whether data updating has started, and a variable `last_get_time` (i.e., the second variable) is used to store the time when the last query message was received. Two additional functions are added to the SNMP agent: the `reset_begin_to_update` function, used to calculate the time since the last SNMP query message was received; and the second function, used to assign a value to the `begin_to_update` variable based on the current time since the last query message was received and the currently received query message. The default value of the second variable is 0, and the first default time threshold is 10 minutes.
[0104] In this embodiment, in one feasible implementation method, after the device enables the SNMP service, the following steps are performed:
[0105] Step S301: Received a query message.
[0106] Step S302: Enable the second function to detect whether the value of the begin_to_update variable is false.
[0107] If the value of the begin_to_update variable is true, proceed to step S304; if the value of the begin_to_update variable is false, proceed to step S303.
[0108] Step S303: Set the value of the begin_to_update variable to true.
[0109] Step S304: Set the value of the last_get_time variable to the time when the query message was received.
[0110] Step S305: Initiate the data update operation within the node.
[0111] Step S306: Determine whether the value of the begin_to_update variable is true.
[0112] If the value of the begin_to_update variable is true, proceed to step S307; if the value of the begin_to_update variable is false, proceed to step S308.
[0113] Step S307: Continue performing the data update operation. After completion, jump to the next node and execute step S305.
[0114] Step S308, return to the previous step, and jump to step S305.
[0115] In a feasible second implementation method, after the device enables the SNMP service, the following steps are performed:
[0116] Step S401: Enable the reset_begin_to_update function.
[0117] Step S402: Determine whether the value of the last_get_time variable is 0.
[0118] If the value of the last_get_time variable is 0, proceed to step S404; if the value of the last_get_time variable is not 0, proceed to step S403.
[0119] Step S403: Determine whether the value of the begin_to_update variable is true.
[0120] If the value of the begin_to_update variable is determined to be true, then step S406 is executed; if the value of the begin_to_update variable is determined to be false, then step S404 is executed.
[0121] Step S404: Determine that the time during which no query message has been received exceeds 10 minutes.
[0122] In step S405, set the value of the last_get_time variable to 0. After completing step S405, you can directly return to step S401.
[0123] Step S406: Set the value of the begin_to_update variable to false.
[0124] Repeat steps S401-S406 above to adjust the value of the begin_to_update variable in a timely manner, and simultaneously execute the following implementation method three.
[0125] In one feasible implementation method three, after the device enables the SNMP service, the following steps are performed:
[0126] Step S501: Begin the data update operation within the node.
[0127] Step S502: Determine whether the value of the begin_to_update variable is true.
[0128] If the value of the begin_to_update variable is true, proceed to step S503; if the value of the begin_to_update variable is false, proceed to step S504.
[0129] Step S503: Continue to perform the data update operation. After completion, jump to the next node and execute step S501.
[0130] Step S504: Return to the previous operation and jump to step S501.
[0131] In this embodiment, Implementation Method 1, Implementation Method 2, and Implementation Method 3 can be executed in parallel. That is, after the device enables the SNMP service, steps S301, S401, and S501 are executed simultaneously. For a detailed description of the execution steps, please refer to the above embodiments, which will not be repeated here.
[0132] In this embodiment, the `begin_to_update` variable is set in the SNMP agent to indicate whether data updates should begin, and the `last_get_time` variable is used to store the time when the most recent query message was received. Two new functions are added: a `reset_begin_to_update` function to calculate the time since the last received SNMP query message; and a second function to assign a value to the `begin_to_update` variable based on the current time since the last received query message and the currently received query message. Finally, the original `update_data` function of the SNMP agent is used to first determine the value of the `begin_to_update` variable before determining whether to continue the update operation. Thus, determining whether to continue the update operation based on the current time since the last received query message and the received query message avoids the resource waste caused by repeated data update operations when no query messages are received for a long time.
[0133] Reference Figure 4 , Figure 4 This is a schematic diagram of the data update device in one embodiment of this application. In one embodiment of this application, as shown... Figure 4 As shown, the data update device 400 includes:
[0134] The determination module 401 is used to call the first function to determine whether the value of the first variable is true; the first variable is used to indicate whether to perform a data update operation, and the first variable is updated according to the second variable, which is used to indicate the time when the query message was last received; the first function is used to perform the data update operation.
[0135] The update module 402 is used to retrieve data from the database to update the data cached by the network management agent when the value of the first variable is determined to be true; the database is used to store the attribute information of the network device to which the network management agent belongs.
[0136] In this embodiment, the network management agent determines whether the value of a first variable is true by calling a first function. The first variable is used to indicate whether a data update operation should be performed. The first variable is updated based on a second variable, which is used to indicate the time when the query message was last received. The first function is used to perform the data update operation. If the first variable is determined to be true, data is retrieved from the database to update the data cached by the network management agent. The database is used to store the attribute information of the network device to which the network management agent belongs, thus avoiding resource waste caused by repeated update operations when no query message has been received for a long time.
[0137] In one feasible implementation, the data updating device 400 further includes:
[0138] The first detection module is used to detect whether the query message has been received.
[0139] The first assignment module is used to adjust the value of the first variable to true when it is determined that the query message has been received;
[0140] The second assignment module is used to set the reception time of the query message to the value of the second variable.
[0141] In one feasible implementation, the data updating device 400 further includes:
[0142] The first determination submodule is used to determine whether the second variable is a preset value;
[0143] The first judgment submodule is used to determine whether the value of the first variable is true when the second variable is a preset value;
[0144] The first assignment submodule is used to adjust the value of the first variable to false if the value of the first variable is true.
[0145] In one feasible implementation, the data updating device 400 further includes:
[0146] The calculation module is used to calculate the time difference between the current time and the current value of the second variable when the second variable is not the preset value.
[0147] The second assignment submodule is used to adjust the value of the first variable to false when the time difference is greater than the first preset time threshold.
[0148] In one feasible implementation, the data updating device 400 further includes:
[0149] The second detection module is used to call the third function to detect the duration of the current value of the first variable being false.
[0150] The acquisition module is used to acquire data from the database when the duration is determined to be greater than a second preset time threshold, so as to perform a data update operation on the data cached by the network management agent.
[0151] In one feasible implementation, the data updating device 400 further includes:
[0152] The third detection module is used to call the third function to detect the duration of the current value of the first variable being false.
[0153] The third assignment submodule is used to adjust the value of the first variable to true when it is determined that the duration is greater than the second preset time threshold.
[0154] In one feasible implementation, the data updating device 400 further includes:
[0155] The rollback module is used to abandon the data update operation if the first function determines that the first variable is true;
[0156] The calling module is used to re-invoke the first function and evaluate the value of the first variable.
[0157] Based on the same inventive concept, in one embodiment of this application, a switch is provided, on which a network management agent is configured, and when the network management agent is running, the data update method described in the above embodiment is executed.
[0158] In one embodiment of this application, a volatile storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, it implements the data update method as described in the above embodiments.
[0159] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0160] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, or computer program products. Therefore, embodiments of this application can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of this application can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0161] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0162] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0163] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0164] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0165] The above provides a detailed description of the data update method, apparatus, and switch. Specific examples have been used to illustrate the principles and embodiments of this application. The descriptions of the embodiments above are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in specific embodiments and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A data update method, characterized in that, The method includes: The first function is called to determine whether the value of the first variable is true; the first variable is used to indicate whether a data update operation should be performed, and the first variable is updated according to the second variable, which is used to indicate the time when the query message was last received; the first function is used to perform the data update operation. Detect whether the query message has been received; if it is determined that the query message has been received, adjust the value of the first variable to true and set the reception time of the query message to the value of the second variable; Calculate the time difference between the current time and the value of the second variable. If the time difference is greater than a first preset time threshold, adjust the value of the first variable to false. If the value of the first variable is determined to be true, data is retrieved from the database to update the data cached by the network management agent; the database is used to store attribute information of the network device to which the network management agent belongs.
2. The method according to claim 1, characterized in that, The method further includes updating the first variable based on the second variable according to the following steps: Determine whether the second variable is a preset value; If the second variable is the preset value, determine whether the value of the first variable is true; If the value of the first variable is true, a second function is called to adjust the value of the first variable to false. The second function is used to adjust the value of the first variable.
3. The data update method according to claim 1, characterized in that, The method further includes: Call the third function to check the duration for which the current value of the first variable is false; If the duration is determined to be greater than a second preset time threshold, data is retrieved from the database to perform the data update operation on the data cached by the network management agent.
4. The data update method according to claim 1, characterized in that, The method further includes: Call the third function to check the duration for which the current value of the first variable is false; If it is determined that the duration is greater than the second preset time threshold, the value of the first variable is adjusted to true.
5. The data update method according to claim 1, characterized in that, The method further includes: If the first function determines that the value of the first variable is false, the data update operation is abandoned. Call the first function again to evaluate the value of the first variable.
6. A data update device, characterized in that, The device includes: The module is used to call a first function to determine whether the value of a first variable is true; the first variable is used to indicate whether a data update operation should be performed, and the first variable is updated according to a second variable, which is used to indicate the time when the query message was last received; the first function is used to perform the data update operation. The first detection module is used to detect whether the query message has been received. The first assignment module is used to adjust the value of the first variable to true when it is determined that the query message has been received; The second assignment module is used to set the receiving time of the query message to the value of the second variable; The calculation module is used to calculate the time difference between the current time and the value of the second variable; The second assignment submodule is used to adjust the value of the first variable to false when the time difference is greater than the first preset time threshold. The update module is used to retrieve data from the database to update the data cached by the network management agent when the first variable is determined to be true; the database is used to store the attribute information of the network device to which the network management agent belongs.
7. A switch, characterized in that, It is equipped with a network management agent, which, when running, executes the data update method described in any one of claims 1-5.
Citation Information
Patent Citations
Data processing method and device, server and inventory system
CN108334505A
Remote management method and device, electronic equipment and storage medium
CN111147276A
