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

By dividing resource buckets in peer-to-peer networks and recording the correspondence between resources and network nodes, the problem of low efficiency of cache services in the existing technology is solved, efficient resource query and management is realized, and the performance of the p2p system is improved.

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

Patent Information

Application Number
CN202311245278.0
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 peer-to-peer network (p2p) model, the cache service efficiency is low, making it difficult to effectively manage and query the resources of network nodes.

Method used

By dividing multiple resource buckets in the resource pool, each resource bucket stores one or more types of resources, and records the correspondence between each resource and its network node, and quickly query the network node where the target resource is located using a hash table and a two-way linked list structure.

Benefits of technology

It realizes efficient resource query and cache management, improving the accessibility of resources in the p2p system and the overall performance of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119691252A_ABST
    Figure CN119691252A_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 determining a target resource bucket storing a target resource in a resource pool according to a resource identifier of the target resource under the condition that a resource query request which is initiated by a client and used for querying the target resource is received; searching a first network node in the target resource bucket according to the node information of the target network node corresponding to the client and the node information of the network nodes in the resource bucket; and returning the node identifier of the first network node to the client, so that a target network node corresponding to the client 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 and storage medium 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 and storage medium 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, determining a target resource bucket in a resource pool that stores the target resource based on a resource identifier of the target resource, wherein the resource pool includes multiple resource buckets, each of the resource buckets stores one or more types of resources, and the resource bucket also stores node information of a network node where each resource is located; searching for a first network node in the target resource bucket based on the node information of the target network node corresponding to the client and the node information of the network nodes in the resource bucket; and returning the node identifier of the first network node to the client, so that the target network node corresponding to the client 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 determination module, which is used to determine, when receiving a resource query request initiated by a client for querying a target resource, a target resource bucket in a resource pool that stores the target resource according to a resource identifier of the target resource, wherein the resource pool includes multiple resource buckets, each of which stores one or more types of resources, and the resource bucket also stores node information of a network node where each resource is located; a search module, which is used to search for a first network node in the target resource bucket according to the node information of the target network node corresponding to the client and the node information of the network nodes in the resource bucket; a sending module, which is used to return the node identifier of the first network node to the client, so that the target network node corresponding to the client obtains the target resource from the first network node.

[0007] As an optional example, the above-mentioned device also includes: an acquisition module, which is used to obtain the node information of all network nodes under the above-mentioned peer network and the resource information of the network resources stored in each of the above-mentioned network nodes before receiving the above-mentioned resource query request; a classification module, which is used to classify the above-mentioned network resources according to the above-mentioned resource information to obtain multiple resource classes; a storage module, which is used to store each class or multiple classes of the above-mentioned resource classes in one of the above-mentioned resource buckets; and the correspondence between each resource under each of the above-mentioned resource classes and the node information of the network node where it is located is stored in the above-mentioned resource bucket.

[0008] As an optional example, the above-mentioned storage module includes: a storage unit, used to allocate multiple resource sub-buckets to the resource bucket where the above-mentioned resource is located when the number of network nodes where the above-mentioned resource is located exceeds a predetermined threshold; divide the network nodes where the above-mentioned resource is located into multiple node groups according to type; and store the node information of the network nodes in each node group in a resource sub-bucket.

[0009] As an optional example, the above-mentioned search module includes: a query unit, used to query the above-mentioned first network node through the bidirectional linked list structure in the above-mentioned target resource bucket, wherein the node information of the above-mentioned network node in the above-mentioned target resource bucket is stored in the form of a combination structure of a hash table structure and the above-mentioned bidirectional linked list structure, the above-mentioned hash table structure stores the node unique identifier in the above-mentioned node information, the above-mentioned bidirectional linked list structure stores the node attribute information in the above-mentioned node information, and the above-mentioned node unique identifier and the above-mentioned node attribute information are associated with each other.

[0010] As an optional example, the above-mentioned device also includes: a first receiving module, which is used to obtain the node information of the above-mentioned second network node and the resource information of the network resources stored by the above-mentioned second network node when receiving a new request initiated by the client to add a second network node; determine the first resource bucket according to the resource information of the network resources stored by the above-mentioned second network node; store the unique identification information in the node information of the above-mentioned second network node in the above-mentioned hash table structure, and store the node attribute information in the node information of the above-mentioned second network node in the above-mentioned bidirectional linked list structure.

[0011] As an optional example, the above-mentioned device also includes: a second receiving module, which is used to obtain the node information of the above-mentioned third network node and the resource information of the network resources stored by the above-mentioned third network node when receiving a deletion request initiated by the client to delete the third network node; determine the second resource bucket according to the resource information of the network resources stored by the above-mentioned third network node; delete the unique identification information of the above-mentioned third network node in the above-mentioned hash table structure in the above-mentioned second resource bucket, and delete the node attribute information of the above-mentioned third network node in the above-mentioned bidirectional linked list structure in the above-mentioned second resource bucket.

[0012] As an optional example, the above-mentioned device also includes: a deleting module, which is used to delete the node information of any network node from the above-mentioned peer network when the access to the node information of any network node in any resource bucket times out.

[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 compared with the prior art: for all resources in the p2p system, the resources are divided into different resource buckets according to the type of resources, and the resources stored in each resource bucket correspond to the corresponding relationship between the resources and the node information of the network node. When searching for the target resource, firstly search the target resource bucket where the target resource is located according to the resource identifier of the target resource to be queried, and then search the first network node where the resource is located according to the corresponding relationship between the resource and the node information of the network node, and obtain the target resource from the first network node. Through this embodiment, a new solution for providing cache services for p2p is provided. 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 schematic diagram of a cache structure of a resource query method for 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 schematic diagram of the structure of a resource query device for a peer network node provided in an embodiment of the present application;

[0025] Figure 7 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] 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.

[0027] 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.

[0028] In the prior art, redis is used to provide a cache service for p2p. The present application provides a resource query method for a peer network node and provides a new solution for providing a cache service for p2p.

[0029] 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:

[0030] S102, upon receiving a resource query request initiated by a client for querying a target resource, determining a target resource bucket storing the target resource in a resource pool according to a resource identifier of the target resource, wherein the resource pool includes a plurality of resource buckets, each resource bucket storing one or more types of resources, and the resource bucket also stores node information of a network node where each resource is located;

[0031] S104, searching for a first network node in the target resource bucket according to the node information of the target network node corresponding to the client and the node information of the network nodes in the resource bucket;

[0032] S106: Return the node identifier of the first network node to the client, so that the target network node corresponding to the client obtains the target resource from the first network node.

[0033] 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.

[0034] 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.

[0035] 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.

[0036] In this embodiment, for all resources in the p2p system, although the number of all resources in the p2p system will change as the p2p system runs, in this solution, when the resources are bucketed, the number of resources is known or fixed. When changes occur later, the buckets can be adjusted according to the amount of change in the resources. For the above resources, the resources can be divided into different resource buckets according to the resource type, and the divided resources are located in different resource buckets according to the resource type (a bucket can store multiple types of resources, such as a bucket storing 10 types of resources, and each type of resource has multiple). In addition to the division type, the correspondence between resources and network nodes is also recorded. The correspondence is the network nodes corresponding to resources of different data streams, operators, and custom blocks. For example, there are 100 million resources, and 10,000 resource buckets are prepared. After division, each bucket contains about 10,000 resources, and the 10,000 resources are divided into 1,000 categories, each category has 10 resources, and each resource corresponds to a network node that stores the resource.

[0037] When querying resources, first query the resource bucket where the resource is located according to the resource identifier. Then, since the resource may be located in multiple network nodes, query the first network node that matches the node information through the node information of the network node where the client that initiates the resource query request is located, and obtain the target resource from the first network node. The queried first network node can be one or more. If there are multiple first network nodes, one is preferentially scheduled to the client according to the network load of each first network node, and the client obtains the target resource from the first network node. All network nodes can be evenly scheduled to ensure that the load of the network node is not too high.

[0038] For all resources in the p2p system, the resources are divided into different resource buckets according to the resource types. The resources stored in each resource bucket correspond to the corresponding relationship between the resources and the node information of the network node. When searching for a target resource, the target resource bucket where the target resource is located is first searched according to the resource identifier of the target resource to be queried, and then the first network node where the resource is located is searched according to the corresponding relationship between the resources and the node information of the network node, and the target resource is obtained from the first network node. Through this embodiment, a new solution for providing cache services for p2p is provided.

[0039] As an alternative example, Figure 3 As shown, before receiving the resource query request, the method further includes:

[0040] S302, obtaining node information of all network nodes in the peer-to-peer network and resource information of network resources stored in each network node;

[0041] S304, classifying network resources according to resource information to obtain multiple resource categories;

[0042] S306, storing each or multiple resource classes into a resource bucket;

[0043] S308: Store the correspondence between each resource under each resource class and the node information of the network node where the resource is located in the resource bucket.

[0044] In this embodiment, a resource pool can be configured to provide cache services for the p2p system, and the resource pool includes all network nodes and resources on the network nodes under the 2p2 system. Deduplication is performed on the resources on the network nodes, and the deduplicated resources are used as resources to be cached by the p2p system. The deduplicated resources are divided into multiple resource classes according to the resource type, and the resources of each class or multiple resource classes are stored in a resource bucket, and the relationship between the resources and the network nodes is stored in the resource bucket.

[0045] like Figure 4This is a schematic diagram of the cache system of this embodiment. This cache system is divided into three or four layers. The first layer is to classify all resources of the p2p system and divide the resources into multiple resource buckets. When classifying, the number of resource buckets can be determined based on empirical values ​​to meet the cache requirements of resources in the p2p system. The second layer is the content in each resource bucket. Each resource bucket includes resources and the corresponding relationship between storage identifiers and network nodes. The storage identifier includes the flow identifier, operator identifier and storage block identifier of the resource, where the flow identifier is used to distinguish data flows. The purpose of the second layer is to record the network node where the resource is located for each resource, and the network nodes are divided according to operators, storage blocks, etc. If there are too many network nodes corresponding to a resource, the third layer is divided to divide the multiple network nodes corresponding to a resource into different resource sub-buckets, so that the number of network nodes in each resource sub-bucket will not be too many. If the number of network nodes where the resource is located is not large, there is no need to divide the third layer. For each storage block of the second layer (or the resource sub-bucket in the case of dividing the third layer), the unique identifier of each network node in multiple network nodes and the attribute information of each network node are stored therein, and the attribute information includes the network address, port and other information of the network node.

[0046] As an alternative example, Figure 5 As shown, storing the corresponding relationship between each resource under each resource class and the node information of the network node in the resource bucket includes:

[0047] S502, when the number of network nodes where a resource is located exceeds a predetermined threshold, allocating multiple resource sub-buckets to the resource bucket where the resource is located;

[0048] S504, dividing the network nodes where the resources are located into multiple node groups according to their types;

[0049] S506: Store the node information of the network nodes in each node group into a resource sub-bucket.

[0050] In this embodiment, a resource may be located in multiple network nodes. If the resource is popular, it will be located in many network nodes. Therefore, the multiple network nodes where a resource is located can be divided into multiple categories, and each category of network nodes is stored in a resource sub-bucket. Each resource bucket can be divided into multiple resource sub-buckets. Whether to divide the resource sub-buckets depends on the number of network nodes where the resource is located. If the resource sub-buckets are divided, Figure 4 As shown in the figure, the third-level resource sub-bucket is divided into buckets, and the fourth level is divided under the resource sub-bucket. If the resource sub-bucket is not divided, then Figure 4The storage block block of the second layer is divided into a fourth layer.

[0051] As an optional example, searching for the first network node in the target resource bucket according to the node information of the target network node corresponding to the client and the node information of the network nodes in the resource bucket includes: querying the first network node through the bidirectional linked list structure in the target resource bucket, wherein the node information of the network node in the target resource bucket is stored in the form of a combination structure of a hash table structure and a bidirectional linked list structure, the hash table structure stores the node unique identifier in the node information, the bidirectional linked list structure stores the node attribute information in the node information, and the node unique identifier and the node attribute information are associated with each other.

[0052] In this embodiment, for each resource bucket or each resource sub-bucket, the node attribute information of the resource and the node is stored in the form of a combination of a bidirectional linked list structure and a hash table structure. The node attribute information is the node's data flow, operator, custom block and other attributes. Figure 4 Provide explanation. Figure 4 In the example, the unique identifiers of network nodes form a hash table structure, which can quickly add and delete network nodes. The attribute information of network nodes forms a bidirectional linked list structure, which can quickly find network nodes. The node identifiers of network nodes in the hash table structure and the attribute information of network nodes in the bidirectional linked list structure are associated, and one can find the other.

[0053] As an optional example, the above method further includes:

[0054] Upon receiving a request initiated by a client to add a second network node, node information of the second network node and resource information of network resources stored in the second network node are obtained; a first resource bucket is determined based on the resource information of network resources stored in the second network node; unique identification information in the node information of the second network node is stored in a hash table structure, and node attribute information in the node information of the second network node is stored in a bidirectional linked list structure.

[0055] In this embodiment, when a second network node is added, the node identification, attribute information and resource information of the second network node can be obtained. According to the resource information, the resources of the second network node are stored in the corresponding first resource bucket, and then the unique identification information is added to the hash table structure, and the attribute information is stored in the bidirectional linked list structure, so that the network node can be added quickly.

[0056] As an optional example, the above method also includes: upon receiving a deletion request initiated by a client to delete a third network node, obtaining node information of the third network node and resource information of network resources stored by the third network node; determining a second resource bucket based on the resource information of network resources stored by the third network node; deleting the unique identification information of the third network node in the hash table structure in the second resource bucket, and deleting the node attribute information of the third network node in the bidirectional linked list structure in the second resource bucket.

[0057] In this embodiment, when deleting the third network node, the node identifier, attribute information and resource information of the third network node can be obtained. According to the resource information, the resource bucket where the resources of the third network node are stored is searched, the resources in the resource bucket are deleted, the unique identifier in the hash table structure is deleted, and the attribute information in the bidirectional linked list structure is deleted, thereby deleting the network node.

[0058] As an optional example, the above method further includes: when access to the node information of any network node in any resource bucket times out, deleting the node information of the node from the peer-to-peer network.

[0059] In the case of network node deletion, it can be deleted manually or by determining whether the network node has timed out. If a network node is accessed and the network node has timed out, it means that the network node cannot provide resource caching services and needs to be deleted.

[0060] Combination Figure 4 Let's take an example. For example, a p2p system has 100 million resources to cache, and each resource can be video, audio, picture, document, web page, etc., and 10,000 resource buckets are configured. Among the 100 million resources, if there are about 10 pieces of each type of data, then after bucketing, each bucket contains 10,000 resources. Among the 10,000 resources, there are 1,000 categories, and each category has 10 resources (the number of buckets can be configured or increased or decreased according to the total number of resources). For a bucket, among the 10,000 resources, each piece of data may exist on one network node or on multiple network nodes. Therefore, each bucket records the corresponding relationship between resources and nodes. The resources in a bucket can use mutual exclusion locks or lockfree, or wait free, a technology close to lockfree, to avoid lock collisions. Different data streams and resources of different operators can be divided into different data blocks. Each block stores a data stream and a network node corresponding to the resources of an operator. In addition, data blocks can also be divided according to geographic location, restriction type NAT type, bandwidth, disk, user ID, operating system, kernel version, component version, and whether IPV6 is supported. Figure 4 If there is a third layer in the block, the network nodes under the block are stored in the form of a combination of a hash table structure and a bidirectional linked list structure. If there is a third layer, the resource sub-buckets are first divided, and then the network nodes in each resource sub-bucket are stored in the form of a combination of a hash table structure and a bidirectional linked list structure. Whether to divide the third layer can be determined based on the resource heat. A coldness dividing line is set to determine the heat level. The fourth-layer hash table is mainly used for inserting and updating node data, and the bidirectional linked list is mainly used for data query. The combined data structure is used to ensure the performance of adding, deleting, modifying, and checking. The single query time complexity of the hash table and the combined structure is O(1) (the complexity is very low). A hash table can be used for single-value queries, and a bidirectional linked list structure can be used for multi-value queries. At the same time, with the help of the linked list polling strategy, the scheduling node load balancing can also be guaranteed.

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

[0062] The determination module 602 is used to determine, in the case of receiving a resource query request initiated by a client for querying a target resource, a target resource bucket storing the target resource in the resource pool according to the resource identifier of the target resource, wherein the resource pool includes multiple resource buckets, each resource bucket stores one or more types of resources, and the resource bucket also stores node information of a network node where each resource is located;

[0063] A search module 604, configured to search for a first network node in a target resource bucket according to node information of a target network node corresponding to the client and node information of network nodes in the resource bucket;

[0064] The sending module 606 is configured to return the node identifier of the first network node to the client, so that the target network node corresponding to the client obtains the target resource from the first network node.

[0065] 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.

[0066] 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.

[0067] 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.

[0068] In this embodiment, for all resources in the p2p system, the resources can be divided into different resource buckets according to the resource type, and the divided resources are located in different resource buckets according to the resource type (a bucket can store multiple types of resources, such as a bucket storing 10 types of resources, and each type of resource has multiple). In addition to the division type, the correspondence between resources and network nodes is also recorded. The correspondence is the network nodes corresponding to resources of different data streams, operators, and custom blocks. For example, there are 100 million resources, and 10,000 resource buckets are prepared. After division, each bucket contains about 10,000 resources, and the 10,000 resources are divided into 1,000 categories, with 10 resources in each category, and each resource corresponds to a network node that stores the resource.

[0069] When querying resources, first query the resource bucket where the resource is located based on the resource identifier. Then, since the resource may be located in multiple network nodes, the node information of the network node where the client that initiates the resource query request is located is used to query the first network node that matches the node information, and obtain the target resource from the first network node.

[0070] For all resources in the p2p system, the resources are divided into different resource buckets according to the resource types. The resources stored in each resource bucket correspond to the corresponding relationship between the resources and the node information of the network node. When searching for a target resource, the target resource bucket where the target resource is located is first searched according to the resource identifier of the target resource to be queried, and then the first network node where the resource is located is searched according to the corresponding relationship between the resources and the node information of the network node, and the target resource is obtained from the first network node. Through this embodiment, a new solution for providing cache services for p2p is provided.

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

[0072] like Figure 7As 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.

[0073] Memory 113, used for storing computer programs;

[0074] 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 .

[0075] 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.

[0076] 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, that is, they may be located in one place or distributed on 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.

[0077] 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, 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 described in each embodiment or some parts of the embodiments.

[0078] It should be understood that the terms used in the text 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 "said" as used in the text may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence 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.

[0079] 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: In the case of receiving a resource query request initiated by a client for querying a target resource, determining a target resource bucket storing the target resource in a resource pool according to a resource identifier of the target resource, wherein the resource pool includes a plurality of resource buckets, each of which stores one or more types of resources, and the resource bucket also stores node information of a network node where each resource is located; Searching for a first network node in the target resource bucket according to the node information of the target network node corresponding to the client and the node information of the network nodes in the resource bucket; The node identifier of the first network node is returned to the client, so that the target network node corresponding to the client 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: Acquire node information of all network nodes in the peer-to-peer network and resource information of network resources stored in each of the network nodes; Classifying the network resources according to the resource information to obtain multiple resource classes; storing each class or classes of the resource into one of the resource buckets; The correspondence between each resource under each resource class and the node information of the network node where the resource is located is stored in the resource bucket.

3. The method according to claim 2, characterized in that The storing of the correspondence between each resource under each resource class and the node information of the network node in the resource bucket includes: When the number of network nodes where a resource is located exceeds a predetermined threshold, allocating multiple resource sub-buckets to the resource bucket where the resource is located; Dividing the network nodes where the resources are located into multiple node groups according to their types; The node information of the network nodes in each node group is stored in a resource sub-bucket.

4. The method according to claim 1, characterized in that The searching for the first network node in the target resource bucket according to the node information of the target network node corresponding to the client and the node information of the network nodes in the resource bucket includes: The first network node is queried through the bidirectional linked list structure in the target resource bucket, wherein the node information of the network node in the target resource bucket is stored in the form of a combination structure of a hash table structure and the bidirectional linked list structure, the hash table structure stores the node unique identifier in the node information, the bidirectional linked list structure stores the node attribute information in the node information, and the node unique identifier and the node attribute information are associated with each other.

5. The method according to claim 4, characterized in that The method further comprises: Upon receiving a request initiated by the client for adding a second network node, acquiring node information of the second network node and resource information of network resources stored by the second network node; Determine a first resource bucket according to resource information of network resources stored by the second network node; The unique identification information in the node information of the second network node is stored in the hash table structure, and the node attribute information in the node information of the second network node is stored in the bidirectional linked list structure.

6. The method according to claim 4, characterized in that The method further comprises: Upon receiving a deletion request initiated by the client for deleting a third network node, acquiring node information of the third network node and resource information of network resources stored by the third network node; Determine a second resource bucket according to resource information of network resources stored by the third network node; The unique identification information of the third network node in the hash table structure in the second resource bucket is deleted, and the node attribute information of the third network node in the bidirectional linked list structure in the second resource bucket is deleted.

7. The method according to claim 1, characterized in that The method further comprises: When access to the node information of any network node in any resource bucket times out, the node information of the node is deleted from the peer-to-peer network.

8. A resource query device for a peer network node, characterized in that: include: A determination module, configured to, upon receiving a resource query request initiated by a client for querying a target resource, determine a target resource bucket in a resource pool storing the target resource according to a resource identifier of the target resource, wherein the resource pool includes a plurality of resource buckets, each of which stores one or more types of resources, and the resource bucket also stores node information of a network node where each resource is located; A search module, configured to search for a first network node in the target resource bucket according to the node information of the target network node corresponding to the client and the node information of the network nodes in the resource bucket; The sending module is used to return the node identifier of the first network node to the client, so that the target network node corresponding to the client 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, wherein the storage medium stores 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.