State synchronization method, device, electronic device and medium for distributed graph database
By determining node status changes, generating and sending status change messages in the distributed graph database, the problem of node status synchronization delay is solved, efficient status synchronization and system stability are achieved, and resource consumption is reduced.
Patent Information
- Application Number
- CN202011480908.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-15
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2040-12-15
AI Technical Summary
In distributed graph databases, changes in node status lead to delayed status synchronization, affecting the timeliness of data routing and data processing, and it is difficult for existing technologies to effectively guarantee system stability and resource utilization efficiency.
By determining the changed status of nodes in the distributed graph database, generating status change messages and sending them to registered nodes, status synchronization is achieved, reducing the amount of synchronized data, improving timeliness, and ensuring consistent status through an asynchronous message transmission queue. sex.
It effectively improves the state synchronization timeliness of the distributed graph database, ensures the operational stability of the system, and saves the consumption of hardware and software resources.
Smart Images

Figure CN112559632B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, specifically to the field of artificial intelligence technology such as knowledge graphs, distributed storage, and big data processing, and in particular to a state synchronization method, device, electronic device, and medium for a distributed graph database. Background Art
[0002] Artificial intelligence is a discipline that studies how to use computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.). It includes both hardware-level and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing; artificial intelligence software technologies mainly include computer vision technology, speech recognition technology, natural language processing technology, as well as machine learning / deep learning, big data processing technology, knowledge graph technology, and other major directions.
[0003] In a distributed graph database, the underlying storage cluster may change state at any time. For example, a master node in a replication group may change, or a cluster member node may change. These changed states may affect the routing information when the upper layer reads and writes data. Therefore, these changed states need to be obtained by the upstream data in a timely manner. Summary of the invention
[0004] Provided are a state synchronization method, device, electronic device, storage medium, and computer program product for a distributed graph database.
[0005] According to a first aspect, a state synchronization method for a distributed graph database is provided, comprising: determining a changed state of a first node in the distributed graph database; generating a state change message based on the changed state; determining an identifier of a currently registered second node; and sending the state change message to a second node to which the identifier of the second node belongs.
[0006] According to the second aspect, a state synchronization device for a distributed graph database is provided, comprising: a first determination module for determining a changed state of a first node in the distributed graph database; a generation module for generating a state change message according to the changed state; a second determination module for determining an identifier of a currently registered second node; and a first sending module for sending the state change message to a second node to which the identifier of the second node belongs.
[0007] According to the third aspect, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the state synchronization method of a distributed graph database of an embodiment of the present application.
[0008] According to the fourth aspect, a non-transitory computer-readable storage medium storing computer instructions is proposed, wherein the computer instructions are used to enable the computer to execute the state synchronization method of the distributed graph database disclosed in the embodiment of the present application.
[0009] According to the fifth aspect, a computer program product is proposed, including a computer program, which, when executed by a processor, implements the state synchronization method of the distributed graph database disclosed in the embodiment of the present application.
[0010] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present application.
[0012] Figure 1 is a schematic diagram according to the first embodiment of the present application;
[0013] Figure 2 is a schematic diagram according to a second embodiment of the present application;
[0014] Figure 3 is a schematic diagram according to a third embodiment of the present application;
[0015] Figure 4 is a schematic diagram according to a fourth embodiment of the present application;
[0016] Figure 5 It is a block diagram of an electronic device used to implement the state synchronization method of a distributed graph database in an embodiment of the present application. DETAILED DESCRIPTION
[0017] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0018] Figure 1 It is a schematic diagram according to the first embodiment of the present application.
[0019] It should be noted that the executor of the state synchronization method of the distributed graph database in this embodiment is a state synchronization device of the distributed graph database, which can be implemented by software and / or hardware. The device can be configured in an electronic device, which may include but is not limited to a terminal, a server, etc.
[0020] The embodiments of the present application relate to the fields of artificial intelligence technology such as knowledge graphs, distributed storage, and big data processing.
[0021] Among them, Artificial Intelligence (AI) is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence.
[0022] Knowledge graph is a modern theory that achieves the purpose of multidisciplinary integration by combining the theories and methods of applied mathematics, graphics, information visualization technology, information science and other disciplines with metrological citation analysis, co-occurrence analysis and other methods, and using visual graphs to vividly display the core structure, development history, frontier fields and overall knowledge architecture of the discipline.
[0023] Distributed storage is the process of storing data in a dispersed manner on multiple independent machines and devices.
[0024] Big data processing refers to the process of analyzing and processing huge amounts of data using artificial intelligence. Big data can be summarized as five Vs: volume, velocity, variety, value, and veracity.
[0025] like Figure 1 As shown, the state synchronization method of the distributed graph database includes:
[0026] S101: Determine the changed state of the first node in the distributed graph database.
[0027] The execution entity in the embodiment of the present application may be, for example, a configuration center, which may be specifically deployed on a node in a distributed graph database, or may be deployed on a device independent of the distributed graph database, without limitation.
[0028] It is understandable that graph databases are usually based on graph theory in data structure. There are two core elements that make up a graph: nodes (vertex or node, also called points) and attributes on the nodes, and edges (edge or relationship, also called relationships) and attributes on the edges.
[0029] In the embodiment of the present application, the first node may be any node in the distributed graph database, and the state of the first node, for example, the first node is a master node, or the first node is a slave node, is not limited.
[0030] In this embodiment, if the state of the first node changes, the changed state is obtained and sent to the configuration center in real time. That is, the configuration center monitors the state changes of each node in the distributed graph database and synchronizes the changed state accordingly.
[0031] After the above-mentioned first node obtains the changed state and sends the changed state to the configuration center in real time, the configuration center can receive the changed state of the first node in the distributed graph database, and then trigger subsequent steps.
[0032] S102: Generate a state change message according to the changed state.
[0033] After receiving the changed state of the first node in the distributed graph database, the above-mentioned configuration center can generate a state change message based on the changed state. For example, a variable can be maintained based on the changed state. When it is determined that the changed state is different from the current state of the first node, the variable can be updated accordingly to obtain a new variable, and then a state change message is generated so that the state change message carries the new variable.
[0034] S103: Determine the identifier of the currently registered second node.
[0035] In the embodiment of the present application, when the configuration center determines that the state of the first node has changed, it may search for the identifier of the currently registered second node.
[0036] The second node is a node in the distributed graph database, and the second node has been pre-registered in the configuration center.
[0037] Optionally, in some embodiments, before determining the changed state of the first node in the distributed graph database, a registration request sent by the second node is also received, and the registration request carries the identifier and current state of the second node; the second node is registered according to the identifier and current state of the second node, so as to register the second node in the configuration center in advance, thereby assisting in on-demand distribution and synchronization of the changed state of the first node, which can save hardware and software computing resources consumed by the operation of the distributed graph database while ensuring the operational stability of the distributed graph database.
[0038] The identifier of the second node can be used to uniquely identify the second node. The second node may be a node different from the first node. The first node may also be a node registered in the configuration center. The configuration center not only registers some or all of the nodes, but also saves the current status of each registered node.
[0039] After obtaining the identifier of the second node and the current state of the second node, the configuration center may call a preset registration processing logic to register the second node, so that the registered second node plays the role of an observer.
[0040] S104: Send a state change message to the second node to which the second node identifier belongs.
[0041] After determining the identifier of the currently registered second node, the configuration center may accordingly determine the registered second node, and then the configuration center may send a state change message to the second node to which the identifier of the second node belongs in real time.
[0042] It should be noted that the state change message at this time is used to notify the second node that the current state of the first node has changed, but may not include the specific changed state of the first node.
[0043] Therefore, in an embodiment of the present application, by sending a state change message to the second node to which the identifier of the second node belongs, the amount of synchronized data is reduced, thereby effectively improving the timeliness of the state synchronization of the distributed graph database.
[0044] Optionally, in some embodiments, if there are multiple currently registered second nodes, the state change message is sent to the second node to which the identifier of the second node belongs, and the state change message can be sent to the second nodes to which the identifiers of each second node belong at the same time, thereby comprehensively improving the timeliness of state synchronization and effectively avoiding possible failures of the distributed graph database.
[0045] In this embodiment, by determining the changed state of the first node in the distributed graph database; generating a state change message based on the changed state; determining the identifier of the currently registered second node; and sending the state change message to the second node to which the identifier of the second node belongs, the timeliness of the state synchronization of the distributed graph database can be effectively improved, thereby ensuring the operational stability of the distributed graph database.
[0046] Figure 2 It is a schematic diagram according to the second embodiment of the present application.
[0047] like Figure 2 As shown, the state synchronization method of the distributed graph database includes:
[0048] S201: Determine the changed state of the first node in the distributed graph database.
[0049] S202: Generate a state change message according to the changed state.
[0050] S203: Determine the identifier of the currently registered second node.
[0051] S204: Send a state change message to the second node to which the identifier of the second node belongs.
[0052] The description of S201 - S204 can be specifically referred to the above embodiment, which will not be repeated here.
[0053] S205: Receive a status acquisition request sent by the second node.
[0054] After sending the state change message to the second node to which the second node identifier belongs, it may be monitored in real time whether a state acquisition request sent by the second node is received.
[0055] That is to say, after receiving the status change message sent by the configuration center, the second node can be informed that the status of the first node has changed, and then the second node can determine whether it needs to obtain the full amount of status change data based on the actual application needs. If there is a need to obtain the full amount of status change data, a status acquisition request can be generated and sent to the configuration center.
[0056] S206: In response to the status acquisition request, send the changed status to the second node.
[0057] After receiving the status acquisition request sent by the second node, the configuration center can respond to the status acquisition request and send the changed status to the second node, so that the second node can obtain the changed status of the first node on demand and in a timely manner.
[0058] Optionally, in some embodiments, the changed state may be added to an asynchronous message transmission queue in response to a state acquisition request; and the changed state in the asynchronous message transmission queue may be sent to the second node to which the identifier of the second node belongs in an asynchronous manner.
[0059] It can be understood that based on the operating characteristics of the distributed graph database, the state of each node may change once or multiple times. In the embodiment of the present application, in order to send the changed state to the second node according to the time sequence of the state change and ensure that the second node obtains the latest changed state, the changed state can be added to the asynchronous message transmission queue, and the changed state in the asynchronous message transmission queue can be sent to the second node to which the identifier of the second node belongs in an asynchronous manner.
[0060] In this embodiment, by determining the changed state of the first node in the distributed graph database; generating a state change message according to the changed state; determining the identifier of the currently registered second node; and sending the state change message to the second node to which the identifier of the second node belongs, the timeliness of the state synchronization of the distributed graph database can be effectively improved, thereby ensuring the operational stability of the distributed graph database. By receiving a state acquisition request sent by the second node, and responding to the state acquisition request, the changed state is sent to the second node, so that the second node can obtain the changed state of the first node on demand and in a timely manner. By adding the changed state to the asynchronous message transmission queue, and using an asynchronous sending method to send the changed state in the asynchronous message transmission queue to the second node to which the identifier of the second node belongs, it is possible to send the changed state to the second node according to the time sequence of the state change, ensuring that the second node obtains the latest changed state.
[0061] Figure 3 It is a schematic diagram according to the third embodiment of the present application.
[0062] like Figure 3 As shown, the state synchronization device 30 of the distributed graph database includes:
[0063] A first determination module 301 is used to determine a changed state of a first node in a distributed graph database;
[0064] A generating module 302, configured to generate a state change message according to the changed state;
[0065] A second determination module 303 is used to determine the identifier of the currently registered second node; and
[0066] The first sending module 304 is configured to send a state change message to the second node to which the second node identifier belongs.
[0067] In some embodiments of the present application, Figure 4 As shown, Figure 4 It is a schematic diagram according to the fourth embodiment of the present application. The state synchronization device 40 of the distributed graph database includes: a first determination module 401, a generation module 402, a second determination module 403, a first sending module 404, and further includes:
[0068] A first receiving module 405, configured to receive a status acquisition request sent by a second node;
[0069] The second sending module 406 is configured to send the changed state to the second node in response to the state acquisition request.
[0070] In some embodiments of the present application, Figure 4 As shown, it also includes:
[0071] A second receiving module 407, configured to receive a registration request sent by a second node, where the registration request carries an identifier and a current state of the second node;
[0072] The registration module 408 is used to register the second node according to the identifier and current state of the second node.
[0073] In some embodiments of the present application, the number of currently registered second nodes is multiple, wherein the first sending module 404 is specifically used to:
[0074] The state change message is sent simultaneously to the second nodes to which the identifiers of the respective second nodes belong.
[0075] In some embodiments of the present application, the second sending module 406 is specifically configured to:
[0076] In response to the state acquisition request, the changed state is added to the asynchronous message transmission queue; and the changed state in the asynchronous message transmission queue is sent to the second node to which the identifier of the second node belongs in an asynchronous sending manner.
[0077] It is understandable that the present embodiment Figure 4 The state synchronization device 40 of the distributed graph database in the above embodiment and the state synchronization device 30 of the distributed graph database in the above embodiment, the first determination module 401 and the first determination module 301 in the above embodiment, the generation module 402 and the generation module 302 in the above embodiment, the second determination module 403 and the second determination module 303 in the above embodiment, and the first sending module 404 and the first sending module 304 in the above embodiment may have the same function and structure.
[0078] It should be noted that the aforementioned explanation of the state synchronization method of the distributed graph database is also applicable to the state synchronization device of the distributed graph database of this embodiment, and will not be repeated here.
[0079] In this embodiment, by determining the changed state of the first node in the distributed graph database; generating a state change message based on the changed state; determining the identifier of the currently registered second node; and sending the state change message to the second node to which the identifier of the second node belongs, the timeliness of the state synchronization of the distributed graph database can be effectively improved, thereby ensuring the operational stability of the distributed graph database.
[0080] According to an embodiment of the present application, the present application also provides an electronic device, a readable storage medium and a computer program product.
[0081] Figure 5 It is a block diagram of an electronic device for implementing the state synchronization method of the distributed graph database of an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.
[0082] like Figure 5 As shown, the device 500 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the device 500 can also be stored. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0083] A number of components in the device 500 are connected to the I / O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the device 500 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0084] The computing unit 501 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 501 performs the various methods and processes described above, for example, a state synchronization method for a distributed graph database.
[0085] For example, in some embodiments, the state synchronization method of a distributed graph database may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the computing unit 501, one or more steps of the state synchronization method of the distributed graph database described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to execute the state synchronization method of the distributed graph database in any other appropriate manner (e.g., by means of firmware).
[0086] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0087] The program code for implementing the state synchronization method of the distributed graph database of the present application can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, partially on the machine as an independent software package and partially on a remote machine, or entirely on a remote machine or server.
[0088] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0089] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0090] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.
[0091] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain.
[0092] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution disclosed in this application can be achieved, and this document is not limited here.
[0093] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.
Claims
1. A state synchronization method for a distributed graph database, comprising: Determine a changed state of a first node in a distributed graph database; Generate a state change message according to the changed state, wherein the state change message does not include the specific changed state of the first node; Determining an identifier of a currently registered second node; as well as Sending the state change message to the second node to which the identifier of the second node belongs; Receiving a status acquisition request sent by the second node; In response to the state acquisition request, adding the changed state to the asynchronous message transmission queue; The changed state in the asynchronous message transmission queue is sent to the second node to which the identifier of the second node belongs in an asynchronous sending manner.
2. The method according to claim 1, before determining the changed state of the first node in the distributed graph database, further comprises: receiving a registration request sent by the second node, where the registration request carries an identifier and a current state of the second node; The second node is registered according to the identifier of the second node and the current state.
3. The method according to claim 2, wherein the number of the currently registered second nodes is multiple, wherein: The sending the state change message to the second node to which the identifier of the second node belongs includes: The state change message is sent simultaneously to the second nodes to which the identifiers of the second nodes belong.
4. A state synchronization device for a distributed graph database, comprising: A first determination module, used to determine a changed state of a first node in a distributed graph database; A generating module, configured to generate a state change message according to the changed state, wherein the state change message does not include a specific changed state of the first node; A second determination module, used to determine the identifier of the currently registered second node; as well as A first sending module, configured to send the state change message to a second node to which the identifier of the second node belongs; A first receiving module, used to receive a status acquisition request sent by the second node; The second sending module is used to add the changed state to the asynchronous message transmission queue in response to the state acquisition request; and send the changed state in the asynchronous message transmission queue to the second node to which the identifier of the second node belongs in an asynchronous sending manner.
5. The apparatus according to claim 4, further comprising: A second receiving module, configured to receive a registration request sent by the second node, where the registration request carries an identifier and a current state of the second node; A registration module is used to register the second node according to the identifier of the second node and the current state.
6. The device according to claim 5, wherein the number of the currently registered second nodes is multiple, wherein: The first sending module is specifically used for: The state change message is sent simultaneously to the second nodes to which the identifiers of the second nodes belong.
7. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 3.
8. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-3.
9. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 3.
