Resource query method and device of peer-to-peer network node and storage medium

By configuring network node groups in the p2p network and adopting a consistent hash query method, the problem of insufficient efficiency and reliability of cache service in the existing p2p mode is solved, and efficient and reliable cache service is achieved.

CN119691253APending Publication Date: 2025-03-25BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311246281.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-25
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

In the existing p2p model, the cache service relies on traditional remote dictionary servers such as redis databases, resulting in improved cache efficiency and reliability.

Method used

By configuring a network node group in a network node in the resource pool, each network node group includes multiple network nodes, each network node provides storage units for storing resource files, and a consistent hash query method is used to determine the storage unit where the target resource is located, thereby providing caching services.

Benefits of technology

A new caching method is implemented, providing efficient and reliable caching services for the p2p model, reducing dependence on the central server, and improving the accuracy and efficiency of resource query.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119691253A_ABST
    Figure CN119691253A_ABST
Patent Text Reader

Abstract

The invention relates to a resource query method and device for peer-to-peer network nodes and a storage medium. The method comprises the steps of adding a random value to a resource identifier of a target resource to obtain a target value under the condition that a resource query request which is initiated by a client and used for querying the target resource is received; determining a target network node group from a plurality of network node groups of a resource pool according to node information of a target network node corresponding to the client; performing a consistent hash query operation on each storage unit in the target network node group through the target value, and determining a target storage unit where the target resource is located; and returning the node identifier of the first network node providing the target storage unit to the client, so that the target network node obtains the target resource from the first network node. The invention provides a new caching mode for providing caching service for the p2p.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular to a resource query method, device, storage medium and electronic device for a peer-to-peer network node. Background Art

[0002] Peer to peer (p2p) is a computer network architecture in which all participants have the same capabilities and permissions and share resources and services equally. In a peer-to-peer network, it no longer relies on the traditional client-server model.

[0003] In the existing p2p model, terminal boxes, routers, etc. act as network nodes. After reporting the node information of the network nodes, the node information is sent to the cache cluster through the forwarding node cluster. The cache cluster provides cache services through the remote dictionary server redis database. Summary of the invention

[0004] The present application provides a resource query method, device, storage medium and electronic device for a peer network node, so as to provide a new caching method to provide caching services for p2p.

[0005] In the first aspect, the present application provides a resource query method for a peer network node, comprising: upon receiving a resource query request initiated by a client for querying a target resource, adding a random value to the resource identifier of the target resource to obtain a target value; determining a target network node group from multiple network node groups in a resource pool based on the node information of the target network node corresponding to the client, wherein each of the network node groups includes multiple network nodes, each of the network nodes is provided with a storage unit, and each of the storage units is used to store a resource file of the network node; performing a consistent hash query operation on each storage unit in the target network node group through the target value to determine the target storage unit where the target resource is located; returning the node identifier of the first network node that provides the target storage unit to the client, so that the target network node obtains the target resource from the first network node.

[0006] In the second aspect, the present application provides a resource query device for a peer network node, including: a processing module, which is used to increase the resource identifier of the above-mentioned target resource by a random value to obtain a target value when a resource query request initiated by a client for querying a target resource is received; a first determination module, which is used to determine the target network node group from multiple network node groups in a resource pool according to the node information of the target network node corresponding to the above-mentioned client, wherein each of the above-mentioned network node groups includes multiple network nodes, each of the above-mentioned network nodes is provided with a storage unit, and each of the above-mentioned storage unit is used to store a resource file of the above-mentioned network node; a second determination module, which is used to perform a consistent hash query operation on each storage unit in the above-mentioned target network node group through the above-mentioned target value to determine the target storage unit where the above-mentioned target resource is located; a sending module, which is used to return the node identifier of the first network node that provides the above-mentioned target storage unit to the above-mentioned client, so that the above-mentioned target network node obtains the above-mentioned target resource from the above-mentioned first network node.

[0007] As an optional example, the above-mentioned device also includes: a creation module, which is used to obtain the node information of all network nodes under the above-mentioned peer network before receiving the above-mentioned resource query request; classify the above-mentioned network nodes according to the above-mentioned node information to obtain multiple above-mentioned network node groups; divide each of the above-mentioned network nodes into one or more of the above-mentioned storage units according to the cache resources of a predetermined size; and store each of the above-mentioned resource files in one of the above-mentioned storage units.

[0008] As an optional example, the creation module includes: a division unit, used to determine the disk resource size and bandwidth resource size of the network node; dividing each M-sized disk resource and each N-sized bandwidth resource into one of the storage units until the disk resources or bandwidth resources of the network node are filled.

[0009] As an optional example, the above-mentioned processing module includes: a calculation unit, used to randomly select a value from a pre-set numerical range as the above-mentioned random value; map the above-mentioned target resource into a resource value according to the resource-value mapping relationship; and determine the sum of the above-mentioned resource value and the above-mentioned random value as the above-mentioned target value.

[0010] As an optional example, the above-mentioned second determination module includes: a first determination unit, used to map the resources in each resource file stored on each storage unit in the above-mentioned target network node group to a virtual ring in the hash value space; map the target value to the virtual ring, and determine the position of the target value on the virtual ring; determine the resource corresponding to the position as the target resource; and determine the storage unit where the target resource is located as the target storage unit.

[0011] As an optional example, the node information includes at least one of the uplink bandwidth of the network node, the user identifier of the client, the network address translation type, the client component version, the IPv6 network support type and the geographical location. The first determination module includes: a second determination unit, used to determine the network nodes with the same IPv6 network support type in the network nodes as a group of network node groups; and / or, determine the network nodes with the same client component version in the network nodes as a group of network node groups; and / or, determine the network nodes with the same network address translation type in the network nodes as a group of network node groups; and / or, determine the network nodes with the same user identifier of the client in the network nodes in the same identifier interval as a group of network node groups; and / or, determine the network nodes with the uplink bandwidth in the same bandwidth interval in the network nodes as a group of network node groups; and / or, determine the network nodes with the geographical location in the same area in the network nodes as a group of network node groups; determine the network node group corresponding to the node information of the target network node as the target network node group. 。

[0012] As an optional example, the second determination unit includes: a determination subunit, used to determine the priority of each group of network node groups when the target network node corresponds to multiple groups of network node groups; and determine the network node group with the highest priority as the target network node group.

[0013] In a third aspect, the present application provides an electronic device comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus, wherein the memory stores a computer program, and the processor is configured to implement any one of the resource query methods for the peer network nodes when executing the computer program.

[0014] In a fourth aspect, the present application further provides a computer storage medium storing computer executable instructions, wherein the computer executable instructions are used to execute any of the above-mentioned resource query methods for peer network nodes of the present application.

[0015] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: The present application provides a new solution for providing cache services for the p2p mode. In this solution, a network node group is configured in the network nodes in the resource pool, each of the above network node groups includes multiple network nodes, each of the above network nodes is provided with a storage unit, and each of the above storage units is used to store a resource file of the above network node, and a cache service is provided through the resource pool. If a resource query request is received, the target resource is queried by adding a random value to the resource identifier of the target resource to be queried, and a consistent hash query operation is performed on each storage unit in the above target network node group to determine the target storage unit where the above target resource is located, so that the client can obtain the target resource from the target storage unit. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0018] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0019] Figure 1 A flowchart of a resource query method for a peer network node provided in an embodiment of the present application;

[0020] Figure 2 A system diagram of a resource query method for a peer network node provided in an embodiment of the present application;

[0021] Figure 3 A flowchart of another resource query method of a peer network node provided in an embodiment of the present application;

[0022] Figure 4 A flowchart of another resource query method of a peer network node provided in an embodiment of the present application;

[0023] Figure 5 A flowchart of another resource query method of a peer network node provided in an embodiment of the present application;

[0024] Figure 6 A flowchart of another resource query method of a peer network node provided in an embodiment of the present application;

[0025] Figure 7 A schematic diagram of a hash structure of a resource query method for a peer network node provided in an embodiment of the present application;

[0026] Figure 8 A schematic diagram of the structure of a resource query device for a peer network node provided in an embodiment of the present application;

[0027] Fig. 9 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0028] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0029] The disclosure below provides many different embodiments or examples to implement different structures of the present invention. In order to simplify the disclosure of the present invention, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present invention. In addition, the present invention can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0030] In the prior art, redis provides a technical problem of providing cache service for p2p. The present application provides a resource query method of a peer network node to provide a new cache method to provide cache service for p2p.

[0031] Figure 1 A flowchart of a resource query method for a peer network node provided in an embodiment of the present application. Figure 1 As shown, the resource query method of the above-mentioned peer network node includes:

[0032] S102, when receiving a resource query request initiated by a client for querying a target resource, adding a random value to a resource identifier of the target resource to obtain a target value;

[0033] S104, determining a target network node group from a plurality of network node groups in a resource pool according to the node information of the target network node corresponding to the client, wherein each network node group includes a plurality of network nodes, each network node is provided with a storage unit, and each storage unit is used to store a resource file of the network node;

[0034] S106, performing a consistent hash query operation on each storage unit in the target network node group according to the target value to determine the target storage unit where the target resource is located;

[0035] S108: Return the node identifier of the first network node providing the target storage unit to the client, so that the target network node obtains the target resource from the first network node.

[0036] The above-mentioned peer-to-peer network is a p2p network, and the network nodes under the p2p network can be routers, TV boxes of TV sets, etc. The p2p network caches the node information of each network node. When a network node needs certain resources such as video, audio, images, etc., it can obtain the resource from other nodes without having to obtain it from the central server. The decision of which network node to obtain the resource from can be determined by the node information cached in the p2p network.

[0037] The above-mentioned client can be a client associated with a network device and used to manage the network device. For example, if the network device is a household router, the client can be a user's mobile phone, and the user can use the client to set the content of the network device, upload the device information of the network device, initiate a resource query request, etc.

[0038] Figure 2 This is a system application diagram of the p2p node cache of this embodiment. In p2p, network nodes such as terminal boxes can report node information, and the node information is forwarded to the cache cluster through the forwarding nodes in the forwarding cluster and cached by the cache cluster. If the client wants to query certain resources, it can send a resource query request to the cache cluster through the forwarding cluster, and the cache cluster queries the first network node according to the resource query request.

[0039] The resource identifier of the target resource may be an identifier for uniquely marking the resource, indicating that the identifier may correspond to a numerical value, or the identifier may be a numerical value. The combination of the identifier and the random value is the target value, and the random value may be a pre-set numerical value. The random value is added to reduce or avoid the influence of resource errors during the query process.

[0040] In this embodiment, the number of resources in the p2p network will change. Whenever a new resource is generated, a resource identifier can be assigned to the resource, and whenever a resource is deleted, the corresponding resource identifier can be deleted. The number of resources is unlimited.

[0041] The above-mentioned resource pool is a pool composed of network nodes that can provide cache services. In this pool, all network nodes are divided into multiple network node groups, each network node group includes multiple network nodes, each network node provides one or more storage units, and each storage unit is used to store a resource file. Then, the resources are stored in the network nodes of the network node group. When the target resource is to be queried, the target storage unit in the network node group where the target resource is located is queried according to the target value. The query method uses a consistent hash query method. The network node where the queried target storage unit is located is the first network node, and the p2p client can obtain the target resource from the first network node. The first network node can be one or more. If there are multiple first network nodes, they can be preferentially scheduled according to the network load of each first network node (the smaller the load, the higher the priority). All network nodes under the p2p system are evenly scheduled to avoid excessive load on a single network node.

[0042] The present application provides a new solution for providing cache services for p2p mode. In this solution, a network node group is configured in the network nodes in the resource pool, each network node group includes multiple network nodes, each network node is provided with a storage unit, and each storage unit is used to store a resource file of the network node, and a cache service is provided through the resource pool. If a resource query request is received, the target resource is queried by adding a random value to the resource identifier of the target resource to be queried, and a consistent hash query operation is performed on each storage unit in the target network node group to determine the target storage unit where the target resource is located, so that the client can obtain the target resource from the target storage unit.

[0043] As an alternative example, Figure 3 As shown, before receiving the resource query request, the above method also includes:

[0044] S302, obtaining node information of all network nodes in the peer-to-peer network;

[0045] S304, classifying the network nodes according to the node information to obtain multiple network node groups;

[0046] S306, dividing each network node into one or more storage units according to the cache resources of a predetermined size;

[0047] S308, storing each resource file in a storage unit.

[0048] Before receiving a resource query request, the cache mode must be configured. In this embodiment, all p2p network nodes are regarded as a resource pool, and the network nodes are the resources in the resource pool. The resources in the resource pool are divided into multiple network node groups, that is, each network node group includes one or more network nodes. For each network node in each network node group, one or more storage units are divided for it according to the cache resources it provides, and each storage unit is used to store a resource file.

[0049] like Figure 4 As shown, a network node in a resource pool can be divided into one or more storage units, and one or more storage units are placed in a storage block.

[0050] As an alternative example, Figure 5 As shown, cache resources include disk resources and bandwidth resources. Each network node is divided into one or more storage units according to the cache resources of a predetermined size, including:

[0051] S502, determining the disk resource size and bandwidth resource size of the network node;

[0052] S504: Divide each M-sized disk resource and each N-sized bandwidth resource into a storage unit until the disk resources or bandwidth resources of the network node are fully occupied.

[0053] In this embodiment, for each network node, when dividing the storage units, the size of the disk resource and bandwidth resource of the network node should be checked. For example, if the disk resource of the network node is 100G and the bandwidth resource is 100Mbps, and a resource file occupies 100M disk resource and 10Mbps bandwidth resource, then the network node can be divided into 10 storage units (disk resource has surplus, but bandwidth resource is full).

[0054] Since the size of disk resources and bandwidth resources provided by network nodes is different, different network nodes can be divided into different numbers of storage units. If the resources of the network node are insufficient, it is impossible to divide the storage units. Each storage unit is used to store a resource file. The size of the resource file is predetermined, and the size of the resource file of different resource pools can be different. Each resource file can include multiple resources, and a resource file is a collection of multiple resources.

[0055] As an optional example, when a resource query request initiated by a client for querying a target resource is received, a random value is added to the resource identifier of the target resource, and obtaining the target value includes: randomly selecting a value from a pre-set numerical range as the random value; mapping the target resource to a resource value based on a resource-to-value mapping relationship; and determining the sum of the resource value and the random value as the target value.

[0056] In this embodiment, each target resource may correspond to a resource identifier, which may be a numerical value or a string. If the resource identifier is a string, the resource identifier corresponds to a numerical value. The numerical value corresponding to the resource identifier is added to the random value to obtain the target value, and the storage unit where the target file is located is traversed through the target value.

[0057] As an alternative example, Figure 6 As shown, a consistent hash query operation is performed on each storage unit in the target network node group through the target value to determine that the target storage unit where the target resource is located includes:

[0058] S602, mapping resources in each resource file stored in each storage unit in the target network node group to a virtual ring in the hash value space;

[0059] S604, mapping the target value to the virtual ring, and determining the position of the target value on the virtual ring;

[0060] S606, determining the resource corresponding to the location as the target resource;

[0061] S608: Determine the storage unit where the target resource is located as the target storage unit.

[0062] In this embodiment, when querying the target storage unit where the target resource is located through the target value, a virtual ring can be established, such as Figure 7 As shown, the resource file is mapped to a consistent hash data structure, and each resource corresponds to a resource value in the virtual ring. When the target value is used to query the target resource, the target value can be mapped to the virtual ring to determine the position of a matching resource value. For example, if the target value mapped to the virtual ring is 10, then 10 corresponds to a position on the virtual ring. The resource at this position is the target resource to be acquired, and the node where the target resource is located is the target network node group, and the resource is stored in a storage space of one or some first network nodes in the target network node group. If there is no corresponding resource at this location, it is necessary to download the resource, and the downloaded resource is stored as the target resource in the storage space of the first network node corresponding to the location, and the client obtains the target resource from the first network node.

[0063] As an optional example, the node information includes at least one of the uplink bandwidth of the network node, the user identifier of the client, the network address translation type, the client component version, the IPV6 network (Internet Protocol Version 6) support type and the geographical location. Determining the target network node group from multiple network node groups in the resource pool according to the node information of the target network node corresponding to the client includes: determining the network nodes with the same IPV6 network support type among the network nodes as a group of network node groups; and / or, determining the network nodes with the same client component version among the network nodes as a group of network node groups; and / or, determining the network nodes with the same network address translation type among the network nodes as a group of network node groups; and / or, determining the network nodes with the same user identifier of the client in the network nodes in the same identifier interval as a group of network node groups; and / or, determining the network nodes with the uplink bandwidth in the same bandwidth interval as a group of network node groups; and / or, determining the network nodes with the geographical locations in the same area among the network nodes as a group of network node groups; determining the network node group corresponding to the node information of the target network node as the target network node group.

[0064] In this implementation, when grouping network nodes, the grouping can be performed according to at least one of the upstream bandwidth of the network nodes, the user identification of the client, the network address translation type, the client component version, the IPV6 network support type, and the geographical location. Among the network nodes in a certain area, the network nodes with the same client component version are divided into a group of network node groups, or the network nodes whose geographical locations of the clients are in the same area are divided into a group of network node groups. If all of the above-mentioned multiple information are used, among the network nodes in a certain area, the network nodes with the same client component version, all support the IPV6 network, the same network address translation type, the user identification of the client all belong to the first identification set, and the upstream bandwidth is 100-200Mbps are divided into one network node group. For a network node, determine which network node group it belongs to according to the upstream bandwidth, the user identification of the client, the network address translation type, the client component version, the IPV6 network support type, and the geographical location.

[0065] As an optional example, determining the network node group corresponding to the node information of the target network node as the target network node group includes: when there are multiple groups of network node groups corresponding to the target network node, determining the priority of each group of the network node groups; and determining the network node group with the highest priority as the target network node group.

[0066] In this embodiment, if a network node belongs to multiple network node groups, the network node group with the highest priority among the network node groups is determined as the target network node group according to the priority classification.

[0067] In this embodiment, all network nodes constitute a resource pool. The network nodes in the resource pool are virtualized and classified into a first-layer storage block layer and a second-layer storage unit slot layer. Both are data bucket structures, such as Figure 4 The two-layer structure in. When dividing, the network nodes of the same type are divided into a network node group. A network node group corresponds to a storage block and a block id. The network node type can be divided according to at least one of the following conditions: user id, network region to which the user belongs, user bandwidth, network provider, etc. When the network node is reported, the type is first divided, and then the storage unit is allocated. If the resources of the network node are insufficient to allocate the storage unit, the registration fails. If the registration is successful, the storage unit is bound to the block id. If the device's timed heartbeat detection times out, the device is eliminated and deleted from the resource pool.

[0068] When searching for a target resource, the resource identifier of the target resource plus a random value is used as the target value, and the target value is queried for the target resource in the consistent hash data structure. Figure 7 When querying resources, the storage and management of resource IDs are not involved, and only the network nodes need to be concerned.

[0069] Figure 8 A schematic diagram of a resource query device for a peer network node provided in an embodiment of the present application. Figure 8 As shown, the resource query device of the above-mentioned peer network node includes:

[0070] The processing module 802 is used to increase the resource identifier of the target resource by a random value to obtain a target value when receiving a resource query request initiated by a client for querying a target resource;

[0071] A first determining module 804 is used to determine a target network node group from a plurality of network node groups in a resource pool according to the node information of the target network node corresponding to the client, wherein each network node group includes a plurality of network nodes, each network node is provided with a storage unit, and each storage unit is used to store a resource file of the network node;

[0072] A second determination module 806 is used to perform a consistent hash query operation on each storage unit in the target network node group according to the target value to determine the target storage unit where the target resource is located;

[0073] The sending module 808 is configured to return the node identifier of the first network node providing the target storage unit to the client, so that the target network node obtains the target resource from the first network node.

[0074] The above-mentioned peer-to-peer network is a p2p network, and the network nodes under the p2p network can be routers, TV boxes of TV sets, etc. The p2p network caches the node information of each network node. When a network node needs certain resources such as video, audio, images, etc., it can obtain the resource from other nodes without having to obtain it from the central server. The decision of which network node to obtain the resource from can be determined by the node information cached in the p2p network.

[0075] The above-mentioned client can be a client associated with a network device and used to manage the network device. For example, if the network device is a household router, the client can be a user's mobile phone, and the user can use the client to set the content of the network device, upload the device information of the network device, initiate a resource query request, etc.

[0076] Figure 2 This is a system application diagram of the p2p node cache of this embodiment. In p2p, network nodes such as terminal boxes can report node information, and the node information is forwarded to the cache cluster through the forwarding nodes in the forwarding cluster and cached by the cache cluster. If the client wants to query certain resources, it can send a resource query request to the cache cluster through the forwarding cluster, and the cache cluster queries the first network node according to the resource query request.

[0077] The resource identifier of the target resource may be an identifier for uniquely marking the resource, indicating that the identifier may correspond to a numerical value, or the identifier may be a numerical value. The combination of the identifier and the random value is the target value, and the random value may be a pre-set numerical value. The random value is added to reduce or avoid the influence of resource errors during the query process.

[0078] The above-mentioned resource pool is a pool composed of network nodes that can provide cache services. In this pool, all network nodes are divided into multiple network node groups, each network node group includes multiple network nodes, each network node provides one or more storage units, and each storage unit is used to store a resource file. Then, the resources are stored in the network nodes of the network node group. When the target resource is to be queried, the target storage unit in the network node group where the target resource is located is queried according to the target value. The query method uses a consistent hash query method. The network node where the queried target storage unit is located is the first network node, and the p2p client can obtain the target resource from the first network node.

[0079] The present application provides a new solution for providing cache services for p2p mode. In this solution, a network node group is configured in the network nodes in the resource pool, each network node group includes multiple network nodes, each network node is provided with a storage unit, and each storage unit is used to store a resource file of the network node, and a cache service is provided through the resource pool. If a resource query request is received, the target resource is queried by adding a random value to the resource identifier of the target resource to be queried, and a consistent hash query operation is performed on each storage unit in the target network node group to determine the target storage unit where the target resource is located, so that the client can obtain the target resource from the target storage unit.

[0080] For other examples of this embodiment, please refer to the above examples and will not be described in detail here.

[0081] like Fig. 9 As shown, an embodiment of the present application provides an electronic device, including a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.

[0082] A memory 113, for storing computer programs;

[0083] In one embodiment of the present application, the processor 111 is configured to implement the resource query method of a peer network node provided by any one of the aforementioned method embodiments when executing the program stored in the memory 113 .

[0084] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of providing a resource query method for a peer network node as described in any of the aforementioned method embodiments are implemented.

[0085] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place, or may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0086] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.

[0087] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive and therefore specify the presence of stated features, steps, operations, elements and / or parts, but do not exclude the presence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.

[0088] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A resource query method for a peer network node, characterized in that: include: When receiving a resource query request initiated by a client for querying a target resource, adding a random value to the resource identifier of the target resource to obtain a target value; Determining a target network node group from a plurality of network node groups in a resource pool according to the node information of the target network node corresponding to the client, wherein each of the network node groups includes a plurality of network nodes, each of the network nodes is provided with a storage unit, and each of the storage units is used to store a resource file of the network node; Perform a consistent hash query operation on each storage unit in the target network node group through the target value to determine the target storage unit where the target resource is located; The node identifier of the first network node that provides the target storage unit is returned to the client, so that the target network node obtains the target resource from the first network node.

2. The method according to claim 1, characterized in that Before receiving the resource query request, the method further includes: Obtaining node information of all network nodes in the peer-to-peer network; Classifying the network nodes according to the node information to obtain a plurality of network node groups; Divide each of the network nodes into one or more storage units according to a cache resource of a predetermined size; Each resource file is stored in one storage unit.

3. The method according to claim 2, characterized in that The cache resources include disk resources and bandwidth resources, and the step of dividing each of the network nodes into one or more storage units according to the cache resources of a predetermined size includes: Determine the disk resource size and bandwidth resource size of the network node; Each M-sized disk resource and each N-sized bandwidth resource are divided into one storage unit until the disk resources or bandwidth resources of the network node are fully occupied.

4. The method according to claim 1, characterized in that: When receiving a resource query request initiated by a client for querying a target resource, adding a random value to the resource identifier of the target resource to obtain the target value comprises: Randomly selecting a value from a preset value interval as the random value; Mapping the target resource to a resource value according to a resource-value mapping relationship; The sum of the resource value and the random value is determined as the target value.

5. The method according to claim 4, characterized in that The performing a consistent hash query operation on each storage unit in the target network node group by using the target value to determine the target storage unit where the target resource is located comprises: Mapping resources in each resource file stored in each storage unit in the target network node group to a virtual ring in the hash value space; Mapping the target value onto the virtual ring to determine the position of the target value on the virtual ring; Determine the resource corresponding to the location as the target resource; The storage unit where the target resource is located is determined as the target storage unit.

6. The method according to claim 1, characterized in that The node information includes at least one of the uplink bandwidth of the network node, the user identification of the client, the network address translation type, the client component version, the IPv6 network support type and the geographical location, and the determining the target network node group from the multiple network node groups in the resource pool according to the node information of the target network node corresponding to the client includes: Determine, among the network nodes, network nodes having the same IPv6 network support type as a group of network node groups; and / or, Determine the network nodes having the same client component version among the network nodes as a group of network nodes; and / or, Determine the network nodes with the same network address translation type among the network nodes as a group of network nodes; and / or, Determine the network nodes whose user identifiers of the clients are located in the same identifier interval as a group of network nodes; and / or, Determine, among the network nodes, the network nodes whose uplink bandwidths are in the same bandwidth interval as a group of network nodes; and / or, Determine, among the network nodes, the network nodes whose geographical locations are located in the same area as a group of network nodes; A network node group corresponding to the node information of the target network node is determined as the target network node group.

7. The method according to claim 6, characterized in that The determining the network node group corresponding to the node information of the target network node as the target network node group comprises: In the case where the target network node corresponds to multiple groups of network node groups, determining the priority of each group of the network node groups; The network node group with the highest priority is determined as the target network node group.

8. A resource query device for a peer network node, characterized in that: include: A processing module, configured to, upon receiving a resource query request initiated by a client for querying a target resource, increase a random value by a resource identifier of the target resource to obtain a target value; A first determining module, configured to determine a target network node group from a plurality of network node groups in a resource pool according to node information of the target network node corresponding to the client, wherein each of the network node groups includes a plurality of network nodes, each of the network nodes is provided with a storage unit, and each of the storage units is used to store a resource file of the network node; A second determination module is used to perform a consistent hash query operation on each storage unit in the target network node group according to the target value to determine the target storage unit where the target resource is located; The sending module is used to return the node identifier of the first network node that provides the target storage unit to the client, so that the target network node obtains the target resource from the first network node.

9. An electronic device, characterized in that: include: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor coupled to the at least one bus; At least one memory connected to the at least one bus, wherein a computer program is stored in the memory, and when the processor executes the computer program, the method described in any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the method described in any one of claims 1 to 7 of the present application.