Resource management method, device, equipment and computer storage medium
By setting the correspondence between resource type administrator nodes in the blockchain, the leader node only submits log entries after receiving notification from the target administrator node, which solves the problem of insufficient resource update authority management in the blockchain and achieves consistency and reliability of resource data.
Patent Information
- Application Number
- CN202210379223.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-12
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2042-04-12
AI Technical Summary
The lack of management of resource update permissions in the blockchain makes resources prone to anomalies.
The leader node obtains the resource type in the resource update request, sends a log entry to N follower nodes, and determines the target administrator node based on the preset resource type administrator node correspondence. The log entry is submitted only when the number of notifications received from the target administrator node is greater than the preset threshold.
It effectively avoids data inconsistency caused by unlimited resource modification at any node, improves the reliability and consistency of resource management, and reduces the possibility of resource anomalies.
Smart Images

Figure CN116955367B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of blockchain technology, and in particular relates to a resource management method, apparatus, device, and computer storage medium. Background Art
[0002] As we all know, blockchain is a new application model for computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Blockchain can be used to manage data and other types of resources. In related technologies, when blockchain receives a resource update request, it typically directly updates the resource based on a vote by a majority of nodes in the blockchain. This lacks management of resource update permissions, making it prone to resource anomalies. Summary of the Invention
[0003] The embodiments of the present application provide a resource management method, apparatus, device, and computer storage medium to address the problem that related blockchain technologies lack management of resource update permissions and other content, which makes resources prone to anomalies.
[0004] In a first aspect, an embodiment of the present application provides a resource management method, the method comprising:
[0005] When receiving a resource update request, the leader node obtains the resource type of the updated resource in the resource update request and sends a log entry to N follower nodes, where N is an integer greater than 1;
[0006] The leader node determines the target administrator node corresponding to the resource type from the N follower nodes of the blockchain based on the correspondence between the resource type and the preset resource type administrator node;
[0007] When the leader node receives the first notification sent by the target administrator node and the number of received first notifications is greater than a preset threshold, the leader node submits the log entry. One first notification indicates that one follower node has successfully copied the log entry.
[0008] In a second aspect, an embodiment of the present application provides a resource management device, the device comprising:
[0009] a first obtaining module, configured to, upon receiving a resource update request, cause the leader node to obtain a resource type of an updated resource in the resource update request and send a log entry to N follower nodes, where N is an integer greater than 1;
[0010] A determination module is used for the leader node to determine the target administrator node corresponding to the resource type from the N follower nodes of the blockchain based on the correspondence between the resource type and the preset resource type administrator node;
[0011] The submission module is used for the leader node to submit the log entry when it receives the first notification sent by the target administrator node and the number of received first notifications is greater than a preset threshold. One first notification indicates that one follower node has successfully copied the log entry.
[0012] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory storing computer program instructions;
[0013] When the processor executes the computer program instructions, the resource management method of the first aspect is implemented.
[0014] In a fourth aspect, an embodiment of the present application provides a computer storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the resource management method of the first aspect is implemented.
[0015] In a fifth aspect, an embodiment of the present application provides a computer program product. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the resource management method as described in the first aspect.
[0016] The resource management method provided by the embodiment of the present application, when receiving a resource update request, the leader node obtains the resource type of the updated resource in the resource update request and sends a log entry to N follower nodes; the leader node determines the target administrator node corresponding to the resource type from the N follower nodes of the blockchain based on the correspondence between the resource type and the preset resource type administrator node; the leader node submits the log entry when receiving a first notification sent by the target administrator node and the number of received first notifications is greater than a preset threshold, and one first notification indicates that one follower node has successfully copied the log entry. In the embodiment of the present application, the corresponding target administrator node is set for the resource type of the updated resource through the correspondence between the resource type administrator node. When the leader node copies the log entry in the follower node, it needs to submit the log entry only when it receives the first notification sent by the target administrator node indicating that the log entry has been successfully copied, so as to further complete the update of the updated resource in the blockchain. In this way, it can effectively avoid the situation where any blockchain node modifies various types of resources without restriction, resulting in data asymmetry in each node of the blockchain, helping to maintain the consistency of resource data in each node and reducing the possibility of resource anomalies. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0018] Figure 1 This is a flowchart of a resource management method provided by an embodiment of the present application;
[0019] Figure 2 This is a flowchart of the leader node election process in the blockchain;
[0020] Figure 3 This is a flowchart of the log replication process in the blockchain;
[0021] Figure 4 This is a flowchart of the cloud computing resource management process based on blockchain;
[0022] Figure 5 is a structural diagram of a resource management device provided in an embodiment of the present application;
[0023] Figure 6 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is merely to provide a better understanding of the present application by illustrating the examples of the present application.
[0025] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.
[0026] In order to solve the problems of the prior art, the embodiments of the present application provide a resource management method, apparatus, device and computer storage medium. The following first introduces the framework that can implement the resource management method provided by the embodiments of the present application.
[0027] The above framework can be a blockchain-based framework (hereinafter referred to as a blockchain framework), for example, a blockchain framework based on the Raft algorithm. Of course, the blockchain framework can also use algorithms such as the Practical Byzantine Fault Tolerant Algorithm (PBFT) as a consensus mechanism.
[0028] To simplify the explanation, the following mainly uses the resource management method applied to the blockchain framework based on the Raft algorithm as an example.
[0029] In a blockchain framework based on the Raft algorithm, multiple nodes can be included, each of which can have a corresponding election state. These election states can include leader, candidate, and follower states. The election state of each node can be determined using the conventional Raft algorithm and will not be explained in detail here.
[0030] When a node is in the leader state, the node can become a leader node; correspondingly, when a node is in the follower state, the node can become a follower node.
[0031] In summary, a blockchain framework based on the Raft algorithm can include leader nodes and follower nodes. Nodes in these two election states can interact with each other in data, such as replicating log entries or voting. Examples are not provided here.
[0032] Figure 1 FIG. 1 shows a flow chart of a resource management method provided by an embodiment of the present application. Figure 1 As shown, the method may include:
[0033] Step 101: Upon receiving a resource update request, the leader node obtains the resource type of the updated resource in the resource update request and sends a log entry to N follower nodes, where N is an integer greater than 1.
[0034] Step 102: The leader node determines a target administrator node corresponding to the resource type from the N follower nodes of the blockchain based on the correspondence between the resource type and the preset resource type administrator node;
[0035] Step 103: When the leader node receives the first notification sent by the target administrator node and the number of received first notifications is greater than a preset threshold, the leader node submits the log entry. One first notification indicates that one follower node has successfully copied the log entry.
[0036] Combined with the above description of the framework for applicable resource management methods, there can be a leader node and N follower nodes in the blockchain.
[0037] In step 101 , a leader node may receive a resource update request.
[0038] In some application scenarios, both the leader node and the follower node can have corresponding clients. Each client can generate resource update requests in response to user input. When the user inputs on the leader node's client, the leader node can directly receive the resource update request. When the user inputs on the follower node's client, the leader node can indirectly receive the resource update request from the follower node.
[0039] In some examples, the resource requested to be updated in a resource update request (hereinafter referred to as the updated resource) can be a virtual machine, physical machine, container, database, or middleware, etc., without specific limitation herein. The resource update request can specifically request an update of resource-related data such as the provisioning management, configuration information, operation information, or operation and maintenance information of the aforementioned resource.
[0040] In step 101 , upon receiving a resource update request, the leader node may obtain the resource type of the updated resource and send a log entry to N follower nodes.
[0041] As shown in the examples above, the update resource can be a virtual machine, a physical machine, a container, a database, or a middleware. Accordingly, in some examples, the resource type of the update resource can be a virtual machine, a physical machine, or a container. In this embodiment, the resource type can be set as needed and is not specifically limited here.
[0042] In a blockchain based on an algorithm such as the raft algorithm, a leader node may typically start executing a log replication process upon receiving a resource update request.
[0043] In simple terms, during log replication, the leader node can update its own log entries and send an AppendEntries request to the follower node, and then enter a waiting state. The AppendEntries request can include the above log entries.
[0044] In a conventional blockchain based on the raft algorithm, follower nodes can update the above log entries and send update success messages to the leader node. When the leader node receives update success notifications from more than half of the follower nodes, the leader node will commit the log entry.
[0045] Unlike the log entry submission process in conventional Raft-based blockchains, in this embodiment, the leader node can further consider feedback from the target administrator node corresponding to the resource type before submitting the log entry. The implementation of this process is described in detail below.
[0046] As shown above, in a blockchain, each node may have a corresponding election status. In some implementations of the embodiments of the present application, each node may be assigned a corresponding management status.
[0047] With some examples, the management state can be divided into administrator state and ordinary member state. A node in the administrator state can be called an administrator node, and a node in the ordinary member state can be called an ordinary member node.
[0048] There can be a correspondence between administrator nodes and resource types. For example, there are nodes A, B, and C in the blockchain, and resource types can include type X and type Y. Among them, the administrator nodes corresponding to resource type X can be nodes A and C, and the administrator nodes corresponding to resource type Y can be nodes B and C, and so on.
[0049] The correspondence between the administrator node and the resource type may correspond to the preset resource type administrator node correspondence relationship described above. In practical applications, the resource type administrator node correspondence relationship may be stored in all or part of the nodes of the blockchain.
[0050] Accordingly, in step 102, the leader node can combine the above-mentioned resource type administrator node correspondence to determine the administrator node corresponding to the resource type from the N follower nodes in the blockchain, that is, determine the above-mentioned target administrator node.
[0051] In specific application scenarios, the aforementioned correspondence between administrator nodes and resource types can be considered to indicate that the administrator node has management authority over resources of that resource type. For example, the administrator node has update management authority over resource type X. When a regular member node requests an update for that resource type X, the blockchain requires confirmation from the administrator node before updating the resource. Conversely, if confirmation is not received from the administrator node, the blockchain may not update the resource. This reduces the risk of data asymmetry across blockchain nodes caused by unrestricted modification of resources of that type by clients corresponding to any node.
[0052] To implement the administrator node's management process of updating resources of the corresponding resource type, in step 103, the leader node may submit a log entry when it receives a first notification sent by the target administrator node and the number of received first notifications is greater than a preset threshold.
[0053] In other words, in this embodiment, the leader node needs to meet two conditions to submit a log entry.
[0054] One of the conditions can be a standard condition required for a leader node in a blockchain to commit a log entry, such as the number of follower nodes that return a notification indicating successful log entry replication exceeding half of the total number of nodes in the blockchain. This notification indicating successful log entry replication can correspond to the first notification described above, and half of the total number of nodes in the blockchain can correspond to the predetermined threshold. Of course, in practical applications, the predetermined threshold can be adjusted as needed.
[0055] Another condition is that the leader node needs to receive the first notification sent by the target administrator node, that is, receive the first notification sent by the administrator node corresponding to the resource type of the above-mentioned updated resource.
[0056] In some embodiments, the target administrator node may replicate the log entry upon receiving it and send a first notification to the leader node if the replication is successful. Alternatively, in other embodiments, the target administrator node may notify the user in the corresponding client upon receiving the log entry and then replicate the log entry upon receiving the user's input agreeing to the update.
[0057] In one example, the leader node commits the log directory, which can be specifically manifested by the leader node updating the log status of the log entry to commit. The leader node can subsequently notify follower nodes to commit the log entry, completing the update of the updated data in the blockchain, etc., which will not be explained in detail here.
[0058] The resource management method provided by the embodiment of the present application, when receiving a resource update request, the leader node obtains the resource type of the updated resource in the resource update request and sends a log entry to N follower nodes; the leader node determines the target administrator node corresponding to the resource type from the N follower nodes of the blockchain based on the correspondence between the resource type and the preset resource type administrator node; the leader node submits the log entry when receiving a first notification sent by the target administrator node and the number of received first notifications is greater than a preset threshold, and one first notification indicates that one follower node has successfully copied the log entry. In the embodiment of the present application, the corresponding target administrator node is set for the resource type of the updated resource through the correspondence between the resource type administrator node. When the leader node copies the log entry in the follower node, it needs to submit the log entry only when it receives the first notification sent by the target administrator node indicating that the log entry has been successfully copied, so as to further complete the update of the updated resource in the blockchain. In this way, it can effectively avoid the situation where any blockchain node modifies various types of resources without restriction, resulting in data asymmetry in each node of the blockchain, helping to maintain the consistency of resource data in each node and reducing the possibility of resource anomalies.
[0059] In one embodiment, the resource type administrator node correspondence relationship may exist in the form of a management information dictionary.
[0060] As an example, all blockchain nodes jointly store a management information dictionary. This management information dictionary can be pre-written when the blockchain node joins the network, recording the management permissions of different node systems for resource fields of different types of resources, as shown in the following table. Among them, resource types X, Y, and Z can represent different types of resources, including but not limited to virtual machines, physical machines, containers, etc., and resource fields (or resource data) such as X-1, X-2, and Y-1 can represent the attributes of the corresponding resource, including but not limited to the resource name, resource IP address, resource business type, and resource owner.
[0061] Node ID The system to which the node belongs Resource Type Resource Field Node A Cloud Management System X X-1,… Node B Out-of-band management system Y Y-1, Y-2,… Node C Safety Management System Z Z-1, Z-2, ... Node D Operation and maintenance system X, Y, Z X-2, Y-3, Z-2, Z-3, ...
[0062] Optionally, the log entry includes the resource type;
[0063] The leader node obtains the resource type of the updated resource in the resource update request, and after sending the log entry to the N follower nodes, the method further includes:
[0064] When a follower node receives a log entry, it copies the log entry;
[0065] The follower node determines the management status based on the resource type administrator node correspondence and the resource type included in the log entry;
[0066] In a case where the management state indicates that the follower node is a target administrator node corresponding to the resource type and replication of the log entry by the follower node fails, the follower node sends a second notification to the leader node.
[0067] In the example above, all nodes in the blockchain store a common management information dictionary. It is easy to understand that the management information dictionary can correspond to the resource type administrator node correspondence, and accordingly, the resource type administrator node correspondence can also be obtained by the follower node.
[0068] In conventional blockchain applications, a follower node replicates a log entry after receiving it from a leader node. Upon successful replication, it sends a first notification to the leader node, notifying it of the successful replication. The leader node can then commit the log entry if the number of first notifications received exceeds a preset threshold.
[0069] In this embodiment, the log entry sent by the leader node to each follower node can include the resource type of the updated resource. Accordingly, after receiving the log entry, each follower node can obtain the resource type and further determine its own management status based on the corresponding relationship between the resource type and the administrator node.
[0070] As mentioned above, the management status can include administrator status and ordinary member status. When the management status is administrator status, it means that the follower node is the administrator node of the resource type. In other words, based on the management status, the follower node can determine whether it is the target administrator node corresponding to the resource type.
[0071] When a follower node determines that it is the target administrator node corresponding to the resource type, it can not only send a first notification to the leader node when the log entry replication is successful, but also send a second notification to the leader node when the log entry replication fails. It is easy to understand that the second notification can be used to inform the leader node that the follower node has failed to replicate the log entry.
[0072] In this embodiment, the follower node can determine whether it is the target administrator node corresponding to the resource type based on the correspondence between the resource type administrator node and the resource type included in the log entry. If so, in the event of a failure to copy the log entry, the follower node needs to send a second notification to the leader node indicating the failure of the copy, so as to avoid the leader node waiting for the target administrator node to reply to the notification for a long time, thereby improving the resource management efficiency of the blockchain.
[0073] Optionally, after the leader node determines a target administrator node corresponding to the resource type from the N follower nodes of the blockchain based on the correspondence between the resource type and a preset resource type administrator node, the method further includes:
[0074] The leader node rolls back data on the log entry upon receiving a second notification sent by at least one target administrator node, wherein a second notification indicates that a follower node has failed to replicate the log entry.
[0075] As can be seen from the above example of the management information dictionary, the number of target administrator nodes corresponding to a resource type can be one or more, which is specifically determined by the configuration of the resource type administrator node correspondence.
[0076] The leader node can determine all target administrator nodes corresponding to the data type based on the correspondence between the data type of the updated data and the resource type administrator node, that is, the leader node can obtain information such as the number of target administrator nodes.
[0077] In this embodiment, when the leader node receives the second notification sent by at least one target administrator node, it can be considered that the administrator node corresponding to the resource type of the updated resource does not agree to update the resource. At this time, the leader node can roll back the log entry.
[0078] From another perspective, in this embodiment, upon receiving the second notification from at least one target administrator node, the leader node can determine that it is not necessary to update the resource in accordance with the resource update request, and thus does not need to submit a log entry. This facilitates efficient management of various resource types, prevents arbitrary updates to resource data, and further helps ensure the consistency of resource data in the blockchain.
[0079] In some embodiments, when the target administrator node sends a second notification to the leader node, it may carry the reason for the failure to replicate the above-mentioned log entry in the second notification. For example, the reason for the replication failure may be that the user refuses to update the data, or it may be a software or hardware failure of the target administrator node itself, etc.
[0080] Optionally, the leader node obtains the resource type of the updated resource in the resource update request and sends a log entry to N follower nodes, including:
[0081] When there are M types of updated resources, the leader node creates M log entries for the M resource types. The M resource types correspond to the M log entries one by one, where M is an integer greater than 1.
[0082] The leader node sends each log entry to each of the N follower nodes.
[0083] It is easy to understand that in actual applications, the resource types of the updated resources in the resource update request can be one or more.
[0084] In this embodiment, when there are M resource types, that is, when there are multiple resource types, the leader node can create a log entry for each resource type. In other words, when there are M resource types, the leader node can create M log entries.
[0085] The leader node may send each log entry to each of the N follower nodes. In some examples, the leader node may send the log entries to each follower node simultaneously, or may send the log entries to each follower node in batches.
[0086] From the perspective of the leader node, when the leader node creates M log entries for M resource types, it can perform the replication process for each log entry separately. That is, the leader node can send any log entry to each follower node for replication, and each follower node can notify the leader node of the success or failure of the replication of the log entry.
[0087] As for the process of the leader node submitting or rolling back the corresponding log entry based on the notification fed back by the follower node, please refer to the description in the above embodiment and will not be repeated here.
[0088] Taking into account the situation that the manager nodes corresponding to different resource types may be different, this embodiment can create log entries for each resource type when updating the resource type of a resource and send them to N follower nodes. This helps to achieve independent management of different types of resources by the blockchain, avoid confusion in management authority, and improve the reliability of the resource management process.
[0089] Optionally, the leader node determines a target administrator node corresponding to the resource type from the N follower nodes of the blockchain based on the correspondence between the resource type and the preset resource type administrator node, including:
[0090] The leader node determines, based on the correspondence between the first resource type and the preset resource type administrator node, a first target administrator node corresponding to the first resource type from the N follower nodes of the blockchain, where the first resource type is any resource type among the M resource types;
[0091] When the leader node receives the first notification sent by the target administrator node and the number of received first notifications is greater than a preset threshold, the leader node submits a log entry, including:
[0092] When the leader node receives the third notification sent by the first target administrator node and the number of received third notifications is greater than a preset threshold, the leader node submits the log entry corresponding to the first resource type. A third notification indicates that a follower node has successfully copied the log entry corresponding to the first resource type.
[0093] In this embodiment, the leader node can perform relevant processing for each type of resource in the resource update request, such as creating the log entry, determining the target administrator node, and submitting the log entry when specific conditions are met.
[0094] Taking any resource type in the resource update request, that is, the first resource type mentioned above as an example, the leader node can determine the target administrator node corresponding to the first resource type from N follower nodes based on the correspondence between the resource type administrator nodes, that is, the first target administrator node mentioned above.
[0095] After sending the log entry corresponding to the first resource type to the M follower nodes, the leader node may wait to receive a notification indicating the log entry replication result fed back by each follower node.
[0096] The leader node can submit the log entry corresponding to the first resource type when it receives a notification indicating that the log entry has been successfully copied (i.e., the third notification) sent by each first target administrator node, and a notification indicating that the log entry has been successfully copied sent by a number of follower nodes exceeding a preset threshold among the M follower nodes.
[0097] It is worth emphasizing again that the first resource type is any one of the M resource types mentioned above. In actual applications, the leader node can perform the above-mentioned processes of establishing log entries, determining the target administrator node, and submitting the log entries for each of the M resource types respectively when specific conditions are met.
[0098] In this embodiment, the leader node can perform processing such as determining the target administrator node and submitting log entries for each resource type separately. This helps the blockchain to update different types of resources separately and reduce the risk of resource data anomalies.
[0099] Optionally, after the leader node determines a first target administrator node corresponding to the first resource type from the N follower nodes of the blockchain based on the correspondence between the first resource type and a preset resource type administrator node, the method further includes:
[0100] When the leader node receives a fourth notification sent by at least one first target administrator node, it rolls back data for the log entry corresponding to the first resource type. A fourth notification indicates that a follower node has failed to copy the log entry corresponding to the first resource type.
[0101] In contrast to the embodiment described above in which the leader node determines that the replication process of the log entry corresponding to the first resource type meets specific conditions and commits the log entry, when the replication process of the log entry corresponding to the first resource type does not meet the specific conditions, the leader node can roll back the data of the log entry corresponding to the first resource type.
[0102] Specifically, this embodiment describes a situation in which the replication process of log entries corresponding to a first resource type fails to meet a specific condition. Specifically, when a leader node receives a fourth notification from at least one first target administrator node indicating that replication of log entries corresponding to the first resource type has failed, the leader node may determine that the replication process of log entries corresponding to the first resource type fails to meet the specific condition.
[0103] In this case, the leader node can only roll back data for the log entries corresponding to the first resource type, without having to roll back data for other corresponding log entry replication processes of resource types that meet specific conditions, thereby reducing the overhead of rolling back data write failures.
[0104] Optionally, before the leader node obtains the resource type of the updated resource in the resource update request and sends the log entry to the N follower nodes, the method further includes:
[0105] When a leader node is elected in the blockchain, the leader node will determine the management state as the primary administrator node;
[0106] Among them, the main administrator node is used to set the corresponding relationship between resource type administrator nodes.
[0107] As mentioned above, each node in the blockchain can have a corresponding election status, and the determination of the election status can be achieved through conventional algorithms in the blockchain.
[0108] For example, in a blockchain based on the raft algorithm, if there is no leader node, each node will enter the candidate state and determine the leader node through election.
[0109] In this embodiment, when the blockchain elects a leader node, the leader node can determine its own management status as the primary administrator node, and the primary administrator node can be used to set the corresponding relationship between resource type administrator nodes.
[0110] In other words, the administrator node may include at least two types: one is a target administrator node corresponding to a resource type, and the other is a master administrator node that can manage the correspondence between resource type administrator nodes.
[0111] With some examples, the main administrator node can add or modify the target administrator node corresponding to each resource type.
[0112] This embodiment assigns the management status of the primary administrator node to the leader node, which helps to set the corresponding relationship between resource type administrator nodes and meets the user's configuration needs for the management status of each node.
[0113] In some examples, the primary administrator node acts as a leader node and can also set general content for the blockchain, such as adding or deleting blockchain member nodes, setting the status of member nodes in the raft algorithm, or specifying the next leader node in the raft algorithm, etc.
[0114] The resource management method provided by the embodiment of the present application is described below with reference to some specific application examples. In these application examples, the blockchain can be a blockchain based on the Raft algorithm.
[0115] like Figure 2 As shown, the process of electing a leader node in a blockchain may include steps 201 to 204.
[0116] Step 201: Initialization. Applicable IT systems are selected as blockchain nodes. Each node has two states: election state and management state. The election state is the same as in the conventional raft algorithm, including follower, candidate, and leader states. The management state is divided into administrator and ordinary member states. Initially, all nodes are in the ordinary member state.
[0117] Step 202, election phase. If there is no leader node in the current blockchain, leader election is performed according to the Raft algorithm, and each node votes to select a leader node.
[0118] Step 203: The election ends. After the election cycle ends, the leader node sends periodic heartbeat notification broadcasts to notify other nodes and simultaneously updates its own management status to the primary administrator. At this time, the node in the administrator state in the blockchain can be the elected leader node.
[0119] Step 204: Leader monitoring. If the leader node exits or reaches the end of its term, the process returns to step 202 and re-election is performed.
[0120] The blockchain status information updated by the periodic heartbeat notification broadcast in step 203 includes the settings of the management node, the addition and deletion of member nodes, the status of the member nodes in the Raft regular algorithm, the designation of the next leader in the Raft regular algorithm, etc.
[0121] The blockchain status information updated by the periodic heartbeat notification broadcast in step 203 may also include blockchain updates and blockchain clearing, etc. The frequency of sending the periodic heartbeat notification broadcast may be determined by the application layer software configuration.
[0122] like Figure 3 As shown, when a node in the blockchain receives a resource update request, the log replication process in the blockchain may include steps 301 to 307.
[0123] In step 301, if a node in the blockchain has a resource update request, it can send the request to the leader node. When the leader node receives a resource update request from the client, it starts to execute the log replication process.
[0124] In step 302, the leader node updates its own log entries according to the raft algorithm log replication process and sends an AppendEntries request to the follower. The leader node enters a waiting state and receives the results returned by other nodes.
[0125] In step 303, the leader node synchronously determines the updated resource type in the message content and the pre-configured management state agreement (corresponding to the resource type administrator node correspondence) to identify the administrator node among the follower nodes that sent the request.
[0126] In step 304, after the follower node receives the AppendEntries message sent by the leader node, it makes a judgment based on the updated data type in the message content and the pre-configured management information dictionary (corresponding to the resource type administrator node correspondence). If the node is in the corresponding management status agreement, the node updates its own management status to administrator.
[0127] Step 305: The follower node updates the log entry and returns it to the leader node. If the administrator node fails to update, a failure notification and the reason for the failure need to be returned to the leader node.
[0128] Step 306: The leader node makes a judgment after receiving the return. When all administrator nodes return successfully and the number of nodes that return successfully exceeds half, the leader node updates the log status to commit, otherwise the data fails and rolls back.
[0129] Step 307: According to the Raft algorithm, the leader node notifies other nodes to commit or roll back data.
[0130] In this application example, a blockchain consensus method based on the Raft algorithm suitable for computing resource management can be used to generate a blockchain, and cloud resource information changes can be confirmed and recorded according to the log replication process described by the algorithm.
[0131] When a user initiates an application related to cloud computing resources (including the addition, change, or recycling of resources, or modification of resource configuration, operation and maintenance information), leader election and log replication are completed based on the above-mentioned consensus algorithm. If the user initiates the application and the required changes include different resources or fields managed by different systems, the leader node will split the information that needs to be updated and update the node management according to the pre-stored management information dictionary during each log replication process in accordance with the above-mentioned consensus algorithm. The log replication process is performed in multiple times, which can realize partial updates of resource data in batches, avoid failure of batch data updates, and reduce the overhead of rollback of data write failures.
[0132] like Figure 4 As shown, the cloud computing resource management process based on blockchain includes steps 401 to 403.
[0133] Step 401: Receive a user-initiated request for cloud computing resources (including adding, changing, or reclaiming resources, or modifying resource configuration, operation, and maintenance information).
[0134] Step 402: Leader election and log replication are performed based on the consensus algorithm. If the user-initiated change contains different resources or fields managed by different systems, the leader node will split the information that needs to be updated and perform the log replication process multiple times.
[0135] Step 403: After the log is successfully copied, the initiator node (i.e., the node that initiates the resource update request) can confirm the data, and the user side will archive the work order; if the log copy fails or partially fails, the leader node will notify the initiator node of the failed content and reason.
[0136] Based on the above application examples, it can be seen that the embodiments of the present application, by adding additional management status to the nodes in the blockchain and calculating the management status of the updated nodes through a pre-configured management information dictionary, can differentiate different types of data update scenarios according to actual business and update blockchain data.
[0137] In some application scenarios, the embodiments of the present application can record accounts based on the raft algorithm, and nodes with corresponding management status can determine the success or failure of the update during the log update phase. When all administrator nodes return success and the number of nodes that return success exceeds half, the leader node will update the log status to commit, otherwise the data will fail and roll back, which is more in line with the actual production business model and avoids data anomalies caused by more than half of the ordinary nodes passing.
[0138] The embodiment of the present application is based on the node management status and management information dictionary, which can realize partial update of data, reduce the overhead of data write failure rollback while ensuring data consistency and reliability, and improve resource management efficiency and data writing efficiency.
[0139] like Figure 5 As shown, the embodiment of the present application further provides a resource management device, the device comprising:
[0140] The acquisition and sending module 501 is configured to, upon receiving a resource update request, cause the leader node to obtain the resource type of the updated resource in the resource update request and send a log entry to N follower nodes, where N is an integer greater than 1;
[0141] A first determination module 502 is configured for the leader node to determine a target administrator node corresponding to a resource type from N follower nodes of the blockchain based on a correspondence between the resource type and a preset resource type administrator node;
[0142] The submission module 503 is used for the leader node to submit the log entry when it receives the first notification sent by the target administrator node and the number of received first notifications is greater than a preset threshold. One first notification indicates that one follower node has successfully copied the log entry.
[0143] Optionally, the log entry includes the resource type;
[0144] Accordingly, the resource management device may further include:
[0145] A replication module is used for follower nodes to replicate log entries when they receive them.
[0146] A second determination module is used for the follower node to determine the management status according to the corresponding relationship between the resource type and the administrator node, and the resource type included in the log entry;
[0147] The sending module is configured to send a second notification from the follower node to the leader node when the management state indicates that the follower node is a target administrator node corresponding to the resource type and the follower node fails to replicate the log entry.
[0148] Optionally, the resource management device may further include:
[0149] A rollback module is used for the leader node to roll back data of the log entry when receiving a second notification sent by at least one target administrator node, where a second notification indicates that a follower node has failed to replicate the log entry.
[0150] Optionally, obtaining the sending module 501 includes:
[0151] an establishing unit, configured to, when there are M types of resource to be updated, cause the leader node to establish M log entries for the M resource types, wherein the M resource types correspond one to one with the M log entries, and M is an integer greater than 1;
[0152] The sending unit is used for the leader node to send each log entry to N follower nodes respectively.
[0153] Optionally, the first determining module 502 may be specifically configured to:
[0154] The leader node determines, based on the correspondence between the first resource type and the preset resource type administrator node, a first target administrator node corresponding to the first resource type from the N follower nodes of the blockchain, where the first resource type is any resource type among the M resource types;
[0155] Accordingly, the submission module 503 may be specifically configured to:
[0156] When the leader node receives the third notification sent by the first target administrator node and the number of received third notifications is greater than a preset threshold, the leader node submits the log entry corresponding to the first resource type. A third notification indicates that a follower node has successfully copied the log entry corresponding to the first resource type.
[0157] Optionally, the resource management device may further include:
[0158] A rollback unit is used for the leader node to roll back data for the log entry corresponding to the first resource type when it receives a fourth notification sent by at least one first target administrator node, and a fourth notification indicates that a follower node has failed to copy the log entry corresponding to the first resource type.
[0159] Optionally, the resource management device may further include:
[0160] The third determination module is used to determine the management state of the leader node as the primary administrator node when the blockchain elects a leader node;
[0161] Among them, the main administrator node is used to set the corresponding relationship between resource type administrator nodes.
[0162] It should be noted that the resource management device is a device corresponding to the above-mentioned resource management method. All implementation methods in the above-mentioned method embodiments are applicable to the embodiments of the device and can achieve the same technical effects.
[0163] Figure 6 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application is shown.
[0164] The electronic device may include a processor 601 and a memory 602 storing computer program instructions.
[0165] Specifically, the processor 601 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0166] The memory 602 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 602 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 602 may include removable or non-removable (or fixed) media. Where appropriate, the memory 602 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 602 is a non-volatile solid-state memory.
[0167] In certain embodiments, the memory 602 may include read-only memory (ROM), random access memory (RAM), magnetic disk storage media devices, optical storage media devices, flash memory devices, electrical, optical, or other physical / tangible memory storage devices. Thus, in general, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to an aspect of the present disclosure.
[0168] The processor 601 implements any one of the resource management methods in the above embodiments by reading and executing computer program instructions stored in the memory 602 .
[0169] In one example, the electronic device may further include a communication interface 603 and a bus 610. Figure 6 As shown, the processor 601, the memory 602, and the communication interface 603 are connected via a bus 610 and communicate with each other.
[0170] The communication interface 603 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0171] Bus 610 includes hardware, software or both, and the parts of online data flow metering equipment are coupled to each other. For example, but not limitation, bus can include accelerated graphics port (AGP) or other graphics bus, enhanced industry standard architecture (EISA) bus, front side bus (FSB), hypertransport (HT) interconnection, industry standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 610 can include one or more buses. Although the present application embodiment describes and shows specific bus, the application considers any suitable bus or interconnection.
[0172] In addition, in conjunction with the resource management method in the above embodiments, the present application embodiment may provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when the computer program instructions are executed by a processor, any one of the resource management methods in the above embodiments is implemented.
[0173] It should be understood that the present application is not limited to the specific configurations and processes described above and illustrated in the figures. For the sake of brevity, a detailed description of known methods is omitted here. In the above embodiments, several specific steps are described and illustrated as examples. However, the method process of the present application is not limited to the specific steps described and illustrated. Those skilled in the art can make various changes, modifications, and additions, or change the order of the steps after understanding the spirit of the present application.
[0174] The functional blocks shown in the above block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. Programs or code segments can be stored in machine-readable media, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable media" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROMs, flash memories, erasable ROMs (EROMs), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0175] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps. In other words, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0176] Aspects of the present disclosure have been described above with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit. It is also understood that each box in the block diagram and / or flowchart and the combination of the boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0177] The above is only a specific implementation method of the present application. Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the scope of protection of the present application is not limited to this. Any technician familiar with this technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the scope of protection of this application.
Claims
1. A resource management method, characterized in that: include: Upon receiving a resource update request, the leader node obtains the resource type of the updated resource in the resource update request and sends a log entry to N follower nodes, where N is an integer greater than 1; The leader node determines a target administrator node corresponding to the resource type from the N follower nodes of the blockchain based on the correspondence between the resource type and the preset resource type administrator node; The leader node submits the log entry when receiving the first notification sent by the target administrator node and the number of the received first notifications is greater than a preset threshold. One first notification indicates that one follower node has successfully copied the log entry.
2. The method according to claim 1, characterized in that The log entry includes the resource type; After the leader node obtains the resource type of the updated resource in the resource update request and sends the log entry to the N follower nodes, the method further includes: Upon receiving the log entry, the follower node replicates the log entry; The follower node determines the management state according to the resource type administrator node correspondence and the resource type included in the log entry; In a case where the management state indicates that the follower node is a target administrator node corresponding to the resource type and replication of the log entry by the follower node fails, the follower node sends a second notification to the leader node.
3. The method according to claim 1 or 2, characterized in that After the leader node determines a target administrator node corresponding to the resource type from N follower nodes of the blockchain based on the correspondence between the resource type and the preset resource type administrator node, the method further includes: The leader node rolls back the data of the log entry upon receiving a second notification sent by at least one of the target administrator nodes, wherein the second notification indicates that a follower node has failed to replicate the log entry.
4. The method according to claim 1, wherein The leader node obtains the resource type of the updated resource in the resource update request, and sends a log entry to the N follower nodes, including: In a case where there are M types of resource for the update resource, the leader node creates M log entries for the M types of resource, the M types of resource correspond to the M log entries one-to-one, and M is an integer greater than 1; The leader node sends each of the log entries to the N follower nodes respectively.
5. The method according to claim 4, characterized in that The leader node determines a target administrator node corresponding to the resource type from N follower nodes of the blockchain according to the correspondence between the resource type and the preset resource type administrator node, including: The leader node determines, based on a correspondence between a first resource type and a preset resource type administrator node, a first target administrator node corresponding to the first resource type from the N follower nodes of the blockchain, where the first resource type is any one of the M resource types; The leader node submits the log entry when receiving the first notification sent by the target administrator node and the number of the received first notifications is greater than a preset threshold, including: When the leader node receives the third notification sent by the first target administrator node and the number of the received third notifications is greater than a preset threshold, the leader node submits the log entry corresponding to the first resource type. One of the third notifications indicates that one of the follower nodes has successfully copied the log entry corresponding to the first resource type.
6. The method according to claim 5, characterized in that After the leader node determines a first target administrator node corresponding to the first resource type from N follower nodes of the blockchain based on a correspondence between the first resource type and a preset resource type administrator node, the method further includes: When the leader node receives a fourth notification sent by at least one of the first target administrator nodes, it rolls back the data of the log entry corresponding to the first resource type, and one of the fourth notifications indicates that a follower node has failed to copy the log entry corresponding to the first resource type.
7. The method according to claim 1, characterized in that The leader node obtains the resource type of the updated resource in the resource update request, and before sending the log entry to the N follower nodes, the method further includes: In the case where the blockchain elects the leader node, the leader node determines the management state as the primary administrator node; The main administrator node is used to set the corresponding relationship between the resource type administrator nodes.
8. A resource management device, characterized in that: The device comprises: a first acquisition module, configured to, upon receiving a resource update request, cause the leader node to acquire a resource type of an updated resource in the resource update request and send a log entry to N follower nodes, where N is an integer greater than 1; a determination module, configured for the leader node to determine, based on a correspondence between the resource type and a preset resource type administrator node, a target administrator node corresponding to the resource type from N follower nodes of the blockchain; A submission module is used for the leader node to submit the log entry when it receives the first notification sent by the target administrator node and the number of the first notifications received is greater than a preset threshold. One first notification indicates that one follower node has successfully copied the log entry.
9. An electronic device, characterized in that: The device includes: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the resource management method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the resource management method according to any one of claims 1 to 7 is implemented.
11. A computer program product, characterized in that When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the resource management method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Blockchain-based audit log processing method and device, and log audit system
CN108833514A
Method and device for achieving data consistency, server and terminal
CN111352943A