Data modification method, storage medium and electronic device

By creating a client in the Zookeeper cluster, obtaining the tree structure, traversing the query target node and automatically replacing the node value, the problem of low Zookeeper node data modification efficiency and high misoperation rate is solved, and efficient and accurate automatic data modification is achieved.

CN118656520APending Publication Date: 2024-09-17QINGDAO HAIER TECH +3
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410679359.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-29
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

In the existing technology, the modification efficiency of Zookeeper node data is low and prone to misoperation, resulting in service problems.

Method used

By creating a Zookeeper cluster client, you can obtain the tree structure, receive data modification information, traverse the tree structure to query the target node, and automatically replace the node value through the preset parameter modification script to achieve full automatic modification.

Benefits of technology

It significantly improves the efficiency and accuracy of data modification, reduces manual workload, avoids misoperation, and realizes automated node data modification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118656520A
    Figure CN118656520A
Patent Text Reader

Abstract

The invention discloses a data modification method, a storage medium and an electronic device, and relates to the technical field of smart home. The data modification method comprises the following steps: creating a client connected with a Zookeeper cluster, and acquiring a tree structure of nodes of the Zookeeper cluster through the client; data modification information is received through the client, and the data modification information comprises target node information and a node target value; traversing the tree structure to query a node matched with the target node information to obtain a to-be-modified node; and calling a preset parameter modification script through the client to replace a node value corresponding to the to-be-modified node in the Zookeeper cluster with the node target value. According to the scheme, the nodes of the Zookeeper cluster are automatically searched and modified, the manual workload can be obviously reduced, and the node data modification efficiency and accuracy can be obviously improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of smart home technology, and in particular to a data modification method, a storage medium and an electronic device. Background Art

[0002] Zookeeper cluster (hereinafter referred to as zk) is a top-level project of Apache, which provides efficient and highly available distributed coordination services for distributed applications. The data nodes in zk are similar to files or directories in the operating system, and the topological structure is a tree structure. In development, service information is usually registered to the data nodes for unified scheduling management. However, in the current development and operation and maintenance process, if you want to modify the value on the zk node, you usually need to manually modify it node by node through a visual graphical interface or command line. Because zk is usually deployed in the form of a cluster with many data nodes, this method of manually modifying each node is not only inefficient and cumbersome, but also easy to misoperate the data, thus causing a series of service problems. Summary of the invention

[0003] The present application provides a data modification method, storage medium and electronic device to solve the defects of low efficiency and high error rate in manual modification of Zookeeper node data in the prior art, and realize full automatic modification of Zookeeper data nodes.

[0004] According to a first aspect of the present invention, the present application provides a data modification method, the method comprising: Create a client connected to the Zookeeper cluster, and obtain the tree structure of the Zookeeper cluster nodes through the client; Receiving data modification information through the client, wherein the data modification information includes target node information and node target value; Traversing the tree structure to search for nodes matching the target node information, and obtaining a node to be modified; The client calls a preset parameter modification script to replace the node value corresponding to the node to be modified in the Zookeeper cluster with the node target value.

[0005] In some possible implementations, creating a client connected to a Zookeeper cluster and obtaining a tree structure of the Zookeeper cluster nodes through the client includes: Establish a connection with the Zookeeper cluster through the kazoo library and generate a client for operating the Zookeeper cluster; The client communicates with the Zookeeper cluster to obtain a tree structure composed of various nodes of the Zookeeper cluster.

[0006] In some possible implementations, the receiving, by the client, data modification information includes: Receive a complete node name input by a user through the client, and use the complete node name as the target node information; A node target value corresponding to the complete node name input by a user is received through the client.

[0007] In some possible implementations, the receiving, by the client, data modification information includes: Receiving at least one keyword in the target node information input by the user through the client, and using the at least one keyword as the target node information; A node target value corresponding to the at least one keyword input by a user is received through the client.

[0008] In some possible implementations, traversing the tree structure to search for nodes matching the target node information to obtain the node to be modified includes: Obtain all nodes at the first level in the tree structure to obtain the current level nodes; Determine whether each node of the current level node has a next level node; In response to the existence of a next-level node in any node in the current level node, the any node is placed in a preset container; Determine whether there is a node in the container; In the case where there are nodes in the preset container, the nodes in the preset container are taken out in a recursive traversal manner, all nodes of the next level of the taken out nodes are taken as the current level nodes, and the step of determining whether each node of the current level node has a next level node is returned to execute until there are no nodes in the preset container; In response to the fact that any node in the current level of nodes does not have a next-level node, it is determined whether the name of any node matches the target node information, and any matching node is used as the node to be modified.

[0009] In some possible implementations, before the step of replacing the node value corresponding to the to-be-modified node in the Zookeeper cluster with the node target value by calling a preset parameter modification script by the client, the method further includes: Send a modification confirmation request through the client; Receiving, through the client, a confirmation result corresponding to the modification confirmation request, wherein the confirmation result includes confirming the modification and abandoning the modification; If the confirmation result is not received within the preset time, return to the step of sending the modification confirmation request through the client until the number of times the modification confirmation request is sent exceeds the preset number; In response to the confirmation result being confirmation of modification, allowing the step of replacing the node value corresponding to the to-be-modified node in the Zookeeper cluster with the node target value by calling a preset parameter modification script through the client; In response to the confirmation result being abandoning the modification or the number of times the modification confirmation request is sent exceeds the preset number of times, the step of replacing the node value corresponding to the node to be modified in the Zookeeper cluster with the node target value by calling the preset parameter modification script by the client is prohibited.

[0010] In some possible implementations, before the step of sending the modification confirmation request through the client, the method further includes: Querying the current node value of the node to be modified through the client; Determine whether the current node value is the same as the node target value; In the case where the current node value is the same as the node target value, a prompt message indicating that no modification is required is issued through the client.

[0011] According to a second aspect of the present invention, the present application provides a data modification device, the device comprising: A creation module, the creation module is used to create a client connected to the Zookeeper cluster, and obtain the tree structure of the Zookeeper cluster nodes through the client; An acquisition module, the acquisition module is used to receive data modification information through the client, wherein the data modification information includes target node information and node target value; A traversal module, wherein the traversal module traverses the tree structure to search for nodes matching the target node information to obtain nodes to be modified; The modification module is used to replace the node value corresponding to the node to be modified in the Zookeeper cluster with the node target value by calling a preset parameter modification script through the client.

[0012] According to a third aspect of the present invention, the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored program, wherein the program is executed to implement any of the data modification methods described above when it is run.

[0013] According to a fourth aspect of the present invention, the present application further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute any of the data modification methods described above through the computer program.

[0014] The data modification method provided by the present application first creates a client connected to the Zookeeper cluster to obtain the tree structure of the Zookeeper cluster nodes, then uses the created client to receive data modification information, and then traverses the tree structure to query the nodes that match the target node information in the data modification information to obtain the nodes to be modified, and finally calls the preset parameter modification script through the client to replace the node value of the node to be modified with the node target value, thereby realizing automatic search and modification of the nodes of the Zookeeper cluster, so that during the data modification process, the user only needs to enter the node name to be modified and the new node to be modified, which can not only significantly reduce the manual workload, but also significantly improve the efficiency and accuracy of node data modification.

[0015] In addition, a data modification device, a computer-readable storage medium and an electronic device of this embodiment can also achieve the above-mentioned technical effects, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

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

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

[0018] Figure 1 It is a hardware environment diagram of a data modification method according to an embodiment of the present application.

[0019] Figure 2 This is one of the flow charts of the data modification method provided by this application.

[0020] Figure 3 This is the second flow chart of the data modification method provided by this application.

[0021] Figure 4 It is a structural schematic diagram of the data modification device provided in this application.

[0022] Figure 5 It is a schematic diagram of the structure of the electronic device provided in this application. DETAILED DESCRIPTION

[0023] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0025] According to one aspect of an embodiment of the present application, a data modification method is provided. The data modification method is widely used in smart home (Smart Home), smart home, smart home device ecology, smart residential (IntelligenceHouse) ecology and other whole-house intelligent digital control application scenarios. Optionally, in this embodiment, the above data modification method can be applied to Figure 1 In the hardware environment composed of the terminal device 102 and the server 104 shown in FIG. Figure 1 As shown, the server 104 is connected to the terminal device 102 via a network, and can be used to provide services (such as application services, etc.) for the terminal or a client installed on the terminal. A database can be set on the server or independently of the server to provide data storage services for the server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data computing services for the server 104.

[0026] The network may include but is not limited to at least one of the following: wired network, wireless network. The wired network may include but is not limited to at least one of the following: wide area network, metropolitan area network, local area network, and the wireless network may include but is not limited to at least one of the following: WIFI (Wireless Fidelity), Bluetooth. The terminal device 102 may be but is not limited to a PC, a mobile phone, a tablet computer, a smart air conditioner, a smart range hood, a smart refrigerator, a smart oven, a smart stove, a smart washing machine, a smart water heater, a smart washing device, a smart dishwasher, a smart projection device, a smart TV, a smart clothes drying rack, a smart curtain, a smart audio and video, a smart socket, a smart speaker, a smart fresh air device, a smart kitchen and bathroom device, a smart bathroom device, a smart sweeping robot, a smart window cleaning robot, a smart mopping robot, a smart air purification device, a smart steamer, a smart microwave oven, a smart kitchen treasure, a smart purifier, a smart water dispenser, a smart door lock, etc.

[0027] Figure 2 This is one of the flow charts of the data modification method provided by this application. Please refer to Figure 2 As shown, this embodiment provides a data modification method, which can be implemented through steps S201 to S204. Each step will be described in detail below: Step S201, creating a client connected to a Zookeeper cluster, and obtaining a tree structure of the Zookeeper cluster nodes through the client.

[0028] In this embodiment, the Zookeeper cluster refers to a collection of several groups of Zookeeper servers, which work together to provide a high-availability Zookeeper service. Zookeeper is a distributed coordination service that is used to manage configuration information, naming services, distributed locks, etc. in a distributed environment. In a Zookeeper cluster, multiple Zookeeper servers work together to maintain a Zookeeper service to improve its availability and fault tolerance. A node in a Zookeeper cluster is one of the Zookeeper servers. The nodes in the Zookeeper cluster are interrelated and form a tree structure with a hierarchical relationship. The tree structure can include multiple levels from top to bottom, and each level includes at least one node.

[0029] In this embodiment, any existing or future Zookeeper cluster management tool may be used to create a client connected to the Zookeeper cluster. Step S202 receives data modification information through the client, wherein the data modification information includes target node information and node target value.

[0030] In this embodiment, the data modification information may be generated by the user directly inputting on the client, or the data modification information may be inputted on other electronic devices and then sent to the client through the network. The target node information refers to the node information that the user expects to modify, and the node information may be the complete name or a partial name of the node. The node target value refers to the expected value of a parameter of the node that the user expects to modify.

[0031] Step S203, traversing the tree structure to search for nodes matching the target node information, and obtaining nodes to be modified.

[0032] In this embodiment, when traversing the tree structure, a preset node traversal order can be followed, for example, nodes are traversed from top to bottom, from left to right, or nodes are traversed from top to bottom and from right to left, or nodes are traversed from bottom to top, from left to right, etc. Among them, up and down are relative to the change of node level, the direction of increasing node level is from top to bottom, and the direction of decreasing node level is from bottom to top. Left and right are relative to nodes of the same level. For example, the direction of increasing serial numbers of nodes of the same level can be specified as from left to right, or the direction of decreasing serial numbers of nodes of the same level can be specified as from right to left. Matching with the target node information means that the information of the traversed node is the same as the target node information. It should be noted that the number of nodes to be modified is not fixed. The number of nodes to be modified may be one or more. The number of nodes to be modified is determined based on the actual matching results.

[0033] Step S204: The client calls a preset parameter modification script to replace the node value corresponding to the node to be modified in the Zookeeper cluster with the node target value.

[0034] In a specific implementation process, the preset parameter modification script includes but is not limited to a user's automatic parameter modification script, or certain commands in the existing kazoo library.

[0035] The data modification method of this embodiment first creates a client connected to the Zookeeper cluster to obtain the tree structure of the Zookeeper cluster nodes, then uses the created client to receive data modification information, and then traverses the tree structure to query the nodes that match the target node information in the data modification information to obtain the nodes to be modified, and finally calls the preset parameter modification script through the client to replace the node value of the node to be modified with the node target value, thereby realizing automatic search and modification of the Zookeeper cluster nodes, so that during the data modification process, the user only needs to enter the node name to be modified and the new node to be modified, which can not only significantly reduce the manual workload, but also significantly improve the efficiency and accuracy of node data modification.

[0036] In some possible implementations, the aforementioned step S201, creating a client connected to the Zookeeper cluster, and obtaining the tree structure of the Zookeeper cluster nodes through the client, specifically includes: Establish a connection with the Zookeeper cluster through the kazoo library and generate a client for operating the Zookeeper cluster; The client communicates with the Zookeeper cluster to obtain a tree structure composed of various nodes of the Zookeeper cluster.

[0037] The data modification method of this embodiment uses the kazoo library to establish a connection with the Zookeeper cluster, thereby constructing a client that can operate the Zookeeper cluster, making full use of the kazoo library and reducing R&D and operation and maintenance costs.

[0038] In some possible implementations, the aforementioned step S202, receiving data modification information through the client, specifically includes: Receive a complete node name input by a user through the client, and use the complete node name as the target node information; A node target value corresponding to the complete node name input by a user is received through the client.

[0039] The data modification method of this embodiment limits the target node information to a complete node name, which helps to achieve precise matching modification and improve the accuracy of data modification.

[0040] In some possible implementations, the aforementioned step S202, receiving data modification information through the client, specifically includes: Receiving at least one keyword in the target node information input by the user through the client, and using the at least one keyword as the target node information; A node target value corresponding to the at least one keyword input by a user is received through the client.

[0041] The data modification method of this embodiment limits the target node information to partial information in the complete node name, thereby achieving fuzzy matching modification and improving the flexibility of data modification.

[0042] In some possible implementations, the aforementioned step S203, traversing the tree structure to search for nodes matching the target node information to obtain the node to be modified, specifically includes: Obtain all nodes at the first level in the tree structure to obtain the current level nodes; Determine whether each node of the current level node has a next level node; In response to the existence of a next-level node in any node in the current level node, the any node is placed in a preset container; Determine whether there is a node in the container; In the case where there are nodes in the preset container, the nodes in the preset container are taken out in a recursive traversal manner, all nodes of the next level of the taken out nodes are taken as the current level nodes, and the step of determining whether each node of the current level node has a next level node is returned to execute until there are no nodes in the preset container; In response to the fact that any node in the current level of nodes does not have a next-level node, it is determined whether the name of any node matches the target node information, and any matching node is used as the node to be modified.

[0043] The data modification method of this embodiment realizes the breadth traversal of the tree structure of the Zookeeper cluster and performs batch automatic modification according to the nodes that the user needs to modify. This solution is not only highly efficient but also accurate in modification, avoiding the problems of low efficiency and high error rate caused by manual modification.

[0044] In some possible implementations, in the aforementioned step S204, before the client calls a preset parameter modification script to replace the node value corresponding to the to-be-modified node in the Zookeeper cluster with the node target value, the method further includes: Send a modification confirmation request through the client; Receiving, through the client, a confirmation result corresponding to the modification confirmation request, wherein the confirmation result includes confirming the modification and abandoning the modification; If the confirmation result is not received within the preset time, return to the step of sending the modification confirmation request through the client until the number of times the modification confirmation request is sent exceeds the preset number; In response to the confirmation result being confirmation of modification, allowing the step of replacing the node value corresponding to the to-be-modified node in the Zookeeper cluster with the node target value by calling a preset parameter modification script through the client; In response to the confirmation result being abandoning the modification or the number of times the modification confirmation request is sent exceeds the preset number of times, the step of replacing the node value corresponding to the node to be modified in the Zookeeper cluster with the node target value by calling the preset parameter modification script by the client is prohibited.

[0045] The data modification method of this embodiment interacts with the user through the client before executing the node data modification, so that the execution of the modification operation needs to be confirmed by the user, and no modification will be performed without confirmation, thereby ensuring the security and reliability of data modification.

[0046] In some possible implementations, before the step of sending the modification confirmation request through the client, the method further includes: Querying the current node value of the node to be modified through the client; Determine whether the current node value is the same as the node target value; In the case where the current node value is the same as the node target value, a prompt message indicating that no modification is required is issued through the client.

[0047] The data modification method of this embodiment avoids invalid modification and reduces the error probability by pre-querying the current node value of the node to be modified before executing the node data modification and comparing the current node value with the node target value.

[0048] In another embodiment, in order to facilitate understanding of the solution of the present invention, the following takes the kazoo library to operate Zookeeper as an example, please refer to Figure 3 As shown, this embodiment provides another data modification method, and the specific implementation process is as follows: First, the user enters the node name and node value to be modified; Then, the program creates a connection with zk; Next, get all nodes of the current level of zk; Next, determine whether the current node has a child node. If so, temporarily store the node in a container. If not, determine whether the node matches the node to be modified and modify it. Finally, after the node traversal of the current level is completed, it is determined whether there is node data to be traversed in the container of the temporary node. If so, it means that the traversal needs to be continued, and then the above steps are repeated again by recursive traversal. If there is no node data in the container of the temporary node, it means that the entire zk node has been traversed and the operation is completed.

[0049] The data modification method of this embodiment has at least the following beneficial effects: first, the user only needs to enter the node name and node value to be modified, which significantly improves the convenience of data modification; second, it can achieve batch modification of nodes at the millisecond level, which greatly improves the efficiency compared to manual modification and significantly improves the modification efficiency; finally, it is particularly suitable for situations where there are a large number of zk cluster nodes, and can avoid the problem of manual modification errors and achieve accurate automatic matching modifications.

[0050] The data modification device provided in the present application is described below. The data modification device described below and the data modification method described above can be referenced to each other.

[0051] Please refer to Figure 4As shown, this embodiment provides a data modification device, specifically, the device includes: a creation module 410, an acquisition module 420, a traversal module 430 and a modification module 440, and the above modules are described in detail below: a creation module 410, the creation module 410 is used to create a client connected to the Zookeeper cluster, and obtain the tree structure of the Zookeeper cluster node through the client; An acquisition module 420, the acquisition module 420 is used to receive data modification information through the client, wherein the data modification information includes target node information and node target value; A traversal module 430, wherein the traversal module 430 traverses the tree structure to search for nodes matching the target node information and obtain a node to be modified; The modification module 440 is used to replace the node value corresponding to the to-be-modified node in the Zookeeper cluster with the node target value by calling a preset parameter modification script through the client.

[0052] The data modification device of this embodiment first creates a client connected to the Zookeeper cluster to obtain the tree structure of the Zookeeper cluster nodes, then uses the created client to receive data modification information, and then traverses the tree structure to query the nodes that match the target node information in the data modification information to obtain the nodes to be modified, and finally calls the preset parameter modification script through the client to replace the node value of the node to be modified with the node target value, thereby realizing automatic search and modification of the nodes of the Zookeeper cluster, so that during the data modification process, the user only needs to enter the node name to be modified and the new node to be modified, which can not only significantly reduce the manual workload, but also significantly improve the efficiency and accuracy of node data modification.

[0053] In some possible implementations, the creation module 410 is further configured to: Establish a connection with the Zookeeper cluster through the kazoo library and generate a client for operating the Zookeeper cluster; The client communicates with the Zookeeper cluster to obtain a tree structure composed of various nodes of the Zookeeper cluster.

[0054] In some possible implementations, the acquisition module 420 is further configured to: Receive a complete node name input by a user through the client, and use the complete node name as the target node information; A node target value corresponding to the complete node name input by a user is received through the client.

[0055] In some possible implementations, the acquisition module 420 is further configured to: Receiving at least one keyword in the target node information input by the user through the client, and using the at least one keyword as the target node information; A node target value corresponding to the at least one keyword input by a user is received through the client.

[0056] In some possible implementations, the traversal module 430 is further configured to: Obtain all nodes at the first level in the tree structure to obtain the current level nodes; Determine whether each node of the current level node has a next level node; In response to the existence of a next-level node in any node in the current level node, the any node is placed in a preset container; Determine whether there is a node in the container; In the case where there are nodes in the preset container, the nodes in the preset container are taken out in a recursive traversal manner, all nodes of the next level of the taken out nodes are taken as the current level nodes, and the step of determining whether each node of the current level node has a next level node is returned to execute until there are no nodes in the preset container; In response to the fact that any node in the current level of nodes does not have a next-level node, it is determined whether the name of any node matches the target node information, and any matching node is used as the node to be modified.

[0057] In some possible implementations, the device further includes a confirmation module, where the confirmation module is configured to: Send a modification confirmation request through the client; Receiving, through the client, a confirmation result corresponding to the modification confirmation request, wherein the confirmation result includes confirming the modification and abandoning the modification; If the confirmation result is not received within the preset time, return to the step of sending the modification confirmation request through the client until the number of times the modification confirmation request is sent exceeds the preset number; In response to the confirmation result being confirmation of modification, allowing the step of replacing the node value corresponding to the to-be-modified node in the Zookeeper cluster with the node target value by calling a preset parameter modification script through the client; In response to the confirmation result being abandoning the modification or the number of times the modification confirmation request is sent exceeds the preset number of times, the step of replacing the node value corresponding to the node to be modified in the Zookeeper cluster with the node target value by calling the preset parameter modification script by the client is prohibited.

[0058] In some possible implementations, the confirmation module is further configured to: Querying the current node value of the node to be modified through the client; Determine whether the current node value is the same as the node target value; In the case where the current node value is the same as the node target value, a prompt message indicating that no modification is required is issued through the client.

[0059] It should be noted that each module in the above-mentioned data modification device can be implemented in whole or in part by software, hardware, or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in an electronic device in the form of hardware, or can be stored in a memory in an electronic device in the form of software, so that the processor can call and execute operations corresponding to each of the above modules.

[0060] Figure 5 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 complete mutual communication through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the data modification method, which includes: creating a client connected to the Zookeeper cluster, and obtaining the tree structure of the Zookeeper cluster nodes through the client; receiving data modification information through the client, wherein the data modification information includes target node information and node target value; traversing the tree structure to query the node matching the target node information to obtain the node to be modified; and calling the preset parameter modification script through the client to replace the node value corresponding to the node to be modified in the Zookeeper cluster with the node target value.

[0061] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0062] On the other hand, the present application also provides a computer program product, which includes a computer program. The computer program can be stored on a computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the data modification method provided by the above methods, which includes: creating a client connected to the Zookeeper cluster, and obtaining the tree structure of the Zookeeper cluster nodes through the client; receiving data modification information through the client, wherein the data modification information includes target node information and node target value; traversing the tree structure to query the node matching the target node information to obtain the node to be modified; and calling the preset parameter modification script through the client to replace the node value corresponding to the node to be modified in the Zookeeper cluster with the node target value.

[0063] On the other hand, the present application also provides a computer-readable storage medium, which includes a stored program, wherein the program executes the data modification method provided by the above methods when it is running, and the method includes: creating a client connected to the Zookeeper cluster, and obtaining the tree structure of the Zookeeper cluster nodes through the client; receiving data modification information through the client, wherein the data modification information includes target node information and node target value; traversing the tree structure to query the node matching the target node information to obtain the node to be modified; and calling the preset parameter modification script through the client to replace the node value corresponding to the node to be modified in the Zookeeper cluster with the node target value.

[0064] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

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

[0066] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A data modification method, characterized in that: The method comprises: Create a client connected to the Zookeeper cluster, and obtain the tree structure of the Zookeeper cluster nodes through the client; Receiving data modification information through the client, wherein the data modification information includes target node information and node target value; Traversing the tree structure to search for nodes matching the target node information, and obtaining a node to be modified; The client calls a preset parameter modification script to replace the node value corresponding to the node to be modified in the Zookeeper cluster with the node target value.

2. The data modification method according to claim 1, characterized in that: The step of creating a client connected to a Zookeeper cluster and obtaining a tree structure of the Zookeeper cluster nodes through the client includes: Establish a connection with the Zookeeper cluster through the kazoo library and generate a client for operating the Zookeeper cluster; The client communicates with the Zookeeper cluster to obtain a tree structure composed of various nodes of the Zookeeper cluster.

3. The data modification method according to claim 1, characterized in that: The receiving data modification information through the client includes: Receive a complete node name input by a user through the client, and use the complete node name as the target node information; A node target value corresponding to the complete node name input by a user is received through the client.

4. The data modification method according to claim 1, characterized in that: The receiving data modification information through the client includes: Receiving at least one keyword in the target node information input by the user through the client, and using the at least one keyword as the target node information; A node target value corresponding to the at least one keyword input by a user is received through the client.

5. The data modification method according to claim 2, characterized in that: The traversing the tree structure to search for nodes matching the target node information to obtain the node to be modified includes: Obtain all nodes at the first level in the tree structure to obtain the current level nodes; Determine whether each node of the current level node has a next level node; In response to the existence of a next-level node in any node in the current level node, the any node is placed in a preset container; Determine whether there is a node in the container; In the case where there are nodes in the preset container, the nodes in the preset container are taken out in a recursive traversal manner, all nodes of the next level of the taken out nodes are taken as the current level nodes, and the step of determining whether each node of the current level node has a next level node is returned to execute until there are no nodes in the preset container; In response to the fact that any node in the current level of nodes does not have a next-level node, it is determined whether the name of any node matches the target node information, and any matching node is used as the node to be modified.

6. The data modification method according to claim 1, characterized in that: Before the step of replacing the node value corresponding to the to-be-modified node in the Zookeeper cluster with the node target value by calling the preset parameter modification script by the client, the method further includes: Send a modification confirmation request through the client; Receiving, through the client, a confirmation result corresponding to the modification confirmation request, wherein the confirmation result includes confirming the modification and abandoning the modification; If the confirmation result is not received within the preset time, return to the step of sending the modification confirmation request through the client until the number of times the modification confirmation request is sent exceeds the preset number; In response to the confirmation result being confirmation of modification, allowing the step of replacing the node value corresponding to the to-be-modified node in the Zookeeper cluster with the node target value by calling a preset parameter modification script through the client; In response to the confirmation result being abandoning the modification or the number of times the modification confirmation request is sent exceeds the preset number of times, the step of replacing the node value corresponding to the node to be modified in the Zookeeper cluster with the node target value by calling the preset parameter modification script by the client is prohibited.

7. The data modification method according to claim 6, characterized in that: Before the step of sending the modification confirmation request through the client, the method further includes: Querying the current node value of the node to be modified through the client; Determine whether the current node value is the same as the node target value; In the case where the current node value is the same as the node target value, a prompt message indicating that no modification is required is issued through the client.

8. A data modification device, characterized in that: include: A creation module, the creation module is used to create a client connected to the Zookeeper cluster, and obtain the tree structure of the Zookeeper cluster nodes through the client; An acquisition module, the acquisition module is used to receive data modification information through the client, wherein the data modification information includes target node information and node target value; A traversal module, wherein the traversal module traverses the tree structure to search for nodes matching the target node information to obtain nodes to be modified; The modification module is used to replace the node value corresponding to the node to be modified in the Zookeeper cluster with the node target value by calling a preset parameter modification script through the client.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the data modification method according to any one of claims 1 to 7 is executed when the program is executed.

10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the data modification method according to any one of claims 1 to 7 through the computer program.

Citation Information

Patent Citations

  • Master-slave cluster switching method and device

    CN109245908A

  • Data processing method and device for zookeeper client

    CN109525649A

  • Node configuration method and device, computer device and readable storage medium

    CN110113181A

  • Code format standardization method and device, electronic equipment and storage medium

    CN116028027A

  • ID value-based tree structure construction method and system

    CN117972180A