A resource management method and apparatus
By using a resource index automatic generator in a network device to generate a resource index, the problem of time-consuming resource pool initialization is solved, and the initialization time of the network device is shortened.
Patent Information
- Application Number
- CN202411001071.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2044-07-24
AI Technical Summary
In a network device, when the number of resource indexes is large, the initialization of the resource pool takes a long time, resulting in a long initialization time for the network device.
The resource index automatic generator is used to generate the resource index in the resource pool, avoiding the initialization process of the resource pool, and directly generating the resource index for the target resource and sending a response.
Without initializing the resource pool, the initialization time of the network device is shortened, especially when the number of resource indexes is large.
Smart Images

Figure CN119071252B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of communication, and in particular to a resource management method and device. BACKGROUND
[0002] In a network device (for example, a routing device, a switching device, etc.), a counter or the like resource is usually used, and each data flow on the network device can need to be allocated one or more counters for statistics.
[0003] At present, all available resource indexes (for example, counter indexes, etc.) corresponding to a same resource in the network device are in a resource pool, and the resource pool needs to be initialized when the network device starts, so that in the case that the number of resource indexes is large, the initialization of the resource pool takes a long time, and the initialization of the entire network device takes a long time. SUMMARY
[0004] To overcome the problems in the prior art, the present application provides a resource management method and device.
[0005] According to a first aspect of an embodiment of the present application, a resource management method is provided, the method being applied to a resource management module in a network device, and the method comprising:
[0006] receiving a resource application request for applying a resource index of a target resource sent by a first client in the network device;
[0007] if the number of available resource indexes in a resource pool corresponding to the target resource is 0, and the number of resource indexes generated by a resource index automatic generator is less than the number of currently configured available resource indexes of the resource pool, generating a first target resource index for the target resource by calling the resource index automatic generator;
[0008] sending a resource application response carrying the first target resource index to the first client;
[0009] wherein initially, the number of resource indexes generated by the resource index automatic generator is 0;
[0010] when the number of resource indexes generated by the resource index automatic generator is 0, the value of the first target resource index is 0;
[0011] when the number of resource indexes generated by the resource index automatic generator is not 0, the value of the first target resource index is the value of the resource index generated by the resource index automatic generator last time plus 1.
[0012] According to a second aspect of an embodiment of the present application, a resource management device is provided, which is applied to a resource management module in a network device, and includes:
[0013] A receiving unit, configured to receive a resource application request for a resource index of a target resource sent by a first client in the network device;
[0014] A processing unit, configured to, if the number of available resource indexes in the resource pool corresponding to the target resource is 0, call the resource index automatic generator to generate a first target resource index for the target resource when the number of resource indexes generated by the resource index automatic generator corresponding to the target resource is less than the number of available resource indexes currently configured in the resource pool; and send a resource request response carrying the first target resource index to the first client;
[0015] Wherein, initially, the number of resource indexes generated by the resource index automatic generator is 0;
[0016] When the number of resource indexes generated by the resource index automatic generator is 0, the value of the first target resource index is 0;
[0017] When the number of resource indexes generated by the resource index automatic generator is not 0, the value of the first target resource index is the value of the resource index last generated by the resource index automatic generator plus 1.
[0018] The technical solutions provided by the embodiments of the present application may have the following beneficial effects:
[0019] In an embodiment of the present application, for the resource management module in the network device, the following operation process is performed: receiving a resource application request for applying for a resource index of a target resource sent by a first client in the network device; if the number of available resource indexes in the resource pool corresponding to the target resource is 0, then when the resource index automatic generator corresponding to the target resource has not generated a resource index or the number of resource indexes generated by the resource index automatic generator is less than the number of available resource indexes currently configured in the resource pool, calling the resource index automatic generator to generate a first target resource index for the target resource; and sending a resource application response carrying the first target resource index to the first client.
[0020] In this way, the network device does not need to initialize the relevant resource pool, which can effectively shorten the initialization time of the network device when the number of resource indexes is large.
[0021] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0023] Figure 1 A flowchart of a resource management method provided in an embodiment of the present application;
[0024] Figure 2 One of the schematic diagrams of the resource management module managing the resource pool provided in the embodiment of the present application;
[0025] Figure 3 Schematic diagram 2 of the resource management module managing the resource pool provided in the embodiment of the present application;
[0026] Figure 4 Schematic diagram 3 of the resource management module managing the resource pool provided in the embodiment of the present application;
[0027] Figure 5 Schematic diagram 4 of the resource management module managing the resource pool provided in the embodiment of the present application;
[0028] Figure 6 A schematic diagram of the structure of a resource management device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0030] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. As used in this application and the appended claims, the singular forms "a," "an," "the," and "the" are intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
[0031] It should be understood that although the terms first, second, third, etc. may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the words "if" or "if" as used herein may be interpreted as "when" or "when".
[0032] Next, the embodiments of the present application are described in detail.
[0033] The embodiment of the present application provides a resource management method, which is applied to a resource management module in a network device, such as Figure 1 As shown, the method may include the following steps:
[0034] S11. Receive a resource application request for a resource index of a target resource sent by a first client in a network device.
[0035] In this step, the target resource may be a counter resource or the like.
[0036] S12. If the number of available resource indexes in the resource pool corresponding to the target resource is 0, then when the number of resource indexes generated by the resource index automatic generator corresponding to the target resource is less than the number of available resource indexes currently configured in the resource pool, the resource index automatic generator is called to generate a first target resource index for the target resource.
[0037] In this step, initially, the number of resource indexes generated by the resource index automatic generator is 0.
[0038] When the number of resource indexes generated by the resource index automatic generator is 0, the value of the first target resource index is 0.
[0039] When the number of resource indexes generated by the resource index automatic generator is not 0, the value of the first target resource index is the value of the resource index last generated by the resource index automatic generator plus 1.
[0040] S13. Send a resource request response carrying the first target resource index to the first client.
[0041] It should be noted that in the above step S12, when the number of available resource indexes in the resource pool corresponding to the target resource is 0, if the resource index automatic generator corresponding to the target resource has not generated a resource index, this means that the above resource application request is received for the first time by the resource management module. At this time, the resource management module directly calls the resource index automatic generator to generate a first target resource index for the target resource, and then executes the above step S13.
[0042] If the number of resource indexes generated by the resource index automatic generator is less than the number of available resource indexes currently configured in the resource pool, this means that the above resource application request is not the first time received by the resource management module, and there have been available resource indexes in the resource pool but they have been read (which can also be understood as allocated). At this time, the resource management module can also directly call the resource index automatic generator to generate a first target resource index for the target resource, and then execute the above step S13.
[0043] In this way, the application and use requirements of resource indexes can be met without initializing the resource pool.
[0044] Furthermore, in the embodiment of the present application, in order to facilitate the administrator to flexibly manage the resource pool, the resource management module may further perform the following operations:
[0045] If a resource modification instruction input by an administrator for modifying the number of available resource indexes currently configured in the resource pool is received, the number of available resource indexes currently configured in the resource pool is modified to the new number of available resource indexes indicated by the resource modification instruction.
[0046] Here, the new available resource index number indicated by the resource modification instruction may be carried in the resource modification instruction. Moreover, the modified available resource index number may be greater than the number of available resource indexes before the modification, or may be less than the number of available resource indexes before the modification.
[0047] That is, administrators can flexibly increase or decrease the number of available resource indexes configured for the resource pool based on resource requirements.
[0048] For example, assuming that the number of available resource indexes currently configured in the resource pool corresponding to the target resource is 100, if the resource management module receives a resource modification instruction input by the administrator containing a new number of available resource indexes (for example, 110), then the resource management module will modify the number of available resource indexes currently configured in the resource pool to 110.
[0049] For another example, assuming that the number of available resource indexes currently configured in the resource pool corresponding to the target resource is 100, if the resource management module receives a resource modification instruction input by the administrator containing a new number of available resource indexes (for example, 80), then the resource management module will modify the number of available resource indexes currently configured in the resource pool to 80.
[0050] Furthermore, in the embodiment of the present application, the resource management module may further perform the following operations:
[0051] If a first resource release request for releasing a second target resource index of a target resource sent by a first client is received, determining whether a value of the second target resource index is not less than a value of the number of available resource indexes in the resource pool;
[0052] When the judgment result is yes, discard the second target resource index;
[0053] When the judgment result is no, the second target resource index is written into the sub-memory area in the memory area corresponding to the resource pool pointed to by the head pointer of the resource pool, and the head pointer of the resource pool is pointed to the next sub-memory area corresponding to the sub-memory area, and the number of available resource indexes in the resource pool is increased by 1;
[0054] Initially, the number of available resource indexes in the resource pool is 0, and both the head pointer and the tail pointer of the resource pool point to the first empty sub-memory area in the memory area.
[0055] When the sub-memory area pointed to by the head pointer is the last sub-memory area in the memory area, the corresponding next sub-memory area is the first sub-memory area in the memory area.
[0056] It should be noted that, in this operation process, the reason why the judgment result is yes is mainly because the number of available resource indexes configured for the resource pool is reduced.
[0057] It should be further explained that in an embodiment of the present application, the resource management module uses the sub-memory area pointed to by the head pointer of the resource pool to store the resource index released by the client, and provides the resource index in the sub-memory area pointed to by the tail pointer of the resource pool to the client for use.
[0058] In addition, in the embodiment of the present application, after receiving the resource application request, the resource management module may perform the following operations:
[0059] The first operation: if the number of available resource indexes in the resource pool corresponding to the target resource is 0, and the number of resource indexes generated by the resource index automatic generator is not less than the number of available resource indexes currently configured in the resource pool, an error identifier representing resource exhaustion is sent to the first client.
[0060] The second operation: If the number of available resource indexes in the resource pool corresponding to the target resource is greater than 0, then read the value of the resource index currently pointed to by the tail pointer corresponding to the resource pool;
[0061] If the read value is not greater than the value of the number of available resource indexes currently configured in the resource pool, a resource request response carrying the resource index currently pointed to by the tail pointer is sent to the first client, and the tail pointer is pointed to the next resource index of the resource index corresponding to the value read in the resource pool, and the number of available resource indexes in the resource pool is reduced by 1;
[0062] If the read value is greater than the value of the number of available resource indexes currently configured in the resource pool, the read value is discarded, the number of available resource indexes in the resource pool is reduced by 1, and when the number of available resource indexes in the current resource pool is 0, an error flag indicating resource exhaustion is sent to the first client; or
[0063] When the number of available resource indexes in the current resource pool is greater than 0, the tail pointer is pointed to the next resource index of the resource index corresponding to the value read from the resource pool, and the step of reading the value of the resource index currently pointed to by the tail pointer corresponding to the resource pool is continued;
[0064] Wherein, initially, the tail pointer points to the first sub-memory area in the memory area corresponding to the resource pool, and the resource index in the first sub-memory area is written by the resource management module when the resource management module receives a second resource release request sent by the second client in the network device and carries the resource index in the first sub-memory area, and the head pointer of the resource pool points to the first sub-memory area with empty content;
[0065] When the resource index currently pointed to by the tail pointer corresponding to the resource pool is the resource index in the last sub-memory area in the memory area, the corresponding next resource index is the resource index in the first sub-memory area in the memory area.
[0066] It should be noted that after the resource management module receives the resource application request, if the number of available resource indexes in the resource pool corresponding to the target resource is 0 and the number of resource indexes generated by the resource index automatic generator is not less than the number of available resource indexes currently configured in the resource pool, this means that there are no available resource indexes in the resource pool, and the number of resource indexes generated by the resource index automatic generator has reached the number of available resource indexes currently configured in the resource pool or has exceeded the number of available resource indexes currently configured in the resource pool (the situation that occurs after the number of available resource indexes currently configured is reduced). In this case, resource indexes can no longer be allocated to the target resource, and an error identifier representing resource exhaustion is sent to the first client.
[0067] For example, initially, Figure 2 As shown, on the resource management module side of the network device 1, it is assumed that the resource pool corresponding to the counter resource corresponds to the memory area 1, and there are 2N – 1 sub-memory area, one sub-memory area stores one resource index, which can also be understood as the maximum number of resource indexes corresponding to the Resource Pool (recorded as Mask) is 2 N –1 (denoted as SIZE-1); the number of available resource indexes currently configured in the Resource Pool (denoted as Capacity, for example, Capacity is MAX) is 100; the number of available resource indexes in the Resource Pool (denoted as Count) is 0; the head pointer (denoted as Head) and tail pointer (denoted as Tail) corresponding to the Resource Pool point to the first sub-memory area corresponding to the Resource Pool, and the values of Head and Tail can be 0; the starting address of the first sub-memory area is the base address (Base) corresponding to the Resource Pool; the number of resource indexes generated by the resource index automatic generator corresponding to the counter resource (denoted as Auto Generator) is 0.
[0068] Assume that at time 1, the Resource Manager module receives a resource request 1 for a resource index of a counter resource sent by client 1 in network device 1. The Resource Manager module finds that the number of available resource indexes in the resource pool corresponding to the counter resource is 0, and the resource index automatic generator corresponding to the counter resource has not generated a resource index. At this time, the Resource Manager module calls the resource index automatic generator to generate a resource index 1 (corresponding to a value of 0) for the counter resource. It also sends a resource request response 1 carrying resource index 1 to client 1, and adds 1 to the number of resource indexes generated by the resource index automatic generator, as shown in the following example: Figure 3 shown.
[0069] Assume that at time 2, the Resource Manager module receives a resource release request 1 sent by client 1 for releasing resource index 1. The Resource Manager module determines whether the value of resource index 1 is not less than the value of the number of resource indexes available in the resource pool; assuming that the number of resource indexes available in the resource pool is 0, and assuming that the head pointer of the resource pool points to the first sub-memory area, then the judgment result is no. At this time, the Resource Manager module writes resource index 1 into the first sub-memory area pointed to by the head pointer of the resource pool, and points the head pointer of the resource pool to the second sub-memory area corresponding to the resource pool, that is, adds 1 to the value of the head pointer and adds 1 to the number of resource indexes available in the resource pool, as shown in FIG. Figure 4 shown.
[0070] Assume that at time 3, all available resource indexes in the resource pool have been allocated, the values of the head pointer and the tail pointer are N, and the number of resource indexes generated by the resource index automatic generator is MAX. At this time, the Resource Manager module receives a resource modification instruction 1 input by the administrator to modify the number of available resource indexes currently configured in the resource pool, wherein the resource modification instruction 1 carries a new number of available resource indexes (for example, MAX'). In this case, the ResourceManager module modifies the number of available resource indexes currently configured in the resource pool (i.e., MAX) to MAX', as shown in FIG. Figure 5 Here, MAX' is greater than MAX.
[0071] Next, assume that the Resource Manager module receives a resource request 2 from client 1 for a resource index of a counter resource. The Resource Manager module discovers that the number of available resource indexes in the resource pool corresponding to the counter resource is 0, and the number of resource indexes generated by the resource index automatic generator corresponding to the counter resource (i.e., MAX) is less than the number of available resource indexes currently configured in the resource pool (i.e., MAX'). In this case, the Resource Manager module calls the resource index automatic generator to generate a resource index 2 for the counter resource (the corresponding value is MAX+1). The Resource Manager module also sends a resource request response 2 carrying resource index 2 to client 1, adding 1 to the number of resource indexes generated by the resource index automatic generator.
[0072] It can be seen from the above technical solution that in an embodiment of the present application, for the resource management module in the network device, the following operation process is performed: receiving a resource application request for applying for a resource index of a target resource sent by a first client in the network device; if the number of available resource indexes in the resource pool corresponding to the target resource is 0, then when the resource index automatic generator corresponding to the target resource has not generated a resource index or the number of resource indexes generated by the resource index automatic generator is less than the number of available resource indexes currently configured in the resource pool, calling the resource index automatic generator to generate a first target resource index for the target resource; and sending a resource application response carrying the first target resource index to the first client.
[0073] In this way, the network device does not need to initialize the relevant resource pool, which can effectively shorten the initialization time of the network device when the number of resource indexes is large.
[0074] Based on the same inventive concept, the present application also provides a resource management device, which is applied to the resource management module in the network device. Figure 6 As shown, specifically including:
[0075] The receiving unit 61 is configured to receive a resource application request for a resource index of a target resource sent by a first client in the network device;
[0076] Processing unit 62 is configured to, if the number of available resource indexes in the resource pool corresponding to the target resource is 0, call the resource index automatic generator to generate a first target resource index for the target resource when the number of resource indexes generated by the resource index automatic generator corresponding to the target resource is less than the number of available resource indexes currently configured in the resource pool; and send a resource request response carrying the first target resource index to the first client;
[0077] Wherein, initially, the number of resource indexes generated by the resource index automatic generator is 0;
[0078] When the number of resource indexes generated by the resource index automatic generator is 0, the value of the first target resource index is 0;
[0079] When the number of resource indexes generated by the resource index automatic generator is not 0, the value of the first target resource index is the value of the resource index last generated by the resource index automatic generator plus 1.
[0080] Preferably, the device further comprises:
[0081] Modify the unit ( Figure 6 (not shown), is used to modify the number of available resource indexes currently configured in the resource pool to the new number of available resource indexes indicated by the resource modification instruction if a resource modification instruction input by an administrator is received to modify the number of available resource indexes currently configured in the resource pool.
[0082] Preferably, the processing unit 62 is further configured to:
[0083] If a first resource release request for releasing a second target resource index of the target resource sent by the first client is received, determining whether a value of the second target resource index is not less than a value of the number of available resource indexes in the resource pool;
[0084] When the judgment result is yes, discard the second target resource index;
[0085] When the judgment result is no, writing the second target resource index into the sub-memory area in the memory area corresponding to the resource pool pointed to by the head pointer of the resource pool, and pointing the head pointer of the resource pool to the next sub-memory area corresponding to the sub-memory area, and increasing the number of available resource indexes in the resource pool by 1;
[0086] Wherein, initially, the number of available resource indexes in the resource pool is 0, and the head pointer and the tail pointer of the resource pool both point to the first sub-memory area with empty content in the memory area;
[0087] When the sub-memory area pointed to by the head pointer is the last sub-memory area in the memory area, the corresponding next sub-memory area is the first sub-memory area in the memory area.
[0088] Preferably, the processing unit 62 is further configured to:
[0089] After the receiving unit 61 receives the resource application request, if the number of available resource indexes in the resource pool corresponding to the target resource is 0, and the number of resource indexes generated by the resource index automatic generator is not less than the number of available resource indexes currently configured in the resource pool, an error identifier for indicating resource exhaustion is sent to the first client.
[0090] Preferably, the management module 62 is further configured to:
[0091] After the receiving unit 61 receives the resource application request, if the number of available resource indexes in the resource pool corresponding to the target resource is greater than 0, read the value of the resource index currently pointed to by the tail pointer corresponding to the resource pool;
[0092] If the read value is not greater than the value of the number of available resource indexes currently configured in the resource pool, a resource request response carrying the resource index currently pointed to by the tail pointer is sent to the first client, and the tail pointer is pointed to the next resource index of the resource index corresponding to the value read in the resource pool, and the number of available resource indexes in the resource pool is reduced by 1;
[0093] If the read value is greater than the value of the number of available resource indexes currently configured in the resource pool, the read value is discarded, the number of available resource indexes in the resource pool is reduced by 1, and when the number of available resource indexes in the resource pool is currently 0, an error identifier representing resource exhaustion is sent to the first client; or
[0094] When the number of available resource indexes in the current resource pool is greater than 0, the tail pointer is pointed to the next resource index of the resource index corresponding to the value read from the resource pool, and the step of reading the value of the resource index currently pointed to by the tail pointer corresponding to the resource pool is continued;
[0095] Wherein, initially, the tail pointer points to the first sub-memory area in the memory area corresponding to the resource pool, and the resource index in the first sub-memory area is written by the resource management module when receiving a second resource release request sent by the second client in the network device and carrying the resource index in the first sub-memory area, and the head pointer of the resource pool points to the first sub-memory area whose content is empty;
[0096] When the resource index currently pointed to by the tail pointer corresponding to the resource pool is the resource index in the last sub-memory area in the memory area, the corresponding next resource index is the resource index in the first sub-memory area in the memory area.
[0097] It can be seen from the above technical solution that in an embodiment of the present application, for the resource management module in the network device, the following operation process is performed: receiving a resource application request for applying for a resource index of a target resource sent by a first client in the network device; if the number of available resource indexes in the resource pool corresponding to the target resource is 0, then when the resource index automatic generator corresponding to the target resource has not generated a resource index or the number of resource indexes generated by the resource index automatic generator is less than the number of available resource indexes currently configured in the resource pool, calling the resource index automatic generator to generate a first target resource index for the target resource; and sending a resource application response carrying the first target resource index to the first client.
[0098] In this way, the network device does not need to initialize the relevant resource pool, which can effectively shorten the initialization time of the network device when the number of resource indexes is large.
[0099] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A resource management method, characterized in that: The method is applied to a resource management module in a network device, and the method includes: receiving a resource application request for a resource index of a target resource sent by a first client in the network device; If the number of available resource indexes in the resource pool corresponding to the target resource is 0, then when the number of resource indexes generated by the resource index automatic generator corresponding to the target resource is less than the number of available resource indexes currently configured in the resource pool, the resource index automatic generator is called to generate a first target resource index for the target resource; Sending a resource request response carrying the first target resource index to the first client; Wherein, initially, the number of resource indexes generated by the resource index automatic generator is 0; When the number of resource indexes generated by the resource index automatic generator is 0, the value of the first target resource index is 0; When the number of resource indexes generated by the resource index automatic generator is not 0, the value of the first target resource index is the value of the resource index last generated by the resource index automatic generator plus 1.
2. The method according to claim 1, characterized in that The method further comprises: If a resource modification instruction input by an administrator for modifying the number of available resource indexes currently configured in the resource pool is received, the number of available resource indexes currently configured in the resource pool is modified to the new number of available resource indexes indicated by the resource modification instruction.
3. The method according to claim 1, characterized in that The method further comprises: If a first resource release request for releasing a second target resource index of the target resource sent by the first client is received, determining whether a value of the second target resource index is not less than a value of the number of available resource indexes in the resource pool; When the judgment result is yes, discard the second target resource index; When the judgment result is no, writing the second target resource index into the sub-memory area in the memory area corresponding to the resource pool pointed to by the head pointer of the resource pool, and pointing the head pointer of the resource pool to the next sub-memory area corresponding to the sub-memory area, and increasing the number of available resource indexes in the resource pool by 1; Wherein, initially, the number of available resource indexes in the resource pool is 0, and the head pointer and the tail pointer of the resource pool both point to the first sub-memory area with empty content in the memory area; When the sub-memory area pointed to by the head pointer is the last sub-memory area in the memory area, the corresponding next sub-memory area is the first sub-memory area in the memory area.
4. The method according to claim 1, wherein The method further comprises: After receiving the resource application request, if the number of available resource indexes in the resource pool corresponding to the target resource is 0, and the number of resource indexes generated by the resource index automatic generator is not less than the number of available resource indexes currently configured in the resource pool, an error identifier representing resource exhaustion is sent to the first client.
5. The method according to claim 1, wherein The method further comprises: After receiving the resource application request, if the number of available resource indexes in the resource pool corresponding to the target resource is greater than 0, reading the value of the resource index currently pointed to by the tail pointer corresponding to the resource pool; If the read value is not greater than the value of the number of available resource indexes currently configured in the resource pool, a resource request response carrying the resource index currently pointed to by the tail pointer is sent to the first client, and the tail pointer is pointed to the next resource index of the resource index corresponding to the value read in the resource pool, and the number of available resource indexes in the resource pool is reduced by 1; If the read value is greater than the value of the number of available resource indexes currently configured in the resource pool, the read value is discarded, the number of available resource indexes in the resource pool is reduced by 1, and when the number of available resource indexes in the resource pool is currently 0, an error identifier representing resource exhaustion is sent to the first client; or When the number of available resource indexes in the current resource pool is greater than 0, the tail pointer is pointed to the next resource index of the resource index corresponding to the value read from the resource pool, and the step of reading the value of the resource index currently pointed to by the tail pointer corresponding to the resource pool is continued; Wherein, initially, the tail pointer points to the first sub-memory area in the memory area corresponding to the resource pool, and the resource index in the first sub-memory area is written by the resource management module when receiving a second resource release request sent by the second client in the network device and carrying the resource index in the first sub-memory area, and the head pointer of the resource pool points to the first sub-memory area whose content is empty; When the resource index currently pointed to by the tail pointer corresponding to the resource pool is the resource index in the last sub-memory area in the memory area, the corresponding next resource index is the resource index in the first sub-memory area in the memory area.
6. A resource management device, characterized in that: The device is applied to a resource management module in a network device, and includes: A receiving unit, configured to receive a resource application request for a resource index of a target resource sent by a first client in the network device; A processing unit, configured to, if the number of available resource indexes in the resource pool corresponding to the target resource is 0, call the resource index automatic generator to generate a first target resource index for the target resource when the number of resource indexes generated by the resource index automatic generator corresponding to the target resource is less than the number of available resource indexes currently configured in the resource pool; and send a resource request response carrying the first target resource index to the first client; Wherein, initially, the number of resource indexes generated by the resource index automatic generator is 0; When the number of resource indexes generated by the resource index automatic generator is 0, the value of the first target resource index is 0; When the number of resource indexes generated by the resource index automatic generator is not 0, the value of the first target resource index is the value of the resource index last generated by the resource index automatic generator plus 1.
7. The device according to claim 6, characterized in that The device further comprises: The modification unit is used to modify the number of available resource indexes currently configured in the resource pool to the new number of available resource indexes indicated by the resource modification instruction if a resource modification instruction input by the administrator is received to modify the number of available resource indexes currently configured in the resource pool.
8. The device according to claim 6, characterized in that The processing unit is further configured to: If a first resource release request for releasing a second target resource index of the target resource sent by the first client is received, determining whether a value of the second target resource index is not less than a value of the number of available resource indexes in the resource pool; When the judgment result is yes, discard the second target resource index; When the judgment result is no, writing the second target resource index into the sub-memory area in the memory area corresponding to the resource pool pointed to by the head pointer of the resource pool, and pointing the head pointer of the resource pool to the next sub-memory area corresponding to the sub-memory area, and increasing the number of available resource indexes in the resource pool by 1; Wherein, initially, the number of available resource indexes in the resource pool is 0, and the head pointer and the tail pointer of the resource pool both point to the first sub-memory area with empty content in the memory area; When the sub-memory area pointed to by the head pointer is the last sub-memory area in the memory area, the corresponding next sub-memory area is the first sub-memory area in the memory area.
9. The device according to claim 6, characterized in that The processing unit is further configured to: After the receiving unit receives the resource application request, if the number of available resource indexes in the resource pool corresponding to the target resource is 0, and the number of resource indexes generated by the resource index automatic generator is not less than the number of available resource indexes currently configured in the resource pool, an error identifier for indicating resource exhaustion is sent to the first client.
10. The device according to claim 6, characterized in that The processing unit is further configured to: After the receiving unit receives the resource application request, if the number of available resource indexes in the resource pool corresponding to the target resource is greater than 0, read the value of the resource index currently pointed to by the tail pointer corresponding to the resource pool; If the read value is not greater than the value of the number of available resource indexes currently configured in the resource pool, a resource request response carrying the resource index currently pointed to by the tail pointer is sent to the first client, and the tail pointer is pointed to the next resource index of the resource index corresponding to the value read in the resource pool, and the number of available resource indexes in the resource pool is reduced by 1; If the read value is greater than the value of the number of available resource indexes currently configured in the resource pool, the read value is discarded, the number of available resource indexes in the resource pool is reduced by 1, and when the number of available resource indexes in the resource pool is currently 0, an error identifier representing resource exhaustion is sent to the first client; or When the number of available resource indexes in the current resource pool is greater than 0, the tail pointer is pointed to the next resource index of the resource index corresponding to the value read from the resource pool, and the step of reading the value of the resource index currently pointed to by the tail pointer corresponding to the resource pool is continued; Wherein, initially, the tail pointer points to the first sub-memory area in the memory area corresponding to the resource pool, and the resource index in the first sub-memory area is written by the resource management module when receiving a second resource release request sent by the second client in the network device and carrying the resource index in the first sub-memory area, and the head pointer of the resource pool points to the first sub-memory area whose content is empty; When the resource index currently pointed to by the tail pointer corresponding to the resource pool is the resource index in the last sub-memory area in the memory area, the corresponding next resource index is the resource index in the first sub-memory area in the memory area.
Citation Information
Patent Citations
Resource management method and system, electronic equipment and storage medium
CN112269659A
Information transmission method and device
CN115334654A