Resource management method, device, electronic device and storage medium
By initializing all resources in the resource pool of the monitoring system to sleep state and activate target resources for data storage according to user needs, the problem of long time spent on resource pool reduction and high disk pressure is solved, and more efficient resource management and storage performance is achieved.
Patent Information
- Application Number
- CN202011520601.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-21
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2040-12-21
AI Technical Summary
The existing cloud storage systems have problems such as long time-consuming, high disk read and write pressure, and high data migration risks when reducing the resource pool, which affects storage performance and management results.
Data is stored based on a consistent hash algorithm by initializing the usage status of all resources in the resource pool to a dormant state and activate the target resource according to the storage capacity allocated by the user. When decreasing is needed, select resources that meet the needs from the resources in the dormant state to reduce the capacity to avoid data migration.
It reduces the operating time of resource pool shrinkage, reduces the performance pressure of disk read and write, and improves the efficiency and controllability of resource pool management.
Smart Images

Figure CN114650392B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of monitoring technology, and in particular to a resource management method, device, electronic device and storage medium. Background Art
[0002] With the continuous development of social economy, user objects are becoming more and more diversified, and the storage requirements of the massive images and video data involved in the monitoring system are also increasing. As a result, the flexible configuration requirements for cloud storage systems are becoming higher and higher, so as to adapt to different types of business configuration requirements and meet the construction and control of complex monitoring networks on site. The cloud storage currently used in the monitoring industry is managed in units of resources, and the user-allocated usage capacity is based on the resources of the resource pool. Therefore, the management of the resource pool (such as expansion and reduction) is particularly important in meeting the needs of diversified configuration.
[0003] After allocating storage capacity to the user in the resource pool, the IPC (IP Camera) belonging to the user in the monitoring system will store the collected data evenly on all resources in the resource pool. Therefore, when the resource pool needs to be managed, for example, when the resource pool is reduced in capacity, if the user needs to reduce the capacity to a large extent, and the amount of data stored in the early stage is large, the number of resources that the storage system chooses to reduce will be large, and a large amount of data needs to be migrated to other resources, resulting in a long time to reduce the resource pool, a large pressure on disk reading and writing, and affecting storage performance. In addition, when the resource pool is reduced in capacity, the risk of long-term data migration is uncontrollable, and various other abnormal situations may occur during the data migration process, resulting in migration interruption, causing the resource pool to fail to reduce in capacity. It can be seen from this that the management effect of the resource pool in the existing technology is poor. Summary of the invention
[0004] The embodiments of the present application provide a resource management method, device, electronic device and storage medium to achieve the purpose of optimizing resource pool management effect.
[0005] In a first aspect, an embodiment of the present application provides a resource management method, the method comprising:
[0006] Initialize the usage status of all resources in the resource pool to a dormant state; wherein, in the dormant state, the data stored in the resources is in a read-only state and allows deletion;
[0007] According to the storage capacity allocated by the user, at least one target resource in the resource pool is activated, so that the data collected by the collector is stored in the activated target resource based on the consistent hashing algorithm;
[0008] In response to a triggering operation to shrink the resource pool, resources that meet the shrinking requirement are selected from resources currently in a dormant state to shrink the resource pool.
[0009] In a second aspect, an embodiment of the present application provides a resource management device, the device comprising:
[0010] An initialization module, used to initialize the use status of all resources in the resource pool to a dormant state; wherein, in the dormant state, the data stored in the resources is in a read-only state and allows deletion;
[0011] A resource activation module, used to activate at least one target resource in the resource pool according to the storage capacity allocated by the user, so that the data collected by the collector is stored in the target resource in the activated state based on the consistent hashing algorithm;
[0012] The shrinkage management module is used to respond to a triggering operation of shrinking the resource pool and select resources that meet the shrinkage requirements from the resources currently in a dormant state to shrink the resource pool.
[0013] In a third aspect, an embodiment of the present application further provides an electronic device, including:
[0014] one or more processors;
[0015] a storage device for storing one or more programs,
[0016] When one or more programs are executed by one or more processors, the one or more processors implement a resource management method as in any embodiment of the present application.
[0017] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, a resource management method as in any embodiment of the present application is implemented.
[0018] In an embodiment of the present application, a certain amount of resources are activated to be responsible for data storage according to the storage capacity allocated by the user, and other resources are in a dormant state. When it is necessary to shrink the resource pool, resources that meet the capacity requirements are directly selected from the dormant resources to shrink the resource pool. Since the dormant resources do not store the data collected by the collector, data migration is not required during shrinkage, thereby reducing the operation time of shrinking the resource pool, reducing the performance pressure of disk reading and writing, and ultimately achieving the purpose of optimizing the resource pool management effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1a is a flowchart of a resource management method in the first embodiment of the present application;
[0020] Figure 1b is a schematic diagram of the structure of the resource pool in the first embodiment of the present application;
[0021] Figure 1cis a schematic diagram of resource pool shrinkage in the first embodiment of the present application;
[0022] Figure 2a is a flowchart of a resource management method in the second embodiment of the present application;
[0023] Figure 2b It is a schematic diagram of the structure after the resources in the resource pool are sorted in descending order in the second embodiment of the present application;
[0024] Figure 3a is a flowchart of a resource management method in the third embodiment of the present application;
[0025] Figure 3b is a schematic diagram of a hash ring in the third embodiment of the present application; Figure 4 is a flowchart of a resource management method in a fourth embodiment of the present application;
[0026] Figure 5a is a flowchart of a resource management method in a fifth embodiment of the present application;
[0027] Figure 5b is a schematic diagram of the structure of the resource pool after the user allocates storage capacity multiple times in the fifth embodiment of the present application;
[0028] Figure 6 is a flowchart of a resource management method in a sixth embodiment of the present application;
[0029] Figure 7 is a schematic diagram of the structure of a resource management device in the seventh embodiment of the present application;
[0030] Figure 8 It is a structural diagram of an electronic device for implementing a resource management method in the eighth embodiment of the present application. DETAILED DESCRIPTION
[0031] The present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for ease of description, only the parts related to the present application, rather than all structures, are shown in the accompanying drawings.
[0032] Figure 1a It is a flowchart of the resource management method of the first embodiment of the present application. This embodiment can be applied to the situation of performing capacity reduction management on the resource pool of the monitoring system. The method can be executed by a resource management device, which can be implemented in software and / or hardware and can be integrated in an electronic device, such as a data storage server integrated in the monitoring system.
[0033] like Figure 1a As shown, the resource management method specifically includes the following processes:
[0034] S101: Initialize the usage status of all resources in the resource pool to a dormant state.
[0035] In the embodiment of the present application, the use state of the resource includes a dormant state and an activated state. In the dormant state, the data stored in the resource is in a read-only state and allows deletion; in the activated state, the data stored in the resource is in a readable and writable state.
[0036] In the embodiment of the present application, in order to prevent the collector of the monitoring system from storing the collected data uniformly on all resources in the resource pool, the use status of all resources in the resource pool is initialized to a dormant state, that is, writing data to each resource in the resource pool is prohibited. Figure 1b , which shows a schematic diagram of the structure of a resource pool, wherein the resource pool includes 20 resources, and in an initial state, the usage states of resources 1 to 20 are adjusted to a dormant state.
[0037] S102. Activate at least one target resource in the resource pool according to the storage capacity allocated by the user, so that the data collected by the collector is stored in the activated target resource based on the consistent hashing algorithm.
[0038] In the embodiment of the present application, the storage capacity allocated by the user is USER, which refers to a logical space divided from the resource pool. The user can allocate it at will to provide the virtual space size for data writing to the collector of the monitoring system. Among them, the collector of the monitoring system is exemplarily an IPC (IP Camera network camera). IPC is the development trend of IP video surveillance and high-definition video surveillance. The function of IPC is to integrate the camera and the encoder, digitize and compress the analog video and audio signals, form IP data packets, and transmit them to the specified destination address via the network.
[0039] According to the storage capacity allocated by the user, at least one target resource in the resource pool is activated, as long as the total resource capacity of the at least one target resource after activation is not less than the storage capacity allocated by the user. Figure 1b , the storage capacity allocated by the user is 8T. When activating resources in the resource pool, you can activate only resource 1 with a capacity of 10T, or only resource 2 with a capacity of 18T, or activate resource 3 with a capacity of 5T and resource 20 with a capacity of 3T at the same time.
[0040] On the basis of activating at least one target resource, the data collected by the collector can be stored in the target resource in the activated state based on the consistent hashing algorithm.
[0041] S103: In response to a triggering operation to shrink the resource pool, select a resource that meets the shrinking requirement from resources currently in a dormant state to shrink the resource pool.
[0042] In an embodiment of the present application, a user can trigger the resource pool to shrink by issuing a shrink control instruction, wherein the shrink control instruction includes at least the shrink capacity. Then, a resource that meets the shrink requirement is selected from the resources currently in a dormant state to shrink the resource pool, that is, at least one resource is selected from the dormant resources, and the sum of the capacities of the selected resources is equal to the shrink capacity. Furthermore, if there is no data storage in the selected resource, it is directly removed from the resource pool to achieve the purpose of shrinking the resource pool.
[0043] For example, see Figure 1c , which shows a schematic diagram of resource pool shrinkage. Among them, according to the storage capacity allocated by the user (USER), resources 1, resource 2 and resource 3 are activated, and each collector (IPC) belonging to the user evenly stores the collected IPC data streams in resource 1, resource 2 and resource 3 through a consistent hashing algorithm. In response to the trigger operation of shrinking the resource pool, resources that meet the shrinkage requirements are selected from the resources currently in a dormant state to shrink the resource pool. For example, if the shrinkage capacity specified by the user is 3T, the dormant resource 20 (capacity is 3T) is deleted from the resource pool to achieve the purpose of shrinking.
[0044] In an embodiment of the present application, a certain amount of resources are activated to be responsible for data storage according to the storage capacity allocated by the user, and other resources are in a dormant state. When it is necessary to shrink the resource pool, resources that meet the capacity requirements are directly selected from the dormant resources to shrink the resource pool. Since the dormant resources do not store the data collected by the collector, data migration is not required during shrinkage, thereby reducing the operation time of shrinking the resource pool, reducing the performance pressure of disk reading and writing, and ultimately achieving the purpose of optimizing the resource pool management effect.
[0045] Figure 2a is a flow chart of a resource management method according to a second embodiment of the present application. This embodiment optimizes the operation of activating at least one target resource in a resource pool according to the storage capacity allocated by the user on the basis of the above embodiment. Figure 2a , the method comprising:
[0046] S201: Initialize the usage status of all resources in the resource pool to a dormant state.
[0047] In the dormant state, the data stored in the resource is in a read-only state and can be deleted.
[0048] S202: sort all resources in a dormant state in descending order according to resource capacity.
[0049] For example, see Figure 2b , which shows a schematic diagram of the structure of the resources in the resource pool after descending sorting, with the resource 2 with the largest capacity being ranked first and the resource 20 with the smallest capacity being ranked last.
[0050] S203. According to the storage capacity allocated by the user, at least one target resource is activated in descending order of resource capacity, so that the data collected by the collector is stored in the activated target resource based on the consistent hashing algorithm.
[0051] After all resources in the dormant state are sorted in descending order according to resource capacity, at least one target resource is activated in the order of resource capacity from large to small, wherein the total resource capacity of the at least one target resource after activation is not less than the storage capacity allocated by the user. That is, each resource is activated in turn in the order of resource capacity from large to small until the sum of the total capacity of the activated resources is not less than the storage capacity allocated by the user. For example, if the storage capacity allocated by the user is 10T, then only resource 2 with a capacity of 18T, which is ranked first, needs to be activated, and other resources remain in the dormant state.
[0052] It should be noted that the reason why the resource with the largest capacity is activated first is to ensure that the number of activated resources is reduced when the user subsequently allocates storage capacity. For example, after allocating 10T storage capacity, the user allocates 5T storage capacity. At this time, the activated resource 2 (with a capacity of 18T) can fully meet the demand, and there is no need to activate other resources.
[0053] S204: In response to a triggering operation to shrink the resource pool, select a resource that meets the shrinking requirement from resources currently in a dormant state to shrink the resource pool.
[0054] In an embodiment of the present application, by sorting each resource in descending order of capacity and then activating them in order of resource capacity from large to small, it can be ensured that the number of activated resources is minimal while meeting the user's storage needs, thereby facilitating the management of resources in the resource pool.
[0055] Figure 3a is a flowchart of the resource management method of the third embodiment of the present application. This embodiment is optimized based on the above embodiment. Figure 3a , the method comprising:
[0056] S301: Initialize the usage status of all resources in the resource pool to a dormant state.
[0057] In the embodiment of the present application, the use state of the resource includes a dormant state and an activated state. In the dormant state, the data stored in the resource is in a read-only state and allows deletion; in the activated state, the data stored in the resource is in a readable and writable state.
[0058] S302: Activate at least one target resource in the resource pool according to the storage capacity allocated by the user.
[0059] The process of activating at least one target resource in the resource pool according to the storage capacity allocated by the user can be referred to the description of the above embodiment, which will not be repeated here.
[0060] This embodiment mainly describes the process of storing the data collected by the collector into the activated resource. Because the data collected by the collector is stored based on the consistent hashing algorithm, it is necessary to use a fixed value as the basic value of the hash calculation in advance according to the name of the resource constituting the resource pool plus the suffix number, and form a ring space with this fixed value. For example, see Figure 3b , which shows a schematic diagram of a hash ring, where the size of the ring space is 2 32 , the 32 hash values calculated by each resource are evenly distributed on the hash ring. For the specific process of storing data based on the consistent hashing algorithm, see S303-S305.
[0061] It should be noted here that the virtual node corresponding to the resource in the dormant state on the hash ring is in a read-only state, which means that the collected data cannot be stored in the resource corresponding to the virtual node; the virtual node corresponding to the resource in the activated state on the hash ring is in a read-write state, which means that the collected data can be stored in the resource corresponding to the virtual node.
[0062] S303: Calculate a hash value based on the collector's own device code and a preset hash function.
[0063] S304: Search for a target virtual node with a neighboring hash value in a preset order on the hash ring.
[0064] S305: When it is determined that the target virtual node is in a read-write allowed state and the number of collectors that have executed the operation of storing data in the resource corresponding to the target virtual node is less than a first preset number, the collected data is stored in the target resource corresponding to the target virtual node.
[0065] When storing data in an activated resource, a hash value is calculated based on the collector's own device code and the preset hash function, and the nearest virtual node is searched in a preset order (e.g. clockwise) on the hash ring, and the state of the virtual node is determined. If the virtual node is readable and writable (i.e., read and write are allowed), it means that the resource corresponding to the virtual node is in an activated state and can be selected for data storage. If the virtual node is in a read-only state, it means that the resource corresponding to the virtual node is in a dormant state and cannot be used to store data. In this case, it is necessary to skip the virtual node and continue to search for the next nearest virtual node clockwise until a readable and writable virtual node is encountered.
[0066] Furthermore, considering the read and write pressure of the disk, each virtual node on the hash ring supports a first preset number of collectors to store data in the resource corresponding to the virtual node, and each resource supports a second preset number of collectors for data storage, where the second preset number is equal to the product of the first preset number and the number of virtual nodes corresponding to a resource. Therefore, after determining that the target virtual node is in a read-write allowed state, it is also necessary to determine whether the number of collectors that have executed the data storage in the resource corresponding to the target virtual node is less than the first preset number. If so, the collected data is stored in the target resource corresponding to the target virtual node; if not, the target virtual node is skipped and the next adjacent readable and writable virtual node is searched clockwise.
[0067] For example, each resource supports 512 IPC storages, so its corresponding 32 virtual nodes, each of which supports 16 IPC storages. If a virtual node in a readable and writable state has been selected by 16 IPCs, it is necessary to skip and search for the next adjacent readable and writable virtual node clockwise.
[0068] It should be noted here that the currently activated resource node needs to meet all IPC storage requirements configured by the user. When the IPC does not find an available virtual node on the hash ring, the system needs to activate another virtual node.
[0069] S306: In response to a triggering operation to shrink the resource pool, select a resource that meets the shrinking requirement from the resources currently in a dormant state to shrink the resource pool.
[0070] In an optional embodiment, in response to a trigger operation for shrinking the resource pool, resources that meet the shrinkage requirements are selected from resources that are currently in a dormant state to shrink the resource pool, including: in response to a trigger operation for shrinking the resource pool, at least one resource is selected from resources that are currently in a dormant state; wherein the sum of the resource capacity of at least one selected resource is the same as the shrinkage capacity; deleting the at least one selected resource from the resource pool, and deleting the virtual node corresponding to the deleted resource on the hash ring.
[0071] In the embodiment of the present application, by judging the state of a virtual node and determining the number of times the virtual node has been selected by other collectors, it is determined whether to store the data collected by the current collector in the resource corresponding to the virtual node. This not only achieves accurate storage of data in the activated resource, but also takes into account the disk read and write pressure of the resource.
[0072] Figure 4 is a flowchart of the resource management method of the fourth embodiment of the present application. This embodiment is optimized based on the above embodiment. Figure 4 , the method comprising:
[0073] S401: Initialize the usage status of all resources in the resource pool to a dormant state.
[0074] S402. Activate at least one target resource in the resource pool according to the storage capacity allocated by the user, so that the data collected by the collector is stored in the activated target resource based on the consistent hashing algorithm.
[0075] S403: If an activated target resource is abnormal, the virtual node of the target resource on the hash ring is adjusted to an abnormal state.
[0076] In an embodiment of the present application, if an activated target resource encounters an abnormal situation during the data storage process and cannot work normally, the target resource is adjusted to a dormant state, that is, the abnormal resource is prohibited from storing data. At the same time, the virtual node of the target resource on the hash ring is adjusted to an abnormal state to ensure that the virtual node corresponding to the target resource is no longer hit by data selection and storage. It should be noted that when the target resource is dormant, the data (IPC data stream) currently stored on the target resource needs to be re-selected for storage by the resource virtual node.
[0077] S404. Select at least one backup resource whose total capacity is not less than the capacity of the abnormal target resource from other resources in a dormant state, and activate at least one backup resource so that the backup resource continues to store the data collected by the collector.
[0078] When adjusting abnormal resources to a dormant state, in order to ensure user needs, the total capacity of currently activated resources is compared with the total capacity required by users. If the total capacity of currently activated resources is less than the total capacity required by users, backup resources with the same capacity or greater than the capacity of abnormal resources are awakened from other dormant resources so that the backup resources can continue to store the data collected by the collector.
[0079] S405: In response to a triggering operation to shrink the resource pool, select a resource that meets the shrinking requirement from resources currently in a dormant state to shrink the resource pool.
[0080] It should be noted here that if a resource that meets the scaling requirement is selected from resources that are currently in a dormant state, and the resource is adjusted to a dormant state due to an exception, a small amount of data is stored in the selected resource. When scaling down, the small amount of data stored in the selected resource needs to be migrated to other resources in an activated state first, and then the selected resource that is dormant due to the exception is deleted from the resource pool.
[0081] In the embodiment of the present application, when a resource is abnormal, the abnormal resource is put into hibernation, and a resource with a capacity not less than the abnormal resource is selected to work in its place, thereby ensuring the security of data storage and realizing flexible resource management. Moreover, even if the resource selected during capacity reduction is a dormant resource due to an abnormality, only a small amount of data migration is required, the time for capacity reduction is short, and the performance pressure on the disk is small.
[0082] Figure 5a is a flowchart of the resource management method of the fifth embodiment of the present application. This embodiment is optimized based on the above embodiment. Figure 5a , the method comprising:
[0083] S501: Initialize the usage status of all resources in the resource pool to a dormant state.
[0084] In the embodiment of the present application, the use state of the resource includes a dormant state and an activated state. In the dormant state, the data stored in the resource is in a read-only state and allows deletion; in the activated state, the data stored in the resource is in a readable and writable state.
[0085] S502: Activate at least one target resource in the resource pool according to the storage capacity allocated by the user, so that the data collected by the collector is stored in the activated target resource based on the consistent hashing algorithm.
[0086] S503: If the user deletes a storage capacity allocated at a certain time, some resources in an activated state are adjusted to a dormant state according to the remaining storage capacity of the user.
[0087] In the embodiment of the present application, the user may allocate storage capacity multiple times, for example, see Figure 5b , which shows that the user has allocated storage capacity three times (USER1, USER2, USER3), each allocated storage capacity is 10T, and resources 2, resource 1 and resource 3 in the corresponding resource pool are activated.
[0088] If the user deletes the storage capacity allocated at a certain time, the storage system will recover the corresponding capacity, and adjust some resources in the activated state to the dormant state according to the remaining storage capacity of the user. In an optional implementation, according to the remaining storage capacity of the user, some resources in the activated state are adjusted to the dormant state, including: sorting the resources in the activated state in descending order according to the resource capacity; adjusting the resources in the activated state to the dormant state in order from small to large, until the total resource capacity of the remaining resources in the activated state is not less than the remaining storage capacity of the user. It should be noted that the reason for dormancy in order from small to large is to ensure that the number of resources in the activated state is as small as possible, which is convenient for management and does not activate resources frequently. Moreover, when a resource is dormant, the data currently stored on the resource (IPC data stream) needs to be re-selected as a resource virtual node for storage.
[0089] For example, if the user deletes USER2 and USER3, then the activated resources 1 and 3 can be adjusted to the dormant state accordingly, and the remaining resource 2 (18T capacity) is sufficient for the user to use.
[0090] S504: In response to a triggering operation to shrink the resource pool, select a resource that meets the shrinking requirement from resources currently in a dormant state to shrink the resource pool.
[0091] It should be noted here that if a resource that meets the scaling requirement is selected from resources that are currently in a dormant state, and the resource is adjusted to a dormant state because the user deletes the storage capacity, then a small amount of data is stored in the selected resource. When scaling down, the small amount of data stored in the selected resource needs to be migrated to other resources in an activated state first, and then the selected resource that is abnormally dormant needs to be deleted from the resource pool.
[0092] In the embodiment of the present application, when a user deletes storage capacity, some activated resources are adjusted to a dormant state, waiting to be activated next time. This ensures that data is stored within the minimum range of resources at any time, facilitating resource pool shrinkage management.
[0093] Figure 6: is a flowchart of the resource management method of the sixth embodiment of the present application. This embodiment is optimized on the basis of the above embodiments. In the embodiment of the present application, the resource status includes not only the use status (including the dormant status and the activated status), but also the loading status. The loading status includes online and offline. Among them, when the loading status is online, it means that the resource is available; when the loading status is offline, it means that the resource cannot be used due to an abnormality. See Figure 6 , the method comprising:
[0094] S601. Update and record changes in resource usage status and loading status in real time in a database.
[0095] When an abnormal situation occurs in a resource and the resource becomes unavailable, the loading status of the resource is updated to the offline status and is synchronously updated to the database, indicating that the resource cannot perform data read and write operations.
[0096] The resource usage status is divided into two states: dormant state and activated state, which are used to distinguish whether the resource is currently activated by the resource pool to provide data storage services for the data stream. After the resource pool is divided, the usage status of all resources is initialized to dormant state, and the status of all resources is marked as "unused" in the database. When a resource is activated, the usage status of the resource is updated to "in use" in the database. At the same time, if a resource is adjusted from an activated state to a dormant state, the resource's mark "in use" is updated to "unused" in the database. In this way, the changes in resource usage status and loading status can be updated and recorded in real time through the database.
[0097] S602: When the device is restarted, the resources are initialized according to the usage status and loading status of each resource recorded in the database.
[0098] For example, if the resource usage status in the database is marked as "in use", the resource is activated in the resource pool during initialization; and if the resource usage status is marked as "not in use", the resource is initialized to a dormant state in the resource pool, that is, a dormant state resource only supports data reading and deletion, but not data writing.
[0099] In an embodiment of the present application, the changes in resource usage status and loading status are recorded in a database, so that when an abnormal situation occurs and the device needs to be restarted, initialization can be completed according to the status data recorded in the database, so that the resources in the resource pool continue to work according to the status before the restart.
[0100] Figure 7 3 is a schematic diagram of the structure of a resource management device according to the seventh embodiment of the present application. This embodiment is applicable to the case where a resource pool of a monitoring system is managed for shrinkage. Referring to FIG. 3 , the device includes:
[0101] The first initialization module 701 is used to initialize the use status of all resources in the resource pool to a dormant state; wherein, in the dormant state, the data stored in the resources is in a read-only state and allows deletion;
[0102] A resource activation module 702, configured to activate at least one target resource in the resource pool according to the storage capacity allocated by the user, so that the data collected by the collector is stored in the activated target resource based on the consistent hashing algorithm;
[0103] The shrinkage management module 703 is used to select resources that meet the shrinkage requirements from the resources currently in the dormant state to shrink the resource pool in response to a triggering operation to shrink the resource pool.
[0104] Based on the above embodiment, optionally, the resource activation module includes:
[0105] A first sorting unit, used to sort all resources in a dormant state in descending order according to resource capacity;
[0106] The activation unit is used to activate at least one target resource according to the storage capacity allocated by the user and in the order of resource capacity from large to small; wherein the total resource capacity of the at least one target resource after activation is not less than the storage capacity allocated by the user.
[0107] Based on the above embodiment, optionally, the virtual node corresponding to the resource in the dormant state on the hash ring is in a read-only state; the virtual node corresponding to the resource in the activated state on the hash ring is in a read-write state.
[0108] Based on the above embodiment, optionally, the device further includes:
[0109] A first state adjustment module is used to adjust a certain activated target resource to a dormant state if an abnormality occurs to the target resource, and to adjust the virtual node of the target resource on the hash ring to an abnormal state;
[0110] The first screening module is used to select at least one spare resource whose total capacity is not less than the capacity of the abnormal target resource from other resources in a dormant state, and activate at least one spare resource so that the spare resource continues to store the data collected by the collector.
[0111] Based on the above embodiment, optionally, each virtual node on the hash ring supports a first preset number of collectors to store data in the resource corresponding to the virtual node, and each resource supports a second preset number of collectors to store data.
[0112] Based on the above embodiment, optionally, the process in which the collector stores the collected data in the activated target resource based on the consistent hashing algorithm includes:
[0113] A hash value is calculated based on the collector's own device code and the preset hash function;
[0114] Search for the target virtual node with a neighboring hash value in a preset order on the hash ring;
[0115] When it is determined that the target virtual node is in a read-write allowed state and the number of collectors that have executed data storage in the resource corresponding to the target virtual node is less than a first preset number, the collected data is stored in the target resource corresponding to the target virtual node.
[0116] Based on the above embodiment, optionally, the shrinkage management module includes:
[0117] A resource screening unit, configured to select at least one resource from the resources currently in a dormant state in response to a triggering operation of shrinking the resource pool; wherein the sum of the resource capacities of the at least one selected resource is the same as the shrinking capacity;
[0118] The resource deletion unit is used to delete at least one selected resource from the resource pool and delete the virtual node corresponding to the deleted resource on the hash ring.
[0119] Based on the above embodiment, optionally, the device further includes:
[0120] The second state adjustment module is used to adjust part of the resources in the activated state to the dormant state according to the remaining storage capacity of the user if the user deletes the storage capacity allocated at a certain time.
[0121] Based on the above embodiment, optionally, the second state adjustment module includes:
[0122] The second sorting unit sorts the activated resources in descending order according to resource capacity;
[0123] The state adjustment unit is used to adjust the resources in the activated state to the dormant state in order from small to large, until the total resource capacity of the remaining resources in the activated state is not less than the remaining storage capacity of the user.
[0124] Based on the above embodiment, optionally, the resource status further includes a loading status, and the loading status includes online and offline;
[0125] When the loading status is online, it means that the resource is available; when the loading status is offline, it means that the resource is unavailable due to an exception.
[0126] Based on the above embodiment, optionally, the device further includes:
[0127] Update record module, used to update the usage status and loading status changes of record resources in real time in the database;
[0128] The second initialization module is used to initialize resources according to the usage status and loading status of each resource recorded in the database when the device is restarted.
[0129] The resource management device provided in the embodiments of the present application can execute the resource management method provided in any embodiment of the present application, and has the corresponding functional modules and beneficial effects of the execution method.
[0130] Figure 8 Schematic diagram of the structure of an electronic device provided in the eighth embodiment of the present application. Figure 8 The electronic device provided in the embodiment of the present application includes: one or more processors 802 and a memory 801; the processor 802 in the electronic device may be one or more, Figure 8 A processor 802 is taken as an example; the memory 801 is used to store one or more programs; the one or more programs are executed by one or more processors 802, so that one or more processors 802 implement a resource management method as any one of the embodiments of the present application.
[0131] The electronic device may further include: an input device 803 and an output device 804 .
[0132] The processor 802, memory 801, input device 803 and output device 804 in the electronic device can be connected via a bus or other means. Figure 8 The example of connecting through bus is taken in the following.
[0133] The storage device 801 in the electronic device is a computer-readable storage medium that can be used to store one or more programs, which can be software programs, computer executable programs, and modules, such as program instructions / modules corresponding to the resource management method provided in the embodiment of the present application. The processor 802 executes various functional applications and data processing of the electronic device by running the software programs, instructions, and modules stored in the storage device 801, that is, implementing the resource management method in the above method embodiment.
[0134] The storage device 801 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 801 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 801 may further include a memory remotely arranged relative to the processor 802, and these remote memories may be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0135] The input device 803 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the electronic device. The output device 804 may include a display device such as a display screen.
[0136] Furthermore, when one or more programs included in the electronic device are executed by the one or more processors 802, the program performs the following operations:
[0137] Initialize the usage status of all resources in the resource pool to a dormant state; wherein, in the dormant state, the data stored in the resources is in a read-only state and allows deletion;
[0138] According to the storage capacity allocated by the user, at least one target resource in the resource pool is activated, so that the data collected by the collector is stored in the activated target resource based on the consistent hashing algorithm;
[0139] In response to a triggering operation to shrink the resource pool, a resource that meets the shrinking requirement is selected from resources currently in a dormant state to shrink the resource pool.
[0140] Of course, those skilled in the art can understand that when one or more programs included in the above-mentioned electronic device are executed by one or more processors 802, the program can also perform related operations in the resource management method provided in any embodiment of the present application.
[0141] In one embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the program is used to execute a resource management method. The method includes:
[0142] Initialize the usage status of all resources in the resource pool to a dormant state; wherein, in the dormant state, the data stored in the resources is in a read-only state and allows deletion;
[0143] According to the storage capacity allocated by the user, at least one target resource in the resource pool is activated, so that the data collected by the collector is stored in the activated target resource based on the consistent hashing algorithm;
[0144] In response to a triggering operation to shrink the resource pool, a resource that meets the shrinking requirement is selected from resources currently in a dormant state to shrink the resource pool.
[0145] Optionally, when the program is executed by a processor, it can also be used to execute the method provided in any embodiment of the present application.
[0146] The computer storage medium of the embodiment of the present application can adopt any combination of one or more computer-readable media. Computer-readable media can be computer-readable signal media or computer-readable storage media. Computer-readable storage media can be, for example, - but not limited to - electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples (non-exhaustive lists) of computer-readable storage media include: electrical connections with one or more wires, portable computer disks, hard disks, random access memories (Random Access Memory, RAM), read-only memories (Read Only Memory, ROM), erasable programmable read-only memories (Erasable Programmable Read Only Memory, EPROM), flash memory, optical fibers, portable CD-ROMs, optical storage devices, magnetic storage devices, or any suitable combination of the above. Computer-readable storage media can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0147] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to: electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0148] The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, radio frequency (RF), etc., or any suitable combination of the above.
[0149] The computer program code for performing the operation of the present application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages (such as "C" language or similar programming languages). The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer, partially on the remote computer, or completely on the remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network (for example, including a local area network (LAN) or a wide area network (WAN)), or, it can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).
[0150] Note that the above are only preferred embodiments of the present application and the technical principles used. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the appended claims.
Claims
1. A resource management method, characterized in that: include: Initialize the usage status of all resources in the resource pool to a dormant state; wherein, in the dormant state, the data stored in the resources is in a read-only state and allows deletion; According to the storage capacity allocated by the user, at least one target resource in the resource pool is activated, so that the data collected by the collector is stored in the activated target resource based on the consistent hashing algorithm; In response to a triggering operation for shrinking the resource pool, selecting a resource that meets the shrinking requirement from resources currently in a dormant state to shrink the resource pool; Among them, the virtual nodes corresponding to the resources in the dormant state on the hash ring are in a read-only state; the virtual nodes corresponding to the resources in the activated state on the hash ring are in a read-write state; The process of storing the data collected by the collector in the activated target resource based on the consistent hashing algorithm includes: A hash value is calculated based on the collector's own device code and the preset hash function; Searching for a target virtual node adjacent to the hash value on the hash ring in a preset order; When it is determined that the target virtual node is in the read-write allowed state and the number of collectors that have executed the operation of storing data in the resource corresponding to the target virtual node is less than a first preset number, the collected data is stored in the target resource corresponding to the target virtual node.
2. The method according to claim 1, characterized in that Activating at least one target resource in the resource pool according to the storage capacity allocated by the user, comprising: Sort all dormant resources in descending order according to resource capacity; According to the storage capacity allocated by the user, at least one target resource is activated in descending order of resource capacity; wherein the total resource capacity of the at least one target resource after activation is not less than the storage capacity allocated by the user.
3. The method according to claim 1, characterized in that The method further comprises: If an activated target resource is abnormal, the target resource is adjusted to a dormant state, and the virtual node of the target resource on the hash ring is adjusted to an abnormal state; At least one spare resource whose sum of capacities is not less than the capacity of the abnormal target resource is selected from other resources in a dormant state, and the at least one spare resource is activated so that the spare resource continues to store the data collected by the collector.
4. The method according to claim 1, characterized in that: In response to a triggering operation for shrinking the resource pool, selecting a resource that meets the shrinking requirement from resources currently in a dormant state to shrink the resource pool includes: In response to a triggering operation of shrinking the resource pool, at least one resource is selected from the resources currently in a dormant state; wherein the sum of the resource capacity of the at least one selected resource is the same as the shrinking capacity; The at least one selected resource is deleted from the resource pool, and the virtual node corresponding to the deleted resource is deleted on the hash ring.
5. The method according to claim 1, characterized in that The method further comprises: If the user deletes the allocated storage capacity, the activated resources will be sorted in descending order according to the resource capacity; The resources in the activated state are adjusted to the dormant state in order from small to large, until the total resource capacity of the remaining resources in the activated state is not less than the remaining storage capacity of the user.
6. A resource management device, characterized in that: include: An initialization module, used to initialize the use status of all resources in the resource pool to a dormant state; wherein, in the dormant state, the data stored in the resources is in a read-only state and allows deletion; A resource activation module, used to activate at least one target resource in the resource pool according to the storage capacity allocated by the user, so that the data collected by the collector is stored in the target resource in the activated state based on the consistent hashing algorithm; A shrinkage management module, configured to, in response to a trigger operation for shrinking the resource pool, select resources that meet the shrinkage requirement from resources currently in a dormant state to shrink the resource pool; Among them, the virtual nodes corresponding to the resources in the dormant state on the hash ring are in a read-only state; the virtual nodes corresponding to the resources in the activated state on the hash ring are in a read-write state; The process of storing the collected data in the activated target resource based on the consistent hashing algorithm includes: A hash value is calculated based on the collector's own device code and the preset hash function; Search for the target virtual node with a neighboring hash value in a preset order on the hash ring; When it is determined that the target virtual node is in a read-write allowed state and the number of collectors that have executed data storage in the resource corresponding to the target virtual node is less than a first preset number, the collected data is stored in the target resource corresponding to the target virtual node.
7. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the resource management method according to any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the resource management method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Elastic capacity expansion method, elastic capacity expansion device and elastic capacity expansion system
CN106302210A
Method and apparatus for controlling virtual broadband access service, and communication system
CN107547317A