Method and device for avoiding node conflict, computing equipment and storage medium

By obtaining the process identifier set of the ZooKeeper cluster and processing the storage node status using a machine learning model, the problem of duplicate registration after a brief disconnection of storage nodes is solved, thus improving the efficiency and stability of ZooKeeper.

CN121284086APending Publication Date: 2026-01-06SUGON INFORMATION IND +1
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202511357406.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-22
Publication Date
2026-01-06

AI Technical Summary

Technical Problem

In a ZooKeeper cluster, when a storage node briefly disconnects and then reconnects, it may cause the process to register repeatedly, leading to ZooKeeper failure and reduced efficiency.

Method used

By obtaining the process identifier set of each storage node in the ZooKeeper cluster, it is determined whether the target process has been registered. If it has been registered, the registration operation is interrupted. If the storage node is temporarily offline, a machine learning model is used to process the storage node status to determine whether the process has completed registration. A suitable slave node is selected for registration to avoid duplicate registration.

Benefits of technology

This avoids duplicate process registration caused by temporary offline storage nodes, improves the efficiency of ZooKeeper, reduces failures, and enhances the accuracy of registration and management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121284086A_ABST
    Figure CN121284086A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a method and device for avoiding node conflicts, computing equipment and a storage medium, in response to a process registration request, process identifiers stored in storage nodes in a zookeeper cluster can be obtained to serve as a first identifier set, and if the first identifier set contains a process identifier target identifier corresponding to a target process, the target process is not subjected to the process identifier target identifier corresponding to the target process. If the state of the target storage node is changed from the first state to the second state within the set time period, the target storage node can be determined to be offline, and if the state of the target storage node is changed from the first state to the second state within the set time period, the target storage node can be determined to be reconnected. The target process is the registered process, so that the registration operation does not need to be further carried out. By means of the mode, the situation that the target process is repeatedly registered due to the fact that the target storage node is temporarily offline is avoided, other possible faults are avoided, and the use efficiency of the cluster is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of storage, and in particular to a method, apparatus, computing device, and storage medium for avoiding node conflicts. Background Technology

[0002] As distributed systems become increasingly complex, to avoid spending a lot of time writing repetitive, complex, and error-prone low-level coordination code, relevant personnel often use ZooKeeper clusters to enable a group of independent computers to work together. The emergence of ZooKeeper allows relevant personnel to focus on business logic rather than the complexity of low-level distributed coordination.

[0003] ZooKeeper contains multiple storage nodes. If one of the storage nodes is briefly disconnected, the services that were disconnected will be registered after the disconnection. However, when the storage node reconnects, the services that were already registered on that storage node will be duplicated, which may cause ZooKeeper to malfunction and reduce its efficiency. Summary of the Invention

[0004] To address the problems in the prior art, this application provides a method, apparatus, computing device, and storage medium for avoiding node conflicts.

[0005] In a first aspect, embodiments of this application provide a method for avoiding node conflicts, the method comprising:

[0006] In response to a process registration request, a first set of identifiers is obtained; the first set of identifiers contains process identifiers stored by each storage node in the ZooKeeper cluster; the process registration request is generated by the storage node in response to the registration operation of the target process; wherein, the process identifiers stored by each storage node are the process identifiers corresponding to processes that have completed registration;

[0007] If the first set of identifiers contains a target identifier, the registration operation is interrupted and the target storage node for storing the target identifier is determined; the target identifier is the process identifier corresponding to the target process.

[0008] If the state of the target storage node changes from the first state to the second state within a set time period, then the target process is determined to be a process that has completed registration.

[0009] In response to a process registration request, the system retrieves the process identifiers stored on each storage node in the ZooKeeper cluster as the first identifier set. If the first identifier set contains the target process's identifier, the registration operation needs to be terminated first. The system then identifies the target storage node storing the target identifier, confirming that the target storage node has gone offline. If the target storage node's state changes from the first state to the second state within a set time period, it confirms that the target storage node has reconnected and can maintain communication with the service. The target process is then considered successfully registered and no further registration is required. This method avoids the situation where the target process repeatedly registers due to a temporary offline target storage node, thus preventing potential ZooKeeper failures and improving ZooKeeper's efficiency.

[0010] In one possible implementation, the plurality of storage nodes includes a master node and at least one slave node;

[0011] After obtaining the first set of identifiers, the method further includes:

[0012] If the target identifier is not included in the first identifier set, then an identifier write request is sent to each slave node through the master node;

[0013] The master node receives node information returned by each slave node and determines the target slave node from at least one slave node based on the node information.

[0014] Write the target identifier into the target slave node.

[0015] The above method enables registration of a target process even if it is not registered with ZooKeeper. Registration can be achieved through the cooperation between the master and slave nodes in the ZooKeeper cluster. By sending an identifier write request to the slave node and receiving the node information returned by the slave node, the target slave node that can perform the registration operation for the target process can be more accurately identified, thus improving the registration efficiency of the target process.

[0016] In one possible implementation, the node information includes the transmission time of the node information and the available storage space contained in the corresponding slave node;

[0017] Determining the target slave node from at least one slave node based on the node information includes:

[0018] The target slave node is determined based on the transmission time contained in the node information sent by each slave node and the available storage space contained in the corresponding slave node;

[0019] Wherein, the sending time contained in the node information sent by the target slave node is earlier than the sending time contained in the write permission notification sent by other slave nodes, or the available storage space of the target slave node is greater than the available storage space of the other slave nodes.

[0020] Using the above method, the target slave node can be determined based on the sending time of the node information fed back by each slave node to the master node and the available storage space of the corresponding slave node. Among multiple slave nodes, the target slave node whose sending time is earlier than that of other slave nodes can be selected, indicating that the target slave node has a fast response speed and can be registered for the target service more quickly. Among multiple slave nodes, the target slave node whose available storage space is greater than that of other slave nodes can also be selected, which allows each slave node to store a similar number of process identifiers, avoiding overload of a slave node, avoiding potential ZooKeeper failures, and improving the efficiency of ZooKeeper.

[0021] In one possible implementation, the plurality of storage nodes includes a master node and at least one slave node; after interrupting the registration operation and determining the target storage node storing the target identifier, the method further includes:

[0022] The target storage node is processed to change its state;

[0023] If the target state of the target storage node changes to the second state within the set time period, the registration operation ends.

[0024] If the target state remains in the first state and the target storage node is the master node during the set time period, then a master node is selected from the at least one slave node based on the creation time of each slave node and the registration operation continues.

[0025] If the target state remains in the first state and the target storage node is a slave node within the set time period, then the registration operation continues.

[0026] The above methods allow for different handling of different situations. Specifically, if the target storage node reconnects, it can be determined that the target process has already been registered, thus ending the registration operation. If the target storage node, which is the master node, remains offline, the master node can be selected and the registration operation can continue. If the target storage node, which is the slave node, remains offline, the registration operation can continue directly. These three handling methods enable this application to more effectively implement the process registration process while avoiding node conflicts, thus improving the efficiency of ZooKeeper.

[0027] In one possible implementation, processing the target storage node to transform its state includes:

[0028] The offline logs are classified using a trained machine learning model to generate processing methods for the target storage node; the offline logs are generated when the target storage node is offline.

[0029] The target storage node is processed using the aforementioned processing method;

[0030] The machine learning model is trained in the following manner:

[0031] Different categories of historical logs are used as training sets and input into the machine learning model until the target parameters in the machine learning model reach the target threshold; the historical logs include multiple historical logs and solutions for each historical log.

[0032] The above method enables the processing of target storage nodes after they go offline. During this process, machine learning models can be used to generate corresponding processing methods for different offline logs, and these methods can be applied to the target storage node. This allows the target storage node to quickly transition from an offline state to an online state, thus enabling a more accurate determination of whether the target storage node's state is a temporary offline event. This avoids potential ZooKeeper failures and improves the efficiency of ZooKeeper usage.

[0033] In one possible implementation, the method further includes:

[0034] If the target number is greater than the preset number, the process identifiers corresponding to the registered processes stored in the target storage node will be allocated to at least one storage node other than the target storage node; the target number is the number of times the state of the target storage node changes from the second state to the first state within the target time period.

[0035] By using the above method, we can determine the target number of times a target storage node will go offline within a target time period. If the target number is greater than the preset number, the target storage node can be removed, and the process identifiers of the registered processes stored in the target storage node can be assigned to at least one storage node other than the target storage node. This avoids potential failures in the ZooKeeper cluster during subsequent use and improves the efficiency of ZooKeeper.

[0036] In one possible implementation, the step of allocating the process identifier corresponding to the registered process stored in the target storage node to at least one storage node other than the target storage node includes:

[0037] Based on storage space information, the process identifiers stored in the target storage node are allocated to other storage nodes so that the difference in available storage space between any two storage nodes other than the target storage node is less than a set threshold; the storage space information includes the available storage space of the other storage nodes and the storage space occupied by each process identifier stored in the other storage nodes.

[0038] By using the above method, the process identifiers stored in the target storage node can be distributed to other storage nodes. Consequently, each slave node can store a similar number of process identifiers, avoiding overload on any slave node and preventing potential failures in the ZooKeeper cluster during subsequent use, thus improving the efficiency of ZooKeeper.

[0039] In one possible implementation, the step of allocating the process identifier corresponding to the registered process stored in the target storage node to at least one storage node other than the target storage node includes:

[0040] A new storage node is created based on the node identifier of the target storage node; the new storage node has the same parent node as the target storage node; the node sequence number in the node identifier of the new storage node is greater than the node identifier of the target storage node; the node sequence number is used to represent the order in which the nodes were created.

[0041] Save the registered processes stored in the target storage node to the newly created storage node.

[0042] In addition to saving the process identifier from the target storage node to other storage nodes, the above method can also create a new storage node and save the process identifier from the target storage node to the new storage node, thus avoiding potential failures in the subsequent use of the ZooKeeper cluster and improving the efficiency of ZooKeeper.

[0043] Secondly, embodiments of this application provide a device for avoiding node conflicts, the device comprising:

[0044] The first identifier set acquisition unit is used to acquire a first identifier set in response to a process registration request. The first identifier set contains process identifiers stored by each storage node in the ZooKeeper cluster. The process registration request is generated by the storage node in response to the registration operation of the target process. The process identifiers stored by each storage node are the process identifiers corresponding to processes that have completed registration.

[0045] A target storage node determination unit is configured to, if the first identifier set contains a target identifier, interrupt the registration operation and determine the target storage node for storing the target identifier; the target identifier is the process identifier corresponding to the target process;

[0046] The target process registration determination unit is used to determine that the target process is a registered process if the state of the target storage node changes from a first state to a second state within a set time period.

[0047] Thirdly, embodiments of this application provide a computing device, including:

[0048] Memory, used to store program instructions;

[0049] A processor is configured to invoke program instructions stored in the memory and execute the steps included in the method described in the first aspect according to the obtained program instructions.

[0050] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the method described in the first aspect.

[0051] This application provides a method, apparatus, computing device, and storage medium for avoiding node conflicts. In response to a process registration request, it obtains the process identifiers stored on each storage node in the ZooKeeper cluster as a first identifier set. If the first identifier set contains the target process's corresponding process identifier, the registration operation needs to be terminated first, and the target storage node storing the target identifier needs to be identified. This indicates that the target storage node has gone offline. If the target storage node's state changes from a first state to a second state within a set time period, it can be determined that the target storage node has reconnected, and the target process is the one that has completed registration, thus eliminating the need for further registration. This method avoids the situation where the target process repeatedly registers due to the target storage node's temporary offline state, thereby preventing potential ZooKeeper failures and improving ZooKeeper's efficiency. Attached Figure Description

[0052] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0053] Figure 1 This is an application scenario diagram of a method for avoiding node conflicts provided in an embodiment of this application;

[0054] Figure 2 A flowchart illustrating a method for avoiding node conflicts provided in this application embodiment;

[0055] Figure 3 A detailed flowchart of a method for avoiding node conflicts provided in this application embodiment;

[0056] Figure 4 A structural block diagram of a device for avoiding node conflicts provided in an embodiment of this application;

[0057] Figure 5 This is a structural block diagram of a computing device provided in an embodiment of this application. Detailed Implementation

[0058] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0059] It should be noted that the terms "comprising" and "having" and their variations used in this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such process, method, product, or device.

[0060] The terms "first" and "second" used in this document are for descriptive purposes only and should not be construed as indicating relative importance or implying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.

[0061] The word “exemplary” as used below means “serving as an example, embodiment, or illustration.” Any embodiment illustrated as an “exemplary” need not be construed as superior to or better than other embodiments.

[0062] The present application will now be described in further detail with reference to the accompanying drawings and specific embodiments.

[0063] Figure 1 This application scenario diagram illustrates a method for avoiding node conflicts provided in an embodiment of this application. (See attached diagram.) Figure 1 As shown, this application scenario includes a ZooKeeper cluster 100 and a client 200. The ZooKeeper cluster 100 contains multiple storage nodes, including a master node 110 and slave nodes 120, 130, and 140. It should be noted that the ZooKeeper cluster 100 can contain more or fewer slave nodes; this application does not impose any limitations on this. The client 200 can connect to the master node 110 in the ZooKeeper cluster 100, but typically the client-driven mechanism automatically connects to the optimal node without application-level intervention. The client 200 can also connect to any slave node to initiate read requests. If the client 200 sends a write request to any of the slave nodes 120, 130, or 140, the slave node receiving the write request will forward it to the master node 110 for processing.

[0064] In one possible implementation, master node 110 can handle all write requests and initiate proposals, serving as the sole entry point for write operations. Slave nodes 120, 130, and 140 can participate in voting for write operations and handle read requests from client 200. Master node 110 is elected; in the ZooKeeper cluster 100, only one master node is active at any given time. Slave nodes 120, 130, and 140 can participate in the master node election. If the current master node 110 fails, all slave nodes 140 can initiate an election to elect a new master node. To ensure strong data consistency in a distributed environment, all write operations are coordinated by a single node. A voting mechanism ensures that a majority of nodes have successfully saved the data before confirmation of success. This prevents data loss and conflicts even if some nodes fail. Therefore, master node 110 and other slave nodes need to be configured in the ZooKeeper cluster 100.

[0065] As distributed systems become increasingly complex, to avoid spending a lot of time writing repetitive, complex, and error-prone low-level coordination code, relevant personnel often use ZooKeeper clusters to enable a group of independent computers to work together. The emergence of ZooKeeper allows relevant personnel to focus on business logic rather than the complexity of low-level distributed coordination.

[0066] ZooKeeper contains multiple storage nodes. If one of the storage nodes is briefly disconnected, the services that were disconnected will be registered after the disconnection. However, when the storage node reconnects, the services that were already registered on that storage node will be duplicated, which may cause ZooKeeper to malfunction and reduce its efficiency.

[0067] The following describes a test method for a battery backup unit provided by an exemplary embodiment of this application, in conjunction with the application scenarios described above and with reference to the accompanying drawings. It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principles of this application, and the embodiments of this application are not limited in any way in this respect.

[0068] Figure 2 A flowchart illustrating a method for avoiding node conflicts provided in an embodiment of this application is shown, such as... Figure 2 As shown, the method may include the following steps:

[0069] Step S201: Respond to the process registration request and obtain the first set of identifiers.

[0070] In one possible embodiment, the process registration request is generated by the registration operation of the target process in the storage node. The first identifier set contains the process identifiers stored in each storage node of the ZooKeeper cluster. The process identifiers stored in each storage node are the process identifiers corresponding to the processes that have completed registration. Normally, processes that have completed registration will not register again. For example, if the storage nodes in the ZooKeeper cluster store process identifier 1 for process 1, process identifier 2 for process 2, and process identifier 3 for process 3, then it can be considered that processes 1, 2, and 3 are all processes that have completed registration. The first identifier set stores process identifier 1, process identifier 2, and process identifier 3. If no failure occurs in the ZooKeeper cluster, processes 1, 2, and 3 will not send registration requests to ZooKeeper again. However, if there is a process 4, and the storage nodes in the ZooKeeper cluster do not store process identifier 4, then process 4 can register by sending a registration request to the ZooKeeper cluster.

[0071] Specifically, if the target identifier corresponding to the target process is not included in the first identifier set, the master node can send an identifier write request to each slave node. After sending the identifier write request, the master node can receive the node information returned by each slave node, determine the target slave node from at least one slave node based on the node information, and write the target identifier to the target slave node, thus completing the registration process of the target process. The process of determining a target slave node from at least one slave node can be implemented as follows: Each slave node returns node information including the sending time of its sent node information and the available storage space it contains. Therefore, there are two ways to select the target slave node: First, a slave node whose sending time is earlier than that of other slave nodes can be selected as the target slave node, indicating a fast response speed and faster registration for the target service. Second, a slave node with more available storage space than other slave nodes can be selected as the target slave node, allowing each slave node to store a similar number of process identifiers, avoiding overload of any single slave node. It should be noted that the determination of the target slave node is not limited to the two selection methods provided in this application; rather, the two can be combined, selecting a slave node with larger available storage space and an earlier sending time as the target slave node. This application does not impose any limitations on this. The above methods can effectively improve the efficiency of ZooKeeper.

[0072] Step S202: If the first set of identifiers contains the target identifier, then the registration operation is interrupted and the target storage node for storing the target identifier is determined.

[0073] In one possible embodiment, if the first set of identifiers contains the target identifier, it can be preliminarily assumed that the target service has been registered. However, as explained in the background section, services that have already been registered are usually not re-registered. This indicates that a problem has occurred in the ZooKeeper cluster, causing the registered service to re-register. This problem is usually caused by the target storage node that stores the target identifier corresponding to the target service going offline. However, if the target storage node is only temporarily offline, then the target service should not be re-registered. Therefore, after identifying the target storage node, processing can be performed on the target storage node to change its state. This reduces the time the target storage node is offline. If the target storage node's state changes to online within a set time period after processing, the target storage node can be considered to have completed the reconnection process, and the registration operation can end. If the target storage node remains in the first state and is the master node within the set time period after processing, a master node can be selected from at least one slave node, and the registration operation can continue. If the target storage node remains in the first state and is a slave node within the set time period after processing, the registration operation can continue directly.

[0074] In one possible embodiment, processing operations targeting a target storage node can be implemented by classifying offline logs using a trained machine learning model to generate processing methods for the target storage node, and then using these methods to process the target storage node. The offline logs are generated when the target storage node is offline. The machine learning model can be trained by inputting different categories of historical logs as a training set until the target parameter in the machine learning model reaches a target threshold. The target parameter can be the number of iterations, in which case the target threshold can be the corresponding iteration threshold (e.g., 6, 7, or other values). Alternatively, the target parameter can be a loss value, in which case the target threshold can be the corresponding loss threshold. When the loss value of the machine learning model reaches the loss threshold, the training process of the machine learning model can be considered complete.

[0075] In one possible embodiment, the master node can be selected from at least one slave node in the following way: the master node can be selected from at least one slave node by the creation time of each slave node. In general, the slave node with the smallest sequence number can be selected as the master node, because the node sequence number is usually used to characterize the creation time of the node.

[0076] In another possible embodiment, the selection of a master node from at least one slave node can be achieved in the following way: each storage node can store a target value, and each storage node can store different target values. The node with the largest target value can be the master node. If the ZooKeeper cluster does not fail, the target values ​​stored in each storage node can be randomly swapped within a certain period of time. Each swap may lead to the replacement of the master node. This can avoid the failure of the master node due to the long-term use of the same master node. When the target storage node fails, the target value stored in the target storage node will also disappear. Then, a certain master node can be selected based on the target values ​​contained in other storage nodes.

[0077] Step S203: If the state of the target storage node changes from the first state to the second state within a set time period, then the target process is determined to be a process that has completed registration.

[0078] In one possible embodiment, if the state of the target storage node changes from the first state to the second state within a set time period, that is, from offline to online, then the target process can be determined to be a process that has completed registration, and there is no need to continue the previously interrupted registration steps.

[0079] In one possible embodiment, monitoring can also be performed on each storage node in the ZooKeeper cluster. The number of times each storage node in the ZooKeeper cluster changes from the second state to the first state within a target time period can be monitored, that is, the number of times it changes from the online state to the offline state, i.e., the number of brief disconnections. If the target number is greater than the preset number, it can be considered that the lifespan of the storage node is close to the upper limit and frequent brief disconnections occur. Therefore, the process identifiers corresponding to the registered processes stored in the storage node can be assigned to at least one storage node other than the target storage node.

[0080] Specifically, the process identifiers corresponding to the registered processes stored in the target storage node can be allocated to at least one storage node other than the target storage node in the following ways: The process identifiers stored in the target storage node can be allocated to other storage nodes based on storage space information, such that the difference in available storage space between any two storage nodes other than the target storage node is less than a set threshold. The storage space information includes the available storage space of other storage nodes and the storage space occupied by each process identifier stored in the other storage nodes. Alternatively, a new storage node can be created based on the node identifier of the target storage node. The new storage node has the same parent node as the target storage node, the node sequence number in the node identifier of the new storage node is greater than the node identifier of the target storage node, and the registered processes stored in the target storage node are saved to the new storage node.

[0081] This application provides a method, apparatus, computing device, and storage medium for avoiding node conflicts. In response to a process registration request, it obtains the process identifiers stored on each storage node in the ZooKeeper cluster as a first identifier set. If the first identifier set contains the target process's corresponding process identifier, the registration operation needs to be terminated first, and the target storage node storing the target identifier needs to be identified. This indicates that the target storage node has gone offline. If the target storage node's state changes from a first state to a second state within a set time period, it can be determined that the target storage node has reconnected, and the target process is the one that has completed registration, thus eliminating the need for further registration. This method avoids the situation where the target process repeatedly registers due to the target storage node's temporary offline state, thereby preventing potential ZooKeeper failures and improving ZooKeeper's efficiency.

[0082] In one specific embodiment, Figure 3 A flowchart illustrating a method for avoiding node conflicts provided in an embodiment of this application is shown, as follows: Figure 3 As shown, the method may include the following steps:

[0083] Step S301: Respond to the process registration request and obtain the first set of identifiers.

[0084] Step S302: Determine whether the first identifier set contains the target identifier. If not, proceed to step S303; if yes, proceed to step S305.

[0085] Step S303: The master node sends an identifier write request to each slave node and receives the node information returned by each slave node, and writes the target identifier to the target slave node.

[0086] Step S304: Determine the target slave node based on the sending time contained in the node information sent by each slave node and the available storage space contained in the corresponding slave node.

[0087] In one possible embodiment, the sending time contained in the node information sent by the target slave node is earlier than the sending time contained in the write permission notification sent by other slave nodes, or the available storage space of the target slave node is greater than the available storage space of other slave nodes.

[0088] Step S305: Interrupt the registration operation and determine the target storage node for saving the target identifier.

[0089] Step S306: Use the trained machine learning model to classify the offline logs in order to generate a processing method for the target storage node.

[0090] Step S307: Process the target storage node using the processing method.

[0091] Step S308: Determine whether the target state of the target storage node changes to the second state within the set time period. If yes, proceed to step S309; ​​otherwise, proceed to step S310.

[0092] Step S309: End the registration operation and determine the target process as the process that has completed registration.

[0093] Step S310: Determine whether the target storage node is the master node. If yes, proceed to step S311; otherwise, proceed to step S312.

[0094] Step S311: Select a master node from at least one slave node based on the creation time of each slave node and continue the registration operation.

[0095] Step S312, continue with the registration process.

[0096] In one possible embodiment, if the target number is greater than the preset number, the process identifier corresponding to the registered process stored in the target storage node is allocated to at least one storage node other than the target storage node; the target number is the number of times the state of the target storage node changes from the second state to the first state within the target time period.

[0097] In one possible embodiment, process identifiers stored in the target storage node are allocated to other storage nodes based on storage space information, so that the difference in available storage space between any two storage nodes other than the target storage node is less than a set threshold; the storage space information includes the available storage space of other storage nodes, and the storage space occupied by each process identifier stored in other storage nodes.

[0098] In one possible embodiment, a new storage node is created based on the node identifier of the target storage node; the new storage node is consistent with the parent node of the target storage node; the node sequence number in the node identifier of the new storage node is greater than the node identifier of the target storage node; the node sequence number is used to characterize the order of node creation time; and the registered processes stored in the target storage node are saved to the new storage node.

[0099] Based on the same inventive concept Figure 4 A structural block diagram of a device for avoiding node conflicts provided in an embodiment of this application is shown below. Figure 4 As shown, the device 400 for avoiding node conflicts may include:

[0100] The first identifier set acquisition unit 401 is used to acquire a first identifier set in response to a process registration request; the first identifier set contains process identifiers stored by each storage node in the ZooKeeper cluster; the process registration request is generated by the storage node in response to the registration operation of the target process; wherein, the process identifiers stored by each storage node are the process identifiers corresponding to processes that have completed registration.

[0101] The target storage node determination unit 402 is used to interrupt the registration operation and determine the target storage node for storing the target identifier if the first identifier set contains a target identifier; the target identifier is the process identifier corresponding to the target process.

[0102] The target process registration determination unit 403 is used to determine that the target process is a process that has completed registration if the state of the target storage node changes from a first state to a second state within a set time period.

[0103] In one possible implementation, the first identifier set acquisition unit 401 is further configured to send an identifier write request to each slave node through the master node if the first identifier set does not contain the target identifier.

[0104] The master node receives node information returned by each slave node and determines the target slave node from at least one slave node based on the node information.

[0105] Write the target identifier into the target slave node.

[0106] In one possible implementation, the first identifier set acquisition unit 401 is further configured to determine the target slave node based on the transmission time contained in the node information sent by each slave node and the available storage space contained in the corresponding slave node.

[0107] Wherein, the sending time contained in the node information sent by the target slave node is earlier than the sending time contained in the write permission notification sent by other slave nodes, or the available storage space of the target slave node is greater than the available storage space of the other slave nodes.

[0108] In one possible implementation, the target storage node determination unit 402 is further configured to process the target storage node to change the state of the target storage node;

[0109] If the target state of the target storage node changes to the second state within the set time period, the registration operation ends.

[0110] If the target state remains in the first state and the target storage node is the master node during the set time period, then a master node is selected from the at least one slave node based on the creation time of each slave node and the registration operation continues.

[0111] If the target state remains in the first state and the target storage node is a slave node within the set time period, then the registration operation continues.

[0112] In one possible implementation, the target storage node determination unit 402 is further configured to classify offline logs using a trained machine learning model to generate a processing method for the target storage node; the offline logs are generated when the target storage node is offline.

[0113] The target storage node is processed using the aforementioned processing method;

[0114] The machine learning model is trained in the following manner:

[0115] Different categories of historical logs are used as training sets and input into the machine learning model until the target parameters in the machine learning model reach the target threshold; the historical logs include multiple historical logs and solutions for each historical log.

[0116] In one possible implementation, the target process registration determination unit 403 is further configured to, if the target number is greater than a preset number, allocate the process identifier corresponding to the registered process stored in the target storage node to at least one storage node other than the target storage node; the target number is the number of times the state of the target storage node changes from the second state to the first state within the target time period.

[0117] In one possible implementation, the target process registration determination unit 403 is further configured to allocate the process identifiers stored in the target storage node to other storage nodes based on storage space information, so that the difference in available storage space between any two storage nodes other than the target storage node is less than a set threshold; the storage space information includes the available storage space of the other storage nodes and the storage space occupied by each process identifier stored in the other storage nodes.

[0118] In one possible implementation, the target process registration determination unit 403 is further configured to create a new storage node based on the node identifier of the target storage node; the new storage node is consistent with the parent node of the target storage node; the node sequence number in the node identifier of the new storage node is greater than the node identifier of the target storage node; the node sequence number is used to characterize the order in which the nodes are created.

[0119] Save the registered processes stored in the target storage node to the newly created storage node.

[0120] Based on the same inventive concept, embodiments of this application provide a computing device that can implement the node conflict avoidance method described above. Please refer to... Figure 5 The computing device 500 includes a memory 501, a processor 502, and a bus 503.

[0121] The memory 501 is used to store computer programs executed by the processor 502. The memory 501 may mainly include a program storage area and a data storage area. The program storage area may store the operating system and programs required to run instant messaging functions, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.

[0122] Memory 501 may be volatile memory, such as random-access memory (RAM); memory 501 may also be non-volatile memory, such as read-only memory, flash memory, hard disk drive (HDD), or solid-state drive (SSD); or memory 501 may be any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but is not limited thereto. Memory 501 may be a combination of the above-mentioned memories.

[0123] Processor 502 may include one or more central processing units (CPUs) or digital processing units, etc. Processor 502 is used to implement the method for avoiding node conflicts in the above embodiments when calling a computer program stored in memory 501.

[0124] This application embodiment does not limit the specific connection medium between the memory 501 and the processor 502 described above. This application embodiment... Figure 5 The memory 501 and the processor 502 are connected via a bus 503, and the bus 503 is in Figure 5 The connections between other components are shown in thick lines only and are not intended to be limiting. The 503 bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, Figure 5 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0125] Based on the same inventive concept, embodiments of this application provide a computer-readable storage medium. The computer program product includes computer program code, which, when executed on a computer, causes the computer to perform any of the methods for avoiding node conflicts discussed above. Since the principle by which the above-described computer-readable storage medium solves the problem is similar to that of the methods for avoiding node conflicts, the implementation of the above-described computer-readable storage medium can be referred to the implementation of the method; repeated details will not be elaborated further.

[0126] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0127] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0128] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0129] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0130] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method of avoiding node conflicts, characterized by, The method comprises: in response to a process registration request, obtaining a first identifier set; the first identifier set contains process identifiers stored by each storage node in a zookeeper cluster; the process registration request is generated by the storage node in response to a registration operation of a target process; wherein the process identifier stored by each storage node is the process identifier corresponding to the process that has completed registration; if the target identifier is contained in the first identifier set, interrupt the registration operation and determine the target storage node that saves the target identifier; the target identifier is the process identifier corresponding to the target process; if the state of the target storage node is converted from the first state to the second state within a set time period, it is determined that the target process is a process that has completed registration.

2. The method of claim 1, wherein, The plurality of storage nodes contain a master node and at least one slave node; After obtaining the first identifier set, the method further comprises: if the target identifier is not contained in the first identifier set, send an identifier write request to each slave node through the master node; receive the node information returned by each slave node through the master node, and determine a target slave node from at least one slave node based on the node information; write the target identifier to the target slave node.

3. The method of claim 2, wherein, The node information contains the sending time of the node information and the available storage space contained in the corresponding slave node; The target slave node is determined from at least one slave node based on the node information, comprising: determine the target slave node based on the sending time contained in the node information sent by each slave node and the available storage space contained in the corresponding slave node; wherein the sending time contained in the node information sent by the target slave node is earlier than the sending time contained in the write permission notification sent by other slave nodes, or the available storage space of the target slave node is greater than the available storage space of the other slave nodes.

4. The method of claim 1, wherein, The plurality of storage nodes contain a master node and at least one slave node; After interrupting the registration operation and determining the target storage node that saves the target identifier, the method further comprises: processing the target storage node to convert the state of the target storage node; if the target state of the target storage node is converted to the second state within a set time period, end the registration operation; if the target state remains in the first state within a set time period and the target storage node is a master node, select a master node from the at least one slave node based on the creation time of each slave node and continue the registration operation; if the target state remains in the first state within a set time period and the target storage node is a slave node, continue the registration operation.

5. The method of claim 4, wherein, The processing of the target storage node to convert the state of the target storage node comprises: classifying offline logs using a trained machine learning model to generate a processing method for the target storage node; the offline logs are generated when the target storage node is offline; processing the target storage node using the processing method; The machine learning model is trained by the following method: Inputting different categories of historical logs as a training set into the machine learning model until a target parameter in the machine learning model reaches a target threshold; the historical logs include a plurality of offline logs and a solution measure for each of the offline logs.

6. The method of claim 1, wherein, The method further comprises: If the target number of times is greater than a preset number of times, process identifiers corresponding to processes that have completed registration and saved in the target storage node are allocated to at least one storage node other than the target storage node; the target number of times is the number of times that the state of the target storage node is converted from the second state to the first state within a target time period.

7. The method of claim 6, wherein, The process of allocating the process identifiers corresponding to the processes that have completed registration and saved in the target storage node to at least one storage node other than the target storage node comprises: Based on storage space information, the process identifiers saved in the target storage node are allocated to other storage nodes, so that the difference between the available storage spaces of any two storage nodes other than the target storage node is less than a set threshold; the storage space information includes the available storage space of the other storage nodes and the occupied storage space of each process identifier saved in the other storage nodes.

8. The method of claim 6, wherein, The process of allocating the process identifiers corresponding to the processes that have completed registration and saved in the target storage node to at least one storage node other than the target storage node comprises: A new storage node is created based on the node identifier of the target storage node; the parent node of the new storage node is consistent with that of the target storage node; the node identifier of the new storage node is greater than that of the target storage node; the node sequence number in the node identifier is used to represent the chronological order of the creation time of the node; The processes that have completed registration and saved in the target storage node are saved to the new storage node.

9. An apparatus for avoiding node conflict, the apparatus comprising: The device comprises: A first identifier set acquisition unit is configured to acquire a first identifier set in response to a process registration request; the first identifier set includes process identifiers stored by each storage node in a zookeeper cluster; the process registration request is generated by the storage node in response to a registration operation of a target process; wherein the process identifiers stored by each storage node are process identifiers corresponding to processes that have completed registration; A target storage node determination unit is configured to interrupt the registration operation and determine a target storage node that saves a target identifier if the target identifier is included in the first identifier set; the target identifier is a process identifier corresponding to the target process; A target process registration determination unit is configured to determine that the target process is a process that has completed registration if the state of the target storage node is converted from a first state to a second state within a set time period.

10. A computing device, comprising: Comprise: A memory for storing program instructions; A processor for invoking the program instructions stored in the memory to perform the steps included in the method according to any one of claims 1-8 according to the obtained program instructions.

11. A computer readable storage medium having stored therein a computer program, characterized in that: The computer program is executed by the processor to implement the method according to any one of claims 1-8. The computer program is executed by the processor to implement the method according to any one of claims 1-8.

Citation Information

Patent Citations

  • Method and device for processing state transition of cluster management system

    CN104866380A

  • Single service running method and device

    CN107086940A

  • Service monitoring method, service monitoring device, computer equipment and storage medium

    CN107888444A

  • Industrial internet identification data batch registration method and device and medium

    CN117135209A

  • Method and device for executing timed task in off-site active-active system

    CN117827402A