Data processing method, device and equipment and readable storage medium
By monitoring the architectural changes of data nodes in real time and updating node connections in the database direct connection architecture, the connection error problem caused by data node changes in traditional databases is solved, and the reliability and availability of data are improved.
Patent Information
- Application Number
- CN202410316109.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-19
- Publication Date
- 2025-09-19
AI Technical Summary
Changes in data nodes in traditional databases lead to application node connection errors, reducing data reliability and availability.
In the database direct connection architecture, the architecture changes of data nodes are monitored in real time through the gateway layer. Application nodes regularly obtain the latest architecture description data and update node connections in a timely manner to ensure that connections are established with the correct data nodes.
It improves the data reliability and availability of the database, reduces the response delay, and ensures that the application nodes maintain an effective connection with the normally operating data nodes.
Smart Images

Figure CN120670408A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a data processing method, apparatus, device, and readable storage medium. Background Art
[0002] Databases are crucial in many application scenarios, recording and storing relevant business data. A database consists of different data nodes. To store or read application data from a database, you connect the application to the corresponding data node in the database to write data to or read data from the database. For example, an application can connect to a data node with read / write capabilities in the database, allowing it to write data to or read data from that node. Alternatively, an application can connect to a data node with read-only capabilities in the database, allowing it to read data from that node.
[0003] In traditional technology, an application can send a connection request to a database. This connection request specifies the data node to which the application needs to connect. The database can then connect the application to the specified data node based on the application's connection request. However, because data nodes in a database are subject to change, some data nodes may go offline or fail (for example, failing to cache data in a timely manner). This means that the data node to which the application is connected may also go offline or fail. In this case, the application will query incorrect data from the failed data node, which will reduce the reliability of the data provided by the database. Summary of the Invention
[0004] The embodiments of the present application provide a data processing method, apparatus, device, and readable storage medium, which can achieve high availability of a database to improve the reliability of data provided by the database.
[0005] In one aspect, an embodiment of the present application provides a data processing method, which is applied to a database direct connection architecture. The database direct connection architecture includes an application layer, a gateway layer, and a database. The gateway layer and the database are both connected to the application layer. The gateway layer includes at least one gateway device, each gateway device being used to monitor and record changes in database architecture description data. The database architecture description data is used to describe the architecture of N data nodes in the database, where N is a positive integer. The method is executed by any application node in the application layer, and the method includes:
[0006] When the first data acquisition time is reached, querying the first architecture description data having the maximum timestamp from the first gateway device in the gateway layer;
[0007] Acquiring second architecture description data with a maximum timestamp from a second gateway device in the gateway layer at a second data acquisition time; the second data acquisition time is a data acquisition time before the first data acquisition time;
[0008] Determining architecture change attributes of N data nodes based on the first architecture description data and the second architecture description data;
[0009] If the architecture change attributes of the N data nodes indicate that the N data nodes have architecture changes, the node connection of the application node to the database is updated.
[0010] In one aspect, an embodiment of the present application provides a data processing device, which is applied to a database direct connection architecture. The database direct connection architecture includes: an application layer, a gateway layer, and a database; the gateway layer and the database are both connected to the application layer; the gateway layer includes at least one gateway device, each gateway device is used to monitor and record changes in the database's architecture description data; the database architecture description data is used to describe the architecture of N data nodes in the database, where N is a positive integer; the device is specifically applied to any application node in the application layer, and includes:
[0011] A data acquisition module, configured to query first architecture description data having a maximum timestamp from a first gateway device in the gateway layer when a first data acquisition time is reached;
[0012] The data acquisition module is further configured to acquire second architecture description data with a maximum timestamp retrieved from a second gateway device in the gateway layer at a second data acquisition time; the second data acquisition time is a data acquisition time preceding the first data acquisition time;
[0013] an attribute determination module, configured to determine architecture change attributes of N data nodes based on the first architecture description data and the second architecture description data;
[0014] The connection update module is configured to update the node connection of the application node to the database if the architecture change attributes of the N data nodes indicate that the N data nodes have architecture changes.
[0015] In one embodiment, the specific implementation method of the attribute determination module determining the architecture change attributes of N data nodes based on the first architecture description data and the second architecture description data includes:
[0016] Determine, based on the first architecture description data, node master-slave attributes and node operation attributes of each data node in the database at the first data acquisition moment;
[0017] Determine, based on the second architecture description data, node master-slave attributes and node operation attributes of each data node in the database at the second data acquisition moment;
[0018] Determining a node master-slave switching attribute of each data node based on the node master-slave attribute of each data node at the first data acquisition time and the second data acquisition time; the single-node master-slave switching attribute includes a first switching attribute and a second switching attribute, the first switching attribute is used to indicate whether the data node has switched between master and slave attributes, and the second switching attribute is used to indicate whether the data node has not switched between master and slave attributes;
[0019] Determine, based on the node operation attributes of each data node at the first data acquisition time and the second data acquisition time, a node operation change attribute of each data node; the node operation change attribute includes a first operation change attribute and a second operation change attribute, the first operation change attribute is used to indicate that there is a change in the operation state of the data node, and the second operation change attribute is used to indicate that there is no change in the operation state of the data node;
[0020] According to the node master-slave switching attribute and the node operation change attribute of each data node, the architecture change attributes of N data nodes are determined.
[0021] In one embodiment, the attribute determination module determines a specific implementation method of the node master-slave switching attribute of each data node based on the node master-slave attribute of each data node at the first data acquisition time and the second data acquisition time, including:
[0022] Determine any data node among the N data nodes as the target data node;
[0023] Comparing the node master-slave attribute of the target data node at the first data acquisition moment with the node master-slave attribute of the target data node at the second data acquisition moment;
[0024] If the node master-slave attribute of the target data node at the first data acquisition moment is different from the node master-slave attribute of the target data node at the second data acquisition moment, determining that the node master-slave switching attribute of the target data node is the first switching attribute;
[0025] If the node master-slave attribute of the target data node at the first data acquisition moment is the same as the node master-slave attribute of the target data node at the second data acquisition moment, the node master-slave switching attribute of the target data node is determined to be the second switching attribute.
[0026] In one embodiment, the attribute determination module determines the specific implementation method of the architecture change attributes of N data nodes based on the node master-slave switching attribute and the node operation change attribute of each data node, including:
[0027] Traverse N data nodes;
[0028] If there is a data node among the N data nodes whose node master-slave switching attribute is the first switching attribute, or whose node operation change attribute is the first operation change attribute, then the architecture change attribute of the N data nodes is determined as the first architecture change attribute; the first architecture change attribute is used to indicate that an architecture change has occurred on the N data nodes;
[0029] If the node master-slave switching attributes of the data nodes among the N data nodes are all the second switching attributes, and the node operation change attributes are all the second operation change attributes, then the architecture change attributes of the N data nodes are determined to be the second architecture change attributes; the second architecture change attributes are used to indicate that there is no architecture change for the N data nodes.
[0030] In one embodiment, the architecture change of the N data nodes refers to a master-slave attribute switch occurring among the N data nodes.
[0031] The specific implementation method of the connection update module to update the node connection of the application node to the database includes:
[0032] Determine, among the N data nodes, a data node that has established a connection with the application node at the first data acquisition time, and determine the data node that has established a connection with the application node at the first data acquisition time as a connected node;
[0033] If the connected node is a data node among the N data nodes where a master-slave attribute switch occurs, the connection between the connected node and the application node is closed, and a first correct node is selected for the application node from the N data nodes based on the first architecture description data, and a connection is established between the application node and the first correct node; the node slave attribute of the first correct node at the first data acquisition moment is the same as the node slave attribute of the connected node at the second data acquisition moment.
[0034] In one embodiment, the architecture change existing in the N data nodes refers to a change in the running state of a data node among the N data nodes;
[0035] The specific implementation method of the connection update module to update the node connection of the application node to the database includes:
[0036] Determine, among the N data nodes, a data node that has established a connection with the application node at the first data acquisition time, and determine the data node that has established a connection with the application node at the first data acquisition time as a connected node;
[0037] If the connected node is a data node whose operating status changes among the N data nodes, the connection between the connected node and the application node is closed, and a second correct node is selected for the application node from the N data nodes based on the first architecture description data, and a connection is established between the application node and the second correct node; the node operating attributes of the second correct node at the first data acquisition moment are normal operating attributes.
[0038] In one embodiment, after the data acquisition module queries the first architecture description data having the maximum timestamp from the first gateway device in the gateway layer, the apparatus further includes:
[0039] A connection establishment module, configured to receive a connection establishment request for a database initiated by an application management object;
[0040] Determine the operation attributes of the application node on the database based on the connection establishment request; the operation attributes include read-write operation attributes and read-only operation attributes;
[0041] Determine, from the N data nodes, a target connection node for establishing a connection request according to the operation attribute and the first architecture description data;
[0042] Apply to the target connection node to establish a connection between the application node and the target connection node.
[0043] In one embodiment, the connection establishment module determines, according to the operation attribute and the first architecture description data, a specific implementation method of establishing a target connection node for the connection request from the N data nodes, including:
[0044] According to the first architecture description data, a master node set and a slave node set at a first data acquisition time are determined from N data nodes; any master node in the master node set refers to a data node whose node master-slave attribute is a master attribute at the first data acquisition time, and any slave node in the slave node set refers to a data node whose node master-slave attribute is a slave attribute at the first data acquisition time;
[0045] If the operation attribute is a read-write operation attribute, any master node is selected from the master node set as the target connection node for establishing the connection request;
[0046] If the operation attribute is a read-only operation attribute, any slave node is selected from the slave node set as the target connection node for establishing the connection request.
[0047] In one embodiment, after the connection establishment module applies to the target connection node for establishing a connection between the application node and the target connection node, the connection establishment module is further configured to determine that the connection between the application node and the target connection node has failed if no connection response information returned by the target connection node is received within a response waiting period, and to determine the target connection node as an incorrect connection node for the application node;
[0048] The connection establishment module is further configured to mark the first gateway device as abnormal and refuse to query the database for architecture description data from the first gateway device within a specified time period.
[0049] In one embodiment, after the data acquisition module queries the first architecture description data having the maximum timestamp from the first gateway device of the gateway layer when the first data acquisition time is reached, the apparatus further includes:
[0050] a data clearing module, configured to query the third architecture description data having the maximum timestamp from the third gateway device in the gateway layer at the first data acquisition time;
[0051] The data clearing module is further configured to obtain a first data update time corresponding to the first architecture description data and a second data update time corresponding to the second architecture description data; the first data update time and the second data update time both refer to the time when the architecture of the N data nodes changes once;
[0052] The data clearing module is further configured to determine a pseudo-active device from the first gateway device and the second gateway device based on the first data update time and the second data update time;
[0053] The data clearing module is also used to clear the corresponding architecture description data queried from the pseudo-active device.
[0054] In one embodiment, the data clearing module determines a specific implementation of a pseudo-active device from the first gateway device and the second gateway device based on the first data update time and the second data update time, including:
[0055] Comparing the first data update time with the second data update time, and determining the earliest time from the first data update time and the second data update time according to the comparison result;
[0056] Determine both the first gateway device and the second gateway device as candidate pseudo-active devices;
[0057] The candidate false active device corresponding to the earliest time is determined as the false active device.
[0058] In one aspect, an embodiment of the present application provides a computer device, including: a processor and a memory;
[0059] The memory stores a computer program, and when the computer program is executed by the processor, the processor executes the method in the embodiment of the present application.
[0060] On one hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. The computer program includes program instructions. When the program instructions are executed by a processor, the method in the embodiment of the present application is executed.
[0061] In one aspect of the present application, a computer program product is provided, comprising a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, causing the computer device to perform the method provided in one aspect of the embodiments of the present application.
[0062] In an embodiment of the present application, a database direct connection architecture is provided. In this architecture, the application layer can have a direct connection with the gateway layer and the database, and any gateway device in the gateway layer can monitor and record changes in the database's architecture description data. Changes in the architecture description data can be used to describe the architecture changes of N data nodes in the database. In this way, any application node in the application layer (the node corresponding to a certain application) can obtain the real-time architecture status of N data nodes in the database from the gateway device in real time through the direct connection relationship with the gateway layer. When the architecture of N data nodes changes, it can update its own node connection status in the database in real time to reconnect to the correct data node that is operating normally. It should be understood that the database direct connection architecture provided by the present application can use the gateway device to monitor the architectural changes of the data nodes in the database in real time, and when the data nodes have architectural changes, the application nodes can obtain the architectural changes of the data nodes in real time through the direct connection relationship between the application node and the gateway layer. In this way, the application node can promptly determine which data nodes are currently available to meet the application operation requirements, and change the node connection between itself and the data nodes based on the data nodes that currently meet the application operation requirements. It can effectively prevent the application node from erroneously connecting to the data nodes that do not currently meet the operation requirements and promptly connect to the data nodes that can currently meet the operation requirements. Moreover, in this process, since there is a direct connection relationship between the application node and the database, the application node and the database can directly interact with data, and the database can respond to the node connection related requests of the application node in a timely manner, thereby reducing the response delay of the database. It can be seen that through the solution provided by the present application, when the database architecture changes, it can promptly determine the available data nodes based on the database architecture changes and promptly change the node connection status, thereby reducing the response delay of the database while achieving high availability of the data nodes and improving the reliability of the data provided by the data nodes. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0064] Figure 1 This is a schematic diagram of the architecture of a solution system provided by an exemplary embodiment of the present application;
[0065] Figure 2 is a flowchart of a data processing method provided by an exemplary embodiment of the present application;
[0066] Figure 3 This is a schematic diagram of a data node performing node connection update based on master-slave switching provided by an embodiment of the present application;
[0067] Figure 4 This is a schematic diagram of updating node connections based on data nodes with changed operating states, provided by an embodiment of the present application;
[0068] Figure 5 This is a schematic diagram of a process for establishing a connection with a data node based on architecture description data provided by an embodiment of the present application;
[0069] Figure 6 is a structural diagram of a data processing device provided in an embodiment of the present application;
[0070] Figure 7 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0071] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0072] The embodiments of the present application involve database and other related technologies. For ease of understanding, the database and related technical terms and concepts will be briefly explained below.
[0073] 1. Database
[0074] A database is a warehouse that organizes, stores, and manages data according to a data structure. It is a collection of large amounts of data stored in a computer for a long period of time, organized, shareable, and uniformly managed. Data in a database is organized, described, and stored according to a specific data model, resulting in minimal redundancy, high data independence, and scalability, and can be shared by a variety of users.
[0075] 2. Data Node
[0076] Data nodes are nodes in a database that store data. Data in a database can be distributed across multiple nodes to improve read and write efficiency and reduce the pressure on a single node. Data nodes can include master nodes and slave nodes. Data in a master node can be replicated to one or more slave nodes. This allows the master node to handle all write operations and some read operations, while the slave nodes can handle only read operations.
[0077] 3. Structured Query Language (SQL)
[0078] Structured Query Language (SQL) is a standard computer language for accessing and processing databases. It provides statements for various tasks, including: querying data; inserting, updating, and deleting rows of data in a table; creating, replacing, changing, or deleting an object; controlling access to the database and its objects; and ensuring the consistency and integrity of the database.
[0079] In actual applications, a database includes one or more (usually two or more) data nodes (each data node can be understood as a computing device), and the data in the database can be distributed to each data node for storage. Among them, each data node can have a master-slave attribute, wherein the master-slave attribute can include a master attribute and a slave attribute. A data node with a master attribute can be understood as a master node, and a data node with a slave attribute can be understood as a slave node. The slave node can synchronize data from the master node. In this way, the master node can provide data writing and data reading functions to the outside world, and the slave node can provide data reading functions to the outside world. If a user wants to write certain application data of a certain application to the database, a connection request can be initiated to the database through the application node corresponding to the application to request a connection to a master node in the database. In this way, after connecting to this master node, the master node can receive the data that the user wants to write to the database and store it. Subsequently, the slave node can synchronize data from the master node and store it to the slave node. At this point, both the master node and the slave node can store data. If a user wants to query certain application data from the database, a connection request can be initiated to the database through the application node corresponding to the application to request a connection to a slave node in the database. In this way, after connecting to this slave node, the slave node can return the data that the user wants to query to the application node. In other words, the database can complete data writing through the master node and complete data reading through the slave node (of course, the master node can also take on part of the data reading task, that is, it can read data from the master node). Therefore, the division of labor between the master and slave nodes can improve the efficiency of data writing and data reading.
[0080] In traditional technology, users can connect to corresponding data nodes in the database based on different connection establishment requests sent by application nodes to the database. In this way, services (for example, data writing service and data reading service) can be provided to applications through different data nodes. However, data nodes in the database will change. Some data nodes may go offline or fail (such as failing to receive or synchronize data in time), there may be new data nodes online, and some data nodes may switch from master to slave attributes (that is, the data node may switch from master attribute to slave attribute, or from slave attribute to master attribute), etc. Once a data node changes, it can be understood that the database The architecture of the data nodes in the database has changed. Once the data node architecture changes, the data nodes connected to the application nodes may not be able to provide correct services to the application. For example, assume that the application node is connected to a master node. The application can write data to the database or read relevant data from the master node through the master node. If the master node switches between master and slave attributes, the master node will become a slave node after the switch and no longer have the data write function. At this time, although the application node still has a connection to the node, the application can no longer write data to the database through the node, that is, the node can no longer provide data write services. Therefore, when the data node architecture of the database changes, the data node currently connected to the application node may be the wrong node and unable to provide correct services to the application. Not only will the application obtain incorrect data from the wrong node, thereby reducing the reliability of the data provided by the database, but the data node in the database that can provide correct services will not be connected to the application node, resulting in poor availability of the normally operating data nodes in the database.
[0081] In order to effectively and reasonably utilize the data nodes in the database, achieve high availability of the database, and improve the reliability of the data provided by the database, the present application provides a real-time update solution for node connection strategies based on the database direct connection architecture. When the architecture of the data nodes in the database changes, the node connection status of the application to the database can be updated in a timely manner, so that the connection between the application node and the erroneous node can be closed, and a new connection with the correct data node can be established. In this way, an effective connection can be made to the available data nodes in the database, and the normal operating data nodes can provide correct services to the application. The data provided by the data nodes is also reliable and correct data.
[0082] Specifically, the node connection solution for the database provided in the embodiment of the present application can roughly include the following process: First, the present application proposes a database direct connection architecture, in which the application node of any application (which can refer to the background server corresponding to the application) can be directly connected to the database. In this way, the application node can directly send a connection request to the database, and the database can also respond quickly. Compared with the method of deploying additional intermediate components (such as load balancing components) between the application node and the database and forwarding the application node's connection request through the intermediate component, the method of directly connecting the application node to the database can greatly reduce the delay caused by forwarding the intermediate request, and can greatly improve the database's response speed to the connection request. At the same time, in this database direct connection architecture, a gateway layer is used to monitor the architectural changes of data nodes in the database in real time. The gateway layer may include one or more gateway devices, and each gateway device may be deployed with a monitoring component for the database. Through this monitoring component, the architectural description data of the database (used to describe the architecture of the data nodes in the database) can be monitored and obtained in real time. In this application, a direct connection relationship can be established between the application node and the gateway layer. Thus, the application node can quickly obtain the architectural description data of the database from any gateway device through the direct connection relationship with the gateway layer, and determine whether there are architectural changes to the data nodes in the database through the latest architectural description data of the database. Specifically, the application node can regularly (such as every 30 minutes, every hour, every 10 minutes, etc.) query the latest architectural description data stored in a gateway device of the gateway layer from the gateway device. The moment when the application node needs to obtain architectural description data from a gateway device can be referred to as a data acquisition moment in this application. For example, assuming that the application node needs to obtain architectural description data once every 30 minutes, then the 30th minute, the 60th minute, the 90th minute... can all be referred to as a data acquisition moment. Then, based on the currently acquired architecture description data and the architecture description data acquired at the previous data acquisition moment, the application node can determine whether the architecture of the data node in the database has changed. If it is determined that the architecture of the data node in the database has changed, the application node can update the node connection of the application node to the database. For example, if the data nodes to which the application node is already connected have switched between master and slave attributes, the application node can close the connection with these data nodes, determine the correct master node or slave node from the database, and resend the connection request to the correct master node or slave node to establish a new and correct connection with the correct master node or slave node.
[0083] It can be seen that through the solution provided by this application, when the database architecture changes, the available data nodes can be determined in a timely manner based on the database architecture changes, and the node connection status can be changed in a timely manner, thereby reducing the response delay of the database while achieving high availability of the data nodes and improving the reliability of the data provided by the data nodes.
[0084] The solution provided in the embodiments of the present application can be applied to any application scenario that requires a database to store business data, including but not limited to short video push scenarios, game scenarios, etc.
[0085] The short video push scenario can refer to a scenario where video data is continuously pushed to the user. The user can request to update the display of the next video data by performing an operation to pull video data (such as sliding the video display interface of the terminal device). In the short video push scenario, the user can continuously refresh and browse different video data by continuously pulling video data.
[0086] A game scene may refer to a scene in which a user plays an immersive game through a terminal device.
[0087] In summary, the solution provided in the embodiment of the present application can achieve high availability of the database and improve the reliability of the data provided by the data nodes, effectively improving business coverage to a certain extent (such as expanding applicable scenarios).
[0088] It should be noted that the several application scenarios given above are only examples and do not limit the application scenarios to which the solutions provided in the embodiments of the present application are applicable.
[0089] Furthermore, the solution provided by the embodiment of the present application can be executed by a computer device, which can refer to an application node corresponding to any application. The application node can be used to provide corresponding computing services for the application, and can specifically include a terminal or a server. The application node can also include a terminal and a server. To facilitate understanding of the solution provided by the embodiment of the present application, the following is combined with Figure 1 The system environment diagram shown in the figure introduces the application scenarios involved in the embodiments of the present application; wherein, Figure 1 This is a schematic diagram of the architecture of a solution system provided by an exemplary embodiment of the present application. Figure 1 As shown, the system includes an application layer, a gateway layer and a database, and the application layer includes one or more application nodes (for example, Figure 1 The application node 1001, application node 1002, ..., application node 100m shown in FIG); the gateway layer includes one or more gateway devices (for example, Figure 1The gateway device 101, gateway device 102, ..., gateway device 10n shown in FIG; the database includes one or more data nodes (for example, Figure 1 1, data node 10001, data node 10002, ..., data node 1000k). There is a direct connection between the application layer and the database, and a direct connection between the application layer and the gateway layer. Any application node can refer to a backend server corresponding to an application or a terminal device where the application is deployed. For ease of understanding, the following will describe a terminal device or server:
[0090] 1) The terminal device may include the terminal device used by the user. Depending on the application scenario and field to which the present solution is applied, the terminal providing the solution provided by the embodiment of the present application may be different. The terminal device may include, but is not limited to: a smartphone (such as a smartphone deploying the Android system, or a smartphone deploying the Internetworking Operating System (IOS)), a tablet computer, a portable personal computer, a mobile Internet device (MID), a vehicle-mounted device, a head-mounted device, a smart home, and an intelligent voice interaction device. The embodiment of the present application does not limit the type of terminal device, which is explained here.
[0091] For example, in the short video push scenario, the terminal device can be a smart phone; that is, in this implementation mode, the solution provided by the embodiment of the present application can be deployed on the smart phone; when the user uses the short video push application on the smart phone, the smart phone can establish a direct connection relationship with the database and a direct connection relationship with the gateway layer. In this way, the smart phone can determine the architecture of the data nodes in the database through the gateway device in the gateway layer, and determine the available data nodes based on the real-time architecture of the data nodes. Then, the smart phone can write the relevant business data generated by the user in the short video push application (such as historical video data watched, historical video data liked, historical video data collected, etc.) Into the database for storage, specifically, the smartphone can directly send a data write request about the above data to the database, and the database can respond to this request and connect the smartphone to a data node with a master attribute, so that the data node can be used to store these data later; of course, if the smartphone wants to read the relevant business data of a user in a short video push application from the database, then the smartphone can directly send a data read request about these data to the database, and the database can respond to this request and connect the smartphone to a data node with a slave attribute, so that the data node can be used to return the data requested to read or query by the smartphone to the smartphone. Accordingly, the smartphone can return the business data queried from the database to the user, and can also perform data recommendations and other processing to the user based on the queried business data. For example, in the smart car scenario, the application deployed with the solution provided by the embodiment of the present application is a car application; the type of the car application may include but is not limited to: music, video or games, etc.
[0092] Applications can be computer programs designed to perform one or more specific tasks. By categorizing applications according to different dimensions (such as their operating mode and functionality), we can identify the types of the same application across different dimensions. For example, based on their operating mode, applications may include, but are not limited to, clients installed on terminals, mini-programs (subprograms of clients) that can be used without downloading or installing, and World Wide Web (Web) applications opened via a browser. Another example is based on their functional type, applications may include, but are not limited to, instant messaging (IM) applications, content interaction applications, audio applications, or video applications. IM applications refer to internet-based applications for instant messaging and social interaction. They may include, but are not limited to, applications with communication functionality, map applications with interactive functionality, and gaming applications. Content interaction applications refer to applications that enable content interaction, such as sharing platforms, personal spaces, and news applications. Audio applications refer to internet-based applications that implement audio functionality. Audio applications may include, but are not limited to, music applications with music playback and editing capabilities, radio applications with radio playback capabilities, or live streaming applications with live streaming capabilities. Video applications refer to applications that can play images. Video applications may include but are not limited to: applications with short videos (video length is often short, such as a few seconds or minutes, etc.) (such as short video push applications), applications with long videos (such as videos with long playback time such as movies or TV series), etc.
[0093] Of course, the solution provided in the embodiments of the present application can be directly deployed on a device (such as a smartphone), a server (such as a backend server), or deployed outside of an application, as described above, or can be deployed in a device or application in the form of a plug-in. The embodiments of the present application do not limit the carrier of the deployment solution.
[0094] 2) The server can be a server corresponding to the terminal, which is used to interact with the terminal for data to provide computing and application service support for the terminal. Specifically, the server is a background server corresponding to the application deployed in the terminal, which is used to interact with the terminal to provide computing and application servers for the application. Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0095] The terminal and the server may be connected directly or indirectly via wired or wireless communication, which is not limited in this application. In addition, the embodiment of this application does not limit the number of terminals and servers.
[0096] The following combination Figure 1The system shown introduces the general process of the node connection solution for the database in the application scenario. Among them, the process is a process described by taking any application node of the application layer as an example. In the specific implementation, first, when the application node reaches a certain data acquisition moment (that is, the moment when the architecture description data of the database is obtained from a gateway device of the gateway layer, for the sake of ease of understanding, it can be referred to as the first data acquisition moment), it obtains the latest architecture description data stored by the first gateway device from any gateway device of the gateway layer (for the sake of ease of understanding, it can be referred to as the first gateway device) (for the sake of ease of distinction, it can be referred to as the first architecture description data). It should be understood that when each gateway device monitors and obtains the architecture description data of the database once, it can simultaneously record the update time of the architecture description data while recording and storing the architecture description data. In this way, each architecture description data in the gateway device will correspond to a timestamp. The larger the timestamp, the more it can indicate the corresponding architecture description. The newer the data is, based on this, each time the application node obtains architecture description data from the gateway device, it can obtain the architecture description data with the largest timestamp according to the timestamp; then, the application node can obtain the architecture description data (which can be called the second architecture description data) obtained from a certain gateway device (which can be called the second gateway device) at the last data acquisition moment (which can be called the second data acquisition moment); further, the application node can compare the architecture description data of the two previous and subsequent moments. If the first architecture description data is different from the second architecture description data, it can indicate that the architecture of the data node in the database has changed in the time period between the second data acquisition moment and the first data acquisition moment. At this time, the application node can update the node connection of the application node to the database to connect to the data node that is operating normally and can provide the corresponding service.
[0097] Based on the solution and system architecture described above, the following points need to be explained:
[0098] ① The above-mentioned embodiments of this application Figure 1 The system shown is for the purpose of more clearly illustrating the technical solutions of the embodiments of the present application, and does not constitute a limitation on the technical solutions provided by the embodiments of the present application. It is known to those skilled in the art that, with the evolution of system architecture and the emergence of new business scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems. For example, in an application scenario, the execution subject "application node" of the embodiments of the present application includes a terminal and a server, that is, the terminal and the server jointly execute the solution provided by the embodiments of the present application; it should be understood that in actual applications, the application node can also be a terminal or a server, that is, it supports the terminal or the server to execute the solution provided by the embodiments of the present application alone.
[0099] ② The collection and processing of relevant data in the embodiments of this application should be strictly in accordance with the requirements of relevant laws and regulations. The acquisition of personal information requires the knowledge or consent of the individual subject (or the legal basis for obtaining the information), and subsequent data use and processing shall be carried out within the scope of authorization of laws and regulations and the subject of personal information. For example, when the embodiments of this application are applied to specific products or technologies, such as obtaining user feature data, the user's permission or consent must be obtained, and the collection (such as the historical video data that the above-mentioned user has liked), use and processing (such as recommending video data to the user based on the historical video data that the user has liked) of relevant data must comply with the relevant laws, regulations and standards of the relevant region.
[0100] Based on the above-described solution, the embodiment of the present application proposes a more detailed data processing method, which will be described in detail below in conjunction with the accompanying drawings.
[0101] See Figure 2 , Figure 2 It is a flow chart of a data processing method provided by an exemplary embodiment of the present application, and the flow may refer to the flow of a node connection solution for a database provided by an embodiment of the present application. The data processing method can be executed by an application node in the aforementioned system, such as an application node being a terminal and / or a server; in actual applications, the application node can be any application node in the application layer in a database direct connection architecture, wherein the database direct connection architecture further includes a gateway layer and a database, and both the gateway layer and the database have a direct connection relationship with the application layer, and the gateway layer includes at least one gateway device, each gateway device being used to monitor and record changes in the database's architecture description data (the database's architecture description data is used to describe the architecture of N data nodes in the database, where N is a positive integer). On top of this database direct connection architecture, the data processing method may at least include the following steps S101-S104:
[0102] Step S101: When a first data acquisition time is reached, query first architecture description data having a maximum timestamp from a first gateway device of a gateway layer.
[0103] In the present application, the database may contain N (N is a positive integer, usually an integer greater than 1) data nodes, and the architecture description data may refer to data used to describe the architecture of the N data nodes in the database. The architecture of the data node may at least include the following contents: the master-slave attributes of each data node, the operating status of each data node, and whether each data node has been offline. Among them, since the offline of a data node means that the data node is not running, the present application can merge the offline of the data node into the operating status of the data node. The operating status of the data node can be used to determine whether the data node is running healthily. If the data node is running healthily, it indicates that the data node is not offline; and if the data node is running abnormally, it indicates that the data node may be offline. Then the architecture description data can correspondingly include the master-slave attributes and operating status of each data node in the database. It should be understood that the master-slave attribute can include master attributes and slave attributes. The master-slave attribute of a data node is mainly used to indicate the function that the data node is responsible for. For example, if a data node has a master attribute, it can indicate that the data node has both data writing and data reading functions. Applications can store data through the data node and read data from the data node. If a data node has a slave attribute, it can indicate that the data node only has a data reading function. Applications can read data from the data node but cannot write data to the data node. A data node with a master attribute can be called a master node, and a data node with a slave attribute can be called a slave node. The data stored in the slave node can be data synchronized from the master node. The operating status of a data node can include a healthy operating status and an abnormal operating status. The healthy operating status can be used to indicate that the data node is operating normally or healthily, while the abnormal operating status can be used to indicate that the data node is operating abnormally. Abnormal operation of a data node can include: excessive data node delay (that is, there is a delay in the slave node synchronizing data from the master node, which is inefficient, and the data stored in the slave node is less than the data stored in the master node), data node offline, etc.
[0104] It can be seen that the present application can determine the architecture of the data nodes in the database through the architecture description data of the database. In specific applications, the metadata of the database can be used to describe the architecture of the data nodes in the database, so the metadata of the database can be determined as the architecture description data.
[0105] In this application, in order to obtain the architecture of the data nodes in the database in a timely manner to determine whether the connection status of the application node to the data nodes in the database needs to be updated, a gateway layer can be used to monitor the architecture description data of the database. The gateway layer can include one or more gateway devices. For any gateway device in the gateway layer, the database can be monitored in real time to obtain the latest architecture description data of the database when the architecture of the data nodes in the database changes, and store it locally on the gateway device. In order to facilitate the distinction between the various architecture description data stored in the gateway device, the gateway device can store the acquisition time of the architecture description data when storing the architecture description data (this acquisition time can also be understood as the time when the architecture of the data node in the database changes or is updated, so it can also be called the update time). In other words, each architecture description data in the gateway device will correspond to a timestamp, which can be used to represent the time when the architecture of the data node in the database changes or is updated. The larger the timestamp, the newer the architecture description data (that is, the architecture of the data node indicated by this architecture description data is the architecture after the most recent change). The first architecture description data in this application may refer to the architecture description data with the maximum timestamp read by the application node from the first gateway device of the gateway layer at the first data acquisition moment. This architecture description data may indicate the latest architecture of the database monitored by the first gateway device (i.e., the architecture of the data node in the database at the first data acquisition moment). The first gateway device may refer to any gateway device in the gateway layer. When the application node reaches the first data acquisition moment, it may randomly select any gateway device from the gateway layer as the first gateway device, and then query the architecture description data with the maximum timestamp from the first gateway device. The first data acquisition moment may refer to any data acquisition moment. This application may set different moments as the moments when the architecture description data of the database needs to be queried from the gateway layer. These moments may all be referred to as data acquisition moments. For example, assuming that the application node needs to obtain the architecture description data of the database from the gateway layer every 30 seconds, then the 30th second, the 60th second, the 90th second... may all be understood as data acquisition moments.
[0106] Step S102 , obtaining second architecture description data with a maximum timestamp from a second gateway device in the gateway layer at a second data acquisition time; the second data acquisition time is a data acquisition time before the first data acquisition time.
[0107] In this application, the second data acquisition moment may refer to the previous data acquisition moment of the first data acquisition moment. For example, assuming that the application node needs to obtain the architecture description data of the database from the gateway layer every 30 seconds, if the first data acquisition moment is the 60th second, then the second data acquisition moment is the previous data acquisition moment of the 60th second (i.e., the 30th second). The second gateway device is the gateway device from which the application node queries the architecture description data at the second data acquisition moment. The second architecture description data may refer to the architecture description data with the maximum timestamp read by the application node from the second gateway device of the gateway layer at the second data acquisition moment. This architecture description data may indicate the latest architecture of the database monitored by the second gateway device (i.e., the architecture of the data node in the database at the second data acquisition moment).
[0108] It is worth noting that the above-mentioned second data acquisition moment only exists when the first data acquisition moment is not the first data acquisition moment. If the first data acquisition moment is the first data acquisition moment, then there will be no previous data acquisition moment for the first data acquisition moment. At this time, the normally operating master node and slave node can be directly determined from the database based on the acquired first architecture description data, and according to the specific operation request for the database initiated by the user (such as data read and write request, data write request or data read request), a connection establishment request for the corresponding master node or slave node in the database is generated, and this connection establishment request is sent to the corresponding master node or slave node in the database to establish the corresponding connection and provide the corresponding service through the connection by the corresponding data node (for example, the master node can provide data read and write services, and the slave node can provide data read services).
[0109] Step S103 : determining architecture change attributes of N data nodes according to the first architecture description data and the second architecture description data.
[0110] In the present application, the master-slave attributes of each data node recorded in the architecture description data may be referred to as node master-slave attributes, and the operating status of each data node may be referred to as node operating attributes. It can be seen that the node master-slave attributes include master attributes and slave attributes, while the node operating attributes include healthy (i.e. normal) operating attributes and abnormal operating attributes. After obtaining the first architecture description data and the second architecture description data, the node master-slave attributes and the node operating attributes of each data node in the first architecture description data and the second architecture description data may be compared. If the node master-slave attributes or the node operating attributes of any data node are switched, it can be reflected in the time period between the first data acquisition time and the second data acquisition time. When a data node changes, the database undergoes an architectural change. At this time, the architectural change attribute of the N data nodes in the database can be determined as the first architectural change attribute (i.e., the architectural change attribute, which can be used to indicate that the N data nodes have architectural changes). If it is determined through comparison that the database has not had any data node master-slave attribute or node operation attribute switch, it can be reflected that in the time period between the first data acquisition moment and the second data acquisition moment, the data nodes in the database have not changed, and the database has not undergone an architectural change during this period. At this time, the architectural change attribute of the N data nodes in the database can be determined as the second architectural change attribute (i.e., the architectural retention attribute, which can be used to indicate that the N data nodes have not undergone architectural changes).
[0111] In a specific implementation, the specific implementation process of determining the architecture change attributes of N data nodes based on the first architecture description data and the second architecture description data may at least include: first, based on the first architecture description data, the node master-slave attributes (the node master-slave attributes may include master attributes and slave attributes) and the node operation attributes (the node operation attributes may include healthy / normal operation attributes and abnormal operation attributes, and the node operation attributes may indicate whether the operation status of the data node is healthy / normal operation status or abnormal operation status, wherein the healthy / normal operation attributes may be used to indicate that the operation status of the data node is healthy / normal operation status (that is, the data node has not failed), and the abnormal operation attributes may be used to indicate that the data node has not failed. The running state of the node is an abnormal running state (that is, the data node fails); similarly, according to the second architecture description data, the node master-slave attributes and node running attributes of each data node in the database at the second data acquisition time can also be determined; then, according to the node master-slave attributes of each data node at the first data acquisition time and the second data acquisition time, the node master-slave switching attribute of each data node can be determined; the single-node master-slave switching attribute includes a first switching attribute (the first switching attribute can refer to a switching attribute) and a second switching attribute (the second switching attribute can refer to a master-slave maintenance attribute). It can be seen that the first switching attribute can be used to indicate that the data node has switched between master and slave attributes, and the second switching attribute can be used to indicate that the data node does not have switched between master and slave attributes.
[0112] The specific implementation process of determining the node master-slave switching attribute of each data node based on the node master-slave attributes of each data node at the first data acquisition moment and the second data acquisition moment may at least include: taking any data node as an example, any one of the N data nodes may be determined as the target data node (that is, it is referred to as the target data node); then, the node master-slave attributes of the target data node at the first data acquisition moment may be compared with the node master-slave attributes of the target data node at the second data acquisition moment; if the node master-slave attributes of the target data node at the first data acquisition moment are different from the node master-slave attributes of the target data node at the second data acquisition moment, then the node master-slave switching attribute of the target data node may be determined to be the first switching attribute; conversely, if the node master-slave attributes of the target data node at the first data acquisition moment are the same as the node master-slave attributes of the target data node at the second data acquisition moment, then the node master-slave switching attribute of the target data node may be determined to be the second switching attribute. For example, assuming that in the first architecture description data, the node master-slave attribute of the target data node recorded is the master attribute, and in the second architecture description data, the node master-slave attribute of the target data node recorded is the slave attribute, then the node master-slave attribute of the target data node at the first data acquisition moment is the master attribute, and the node master-slave attribute at the previous moment, that is, the second data acquisition moment, is the slave attribute. Then it can be seen that the target data node has undergone a master-slave attribute switch during the time period between the second data acquisition moment and the first data acquisition moment, and the target data node has switched from the slave attribute to the master attribute. The node master-slave switching attribute of the target data node can be determined as the switching attribute (that is, the first switching attribute). It is worth noting that for any data node, the above method can be used as the target data node, and then the node master-slave attributes of the two moments before and after can be compared to determine whether the node master-slave switching attribute of each data node at the two moments before and after is the first switching attribute or the second switching attribute.
[0113] Of course, after obtaining the node operation attributes of each data node at the first data acquisition time and the second data acquisition time, the node operation change attributes of each data node can also be determined based on the node operation attributes of each data node at the first data acquisition time and the second data acquisition time; the node operation change attributes include the first operation change attribute (that is, the operation change attribute) and the second operation change attribute (that is, the operation maintenance attribute). It can be seen that the first operation change attribute can be used to indicate that there is a change in the operation status of the data node, and the second operation change attribute can be used to indicate that there is no change in the operation status of the data node.
[0114] The specific implementation process of determining the node operation change attribute of each data node based on the node operation attributes of each data node at the first data acquisition moment and the second data acquisition moment may at least include: taking any data node as an example, any one of the N data nodes may be determined as the target data node (that is, it is referred to as the target data node); then, the node operation attribute of the target data node at the first data acquisition moment may be compared with the node operation attribute of the target data node at the second data acquisition moment; if the node operation attribute of the target data node at the first data acquisition moment is different from the node operation attribute of the target data node at the second data acquisition moment, then the node operation change attribute of the target data node may be determined to be the first operation change attribute; conversely, if the node operation attribute of the target data node at the first data acquisition moment is the same as the node operation attribute of the target data node at the second data acquisition moment, then the node operation change attribute of the target data node may be determined to be the second operation change attribute. For example, assuming that in the first architecture description data, the node operation attribute of the target data node recorded is a healthy operation attribute, and in the second architecture description data, the node operation attribute of the target data node recorded is an abnormal operation attribute, then the node operation attribute of the target data node at the first data acquisition moment is a healthy operation attribute, and the node operation attribute at the previous moment, that is, the second data acquisition moment, is an abnormal operation attribute. Then it can be seen that the target data node has a fault in the time period between the second data acquisition moment and the first data acquisition moment, causing its node operation attribute to become an abnormal operation attribute. The target data node switches from a healthy operation attribute to an abnormal operation attribute, and the node operation attribute of the target data node can be determined as an operation change attribute (that is, a first operation change attribute). It is worth noting that for any data node, the above method can be used to compare the node operation attributes to determine whether the node operation change attribute of each data node is the first operation change attribute or the second operation change attribute. It is worth noting that for any data node, the above method can be used as the target data node, and then the node operation attributes at two moments before and after can be compared to determine whether the node operation change attribute of each data node at two moments before and after is the first operation change attribute or the second operation change attribute.
[0115] Furthermore, after determining the node master-slave switching attribute and the node operation change attribute of each data node, the architecture change attribute of the N data nodes can be determined according to the node master-slave switching attribute and the node operation change attribute of each data node. The specific implementation process can at least include: the node master-slave switching attribute and the node operation change attribute of the N data nodes can be traversed; if there is a data node among the N data nodes whose node master-slave switching attribute is the first switching attribute, or the node operation change attribute is the first operation change attribute, then the architecture change attribute of the N data nodes can be determined as the first architecture change attribute (i.e., the architecture change attribute). It can be seen that the first architecture change attribute is used to indicate that there is an architecture change in the N data nodes. That is, once there is a data node that has a master-slave attribute switch (for example, from the master attribute to the slave attribute or from the slave attribute to the master attribute) or a change in the operating state (for example, from a healthy operating state to an abnormal operating state or from an abnormal operating state to a healthy operating state, where a data node is offline, its node operating state can be understood as is an abnormal operating state), then it can be considered that an architectural change has occurred to the data node in the database, and its architectural change attribute should be the first architectural change attribute; conversely, if the node master-slave switching attribute of each data node in the N data nodes is the second switching attribute, and the node operation change attribute is the second operation change attribute, then the architectural change attribute of the N data nodes can be determined as the second architectural change attribute (i.e., the architectural preservation attribute); the second architectural change attribute is used to indicate that there is no architectural change in the N data nodes, that is, if the node master-slave attribute and the node operation attribute of each data node remain unchanged, that is, no data node has undergone a master-slave attribute switch (for example, switching from the master attribute to the slave attribute or from the slave attribute to the master attribute) or a change in the operating state (for example, from a healthy operating state to an abnormal operating state or from an abnormal operating state to a healthy operating state, where if a data node is in an offline state, its node operation state can be understood as an abnormal operation state), then it can be considered that no architectural change has occurred to the data node in the database, and its architectural change attribute should be the second architectural change attribute.
[0116] Step S104: If the architecture change attributes of the N data nodes indicate that the N data nodes have architecture changes, then the node connection of the application node to the database is updated.
[0117] In this application, the architecture change attribute may include a first architecture change attribute and a second architecture change attribute, where the first architecture change attribute is used to indicate that an architecture change has occurred on N data nodes, and the second architecture change attribute is used to indicate that an architecture change has not occurred on the N data nodes. After determining the architecture change attributes of the N data nodes, if it is determined that the architecture change attributes of the N data nodes indicate that an architecture change has occurred on the N data nodes, then the node connection of the application node to the database can be updated (i.e., the current node connection strategy can be updated). In actual applications, the application node can perform corresponding updates on the node connection update status of the database based on the architectural changes that have occurred in the N data nodes. For example, if there is a data node among the N data nodes that switches its master-slave attribute, then the data node to which the application node is currently connected can be obtained first, and then some of the data nodes among the N data nodes that have switched their master-slave attributes can be obtained. Among the connected data nodes, it is determined whether there are data nodes that have switched their master-slave attributes. If so, the connection with these data nodes can be closed, and based on the first architectural description data, the data nodes that are operating normally and whose master-slave attributes meet the operational requirements can be determined from the database, and then connection requests are sent to these data nodes that meet the operational requirements to establish new connections. Specifically, when the architectural change existing in N data nodes refers to a master-slave attribute switch among the N data nodes, the specific implementation process for updating the node connection of the application node to the database may at least include: determining, among the N data nodes, a data node that has established a connection with the application node at the first data acquisition time (it can be considered that the application node will establish a connection with different data nodes in the database based on the second architectural description data obtained at the second data acquisition time, and each data node that has established a connection with the application node can be obtained at this time), and determining the data node that has established a connection with the application node at the first data acquisition time as a connected node; if the connected node is a data node among the N data nodes that has undergone a master-slave attribute switch, closing the connection between the connected node and the application node, selecting a first correct node for the application node from the N data nodes based on the first architectural description data, and establishing a connection between the application node and the first correct node; the node subordination attribute of the first correct node at the first data acquisition time is the same as the node subordination attribute of the connected node at the second data acquisition time, and the node operation status of the first correct node at the first data acquisition time should be a healthy operation state.It is worth noting that the number of connected nodes may not be just one, but may be multiple. For any connected node, it can be determined whether it is the data node among the N data nodes where the master-slave attribute switch occurs. If so, the connection between the connected node and the application node can be closed. Then, based on the node master-slave attributes before the connected node undergoes the master-slave attribute switch, the correct data node can be selected for the application node from the N data nodes (the node master-slave attributes of the data node at the first data acquisition moment are the node master-slave attributes before the connected node undergoes the master-slave attribute switch, and at the same time, the data node is running healthily at the first data acquisition moment), and the application node is connected to the correct data node (specifically, the application node can initiate a connection establishment request to this data node, and this data node can respond to the request to establish a connection).
[0118] To understand the process of updating node connections based on master-slave switching, please refer to Figure 3 , Figure 3 Schematic diagram of a data node performing node connection update based on master-slave switching provided by an embodiment of the present application. Figure 3As shown, it is assumed that application node 3001 already has connections with data nodes 10001, 10003, and 10006 in the database before obtaining the first architecture description data. After obtaining the first architecture description data, a comparison with the second architecture description data at the second data acquisition time shows that, in the database, data nodes 10001, 10003, and 10009 all experienced a master-slave attribute switch between the second and third data acquisition times. Specifically, data node 10001 switched from master to slave, data node 10003 switched from slave to master, and data node 10009 switched from master to slave. Through the above-mentioned determination of the data nodes where the master-slave attribute switching occurs, it can be known that, among the data nodes connected to the application node 3001, the data node 10001 and the data node 10003 are both data nodes where the master-slave attribute switching occurs. Then the application node 3001 can first close the connection with the data node 10001 and the connection with the data node 10003. Correspondingly, since the connection with the data node 10001 is closed, it is necessary to establish a connection with another data node so that the other data node can provide the corresponding service. Then the application node can search the database for the data node whose master-slave attribute of the current node is the master attribute and use it as the replacement node for the data node 10001 (for providing the service provided by the data node 10001 to the application before the master-slave attribute switching). For example, assuming that in the first architecture description data, the node master-slave attribute of the data node 10002 recorded is the master attribute, then data node 10002 can be used as the correct node to which the application node should connect, and application node 3001 can establish a new connection with data node 10002; similarly, since the connection with data node 10003 is closed, it is necessary to establish a connection with another data node so that the other data node can provide the corresponding service. In this case, application node 3001 can search the database for a data node whose master-slave attribute is a slave attribute for the current node and use it as a replacement node for data node 10003 (for providing the service provided by data node 10003 to the application before switching the master-slave attribute). For example, assuming that in the first architecture description data, the master-slave attribute of data node 10004 is recorded as a slave attribute, then data node 10004 can be used as the correct node to which the application node should connect, and application node 3001 can establish a new connection with data node 10004.
[0119] The above description is about the specific implementation process of updating the node connection of the application node to the database when the architectural change of N data nodes refers to the case where the master-slave attribute of a data node among the N data nodes is switched. In the specific implementation, the running status of the data node among the N data nodes may also change, and the application node can also update the node connection status based on the change in the running status of the data node. Specifically, when the architectural change existing in N data nodes refers to a change in the operating status of a data node among the N data nodes, the specific implementation process of updating the node connection of the application node to the database may at least include: first, the data node that has established a connection with the application node at the first data acquisition time can be determined among the N data nodes, and the data node that has established a connection with the application node at the first data acquisition time can be determined as a connected node; then, the connected node can be judged, and if the connected node is a data node whose operating status has changed among the N data nodes, the connection between the connected node and the application node can be closed, and a second correct node can be selected for the application node from the N data nodes based on the first architectural description data, and a connection between the application node and the second correct node can be established; the node operating attribute of the second correct node at the first data acquisition time is a normal operating attribute (that is, the second correct node is a data node that is operating normally and has not been offline at the first data acquisition time). It is worth noting that the node master-slave attributes of the second correct node at the first data acquisition moment should also be consistent with the node master-slave attributes of the connected node. In this way, the second correct node can replace the connected node and provide corresponding functional services for the application (for example, data reading and writing function or data reading function).
[0120] To understand how data nodes update node connections based on changes in operating status, see Figure 4 , Figure 4 This is a schematic diagram of a node connection update based on a data node with a changed running state provided by an embodiment of the present application. Figure 4As shown, it is assumed that application node 4001 already has connections with data nodes 10005, 10008, and 10006 in the database before obtaining the first architecture description data. After obtaining the first architecture description data, a comparison with the second architecture description data at the second data acquisition time shows that, in the database, data nodes 10001, 10003, and 10009 all experienced a master-slave attribute switch between the second and third data acquisition times; and data nodes 10002, 10003, and 10006 all experienced a change in operating state between the second and third data acquisition times. Among them, data node 10001 switches from the master attribute to the slave attribute, data node 10003 switches from the slave attribute to the master attribute, and data node 10009 switches from the master attribute to the slave attribute; data node 10002 switches from the abnormal operation attribute to the healthy operation attribute (that is, the operation status switches from the abnormal operation status to the normal operation status), data node 10003 switches from the healthy operation attribute to the abnormal operation attribute (that is, the operation status switches from the normal operation status to the abnormal operation status), and data node 10006 switches from the healthy operation attribute to the abnormal operation attribute (that is, the operation status switches from the normal operation status to the abnormal operation status). Through the above-mentioned determination of the data nodes where the master-slave attribute switching and the running state change occur, it can be known that among the data nodes connected to the application node 4001, the data node 10006 is the data node where the running state change occurs, and the running state of the data node 10006 is no longer normal, then the application node 4001 can first close the connection with the data node 10006. Correspondingly, since the connection with the data node 10006 is closed, it is necessary to establish a connection with another data node so that the other data node can provide the corresponding service. Then the application node 4001 can search the database for the master-slave attribute of the current node. The data node with the master-slave attribute is selected and used as a replacement node for the data node 10006 (used to provide the service that the data node 10006 provided to the application before switching the master-slave attribute). For example, assuming that in the first architecture description data, the current node master-slave attribute of the data node 10009 recorded is the master attribute (that is, the data node 10009 becomes the master attribute after the master-slave attribute switching), and the node operation status of the data node 10009 is still in a healthy operation status, then the data node 10009 can be used as the correct node that the application node 4001 should connect to, and the application node 4001 can establish a new connection with the data node 10009.
[0121] It should be understood that the embodiment of the present application uses a gateway layer to monitor the architecture of the database in real time, so that the gateway layer can obtain the architecture description data of the database in real time, thereby determining the architecture changes of the data nodes in the database in real time. On this basis, the present application directly connects the application node to the gateway layer, so that the application node can obtain the architecture changes of the data nodes in the database in real time through the connection relationship between the application node and the gateway layer. As a result, the application node can update its node connection status for the data node based on the architecture changes of the data node. In this way, when the architecture of the data node changes, it can reasonably connect and utilize the data node that is operating normally and has the correct master-slave attribute, thereby achieving high availability of the data node in the database and effectively ensuring the high reliability of the data provided by the connected data node. In addition, since there is a direct connection between the application node and the database, the request initiated by the application node to the database does not need to be forwarded through an intermediate component, and the database can also respond to it quickly, thereby improving the data interaction efficiency between the database and the application node. Among them, it is worth noting that since the database direct connection architecture provided by this application only needs to deploy the gateway layer, there is no need to deploy any other intermediate components between the application node and the database, which can greatly reduce the component deployment cost. Moreover, the gateway layer in this application is only used to monitor the architectural changes of the database. A gateway device can be deployed on the same physical machine as a data node. Compared with the traditional solution of deploying the gateway device and data separately on different physical machines, this application can also further reduce deployment costs and save resources from the deployment of gateway devices.
[0122] It is worth noting that when an application node updates its own node connection status, if the application node closes the connections with multiple different data nodes, the application node can use asynchronous thread sequential closing to close each connection one by one. Specifically, the application node can order the connections according to their establishment time, and the earlier the establishment time, the earlier the connection can be closed.
[0123] It is also worth noting that the application node in the present application can be deployed with a connection driver for the database (for example, Java DataBase Connectivity, JDBC), and the solution provided in the embodiment of the present application can be specifically executed by the connection driver. In a specific application, a user may initiate multiple data operation requests for the database simultaneously through multiple threads (a data operation request can be used to request to perform a certain type of operation on the database (for example, data write operation, data read operation, etc.), and a data operation request needs to connect to a corresponding data node in the database so that the data node provides the corresponding function. Based on this, JDBC can understand a data operation request as a connection establishment request for a data node with a node master-slave attribute). Then, there will be multiple connection establishment requests processed by JDBC. In the case that the application has not established a connection with the database, JDBC can use optimistic locking to determine one thread from multiple threads (one thread corresponds to one user's connection establishment request) to request to read the architecture description data from the gateway layer. The other threads can wait until the architecture description data is read, and then determine the correct data node based on the architecture description data and establish a connection with it.
[0124] It should be noted that the database direct connection architecture provided by the present application can not only achieve high availability of the database, but also achieve high availability of the gateway layer. Specifically, the present application can obtain two architecture description data from different gateway devices at the same time and compare them. Since the obtained architecture description data are all architecture description data with the largest timestamp stored in the gateway device, then through comparison, once it is found that the architecture description data obtained at the same data acquisition time are different, it can be considered that there is a gateway device that has failed to monitor the architecture changes of the database in time, and the gateway device has the possibility of being falsely active. Even if it can still provide connection services to the outside world, it can no longer provide the latest architecture description data. Specifically, taking the application node as an example, at the first data acquisition time, the application node queries the first architecture description data with the largest timestamp from the first gateway device of the gateway layer. After that, the application node can also first detect the first gateway device to determine whether it is a falsely active device. When it is determined that the first gateway device is not a falsely active device, the application node can execute subsequent steps (such as obtaining the second architecture description data and comparing the second architecture description data with the first architecture description to determine the architecture change attributes of N data nodes in the database). Specifically, the application node can query the third architecture description data with the maximum timestamp from the third gateway device of the gateway layer at the first data acquisition time; then, the first data update time corresponding to the first architecture description data and the second data update time corresponding to the second architecture description data can be obtained; wherein the first data update time and the second data update time both refer to the time when the architecture of N data nodes changes once; based on the first data update time and the second data update time, the pseudo-active device can be determined from the first gateway device and the second gateway device, and its specific implementation process can at least include: comparing the first data update time with the second data update time Compare, and determine the earliest time from the first data update time and the second data update time according to the comparison result; determine the first gateway device and the second gateway device as candidate pseudo-active devices; determine the candidate pseudo-active device corresponding to the earliest time as the pseudo-active device; further, the corresponding architecture description data queried from the pseudo-active device can be cleared, and the architecture description data of the gateway device corresponding to the latest time is retained. The architecture description data can be understood as the correct architecture description data at the first data acquisition moment. Subsequently, the architecture change attributes of the N data nodes can be determined based on the correct architecture description data and the second architecture description data.
[0125] Of course, it is possible that both the third gateway device and the first gateway device are pseudo-active devices. Therefore, in order to effectively use the gateway devices, the present application can compare the update time corresponding to the architecture description data obtained at the previous and next moments. If the update time of the architecture description data obtained at the next moment is still less than the update time of the architecture description data obtained at the previous moment, then it can be considered that the gateway device corresponding to the architecture description data obtained at the next moment is a pseudo-active device. For example, after obtaining the first architecture description data or determining the above-mentioned correct architecture description data, the update time corresponding to the first architecture description data or the correct architecture description data can also be compared with the update time corresponding to the second architecture description data. If the update time corresponding to the first architecture description data or the correct architecture description data is later than the update time corresponding to the second architecture description data, the subsequent steps of determining the architecture change attributes of N data nodes based on the first architecture description data or the correct architecture description data and the second architecture description data can be executed.
[0126] It should be understood that by detecting the gateway devices at the gateway layer, the gateway devices with false activity problems in the gateway layer can be identified in real time, so that the gateway devices that do not have false activity problems can be effectively used, and the high availability of the gateway devices can be effectively improved.
[0127] In an embodiment of the present application, a database direct connection architecture is provided, which can use a gateway device to monitor the architectural changes of data nodes in the database in real time. When there is an architectural change in the data node, the application node can obtain the architectural change of the data node in real time through the direct connection relationship between the application node and the gateway layer. In this way, the application node can promptly determine which data nodes are currently available and meet the application operation requirements, and change the node connection between itself and the data node based on the data node that currently meets the application operation requirements. This can effectively prevent the application node from erroneously connecting to the data node that does not currently meet the operation requirements and promptly connect to the data node that currently meets the operation requirements. Moreover, in this process, since there is a direct connection relationship between the application node and the database, the application node and the database can directly exchange data, and the database can respond to the node connection related requests of the application node in a timely manner, thereby reducing the response delay of the database. It can be seen that through the solution provided by the present application, when the database architecture changes, it can promptly determine the available data nodes based on the database architecture change and promptly change the node connection status, thereby reducing the response delay of the database while achieving high availability of the data node and improving the reliability of the data provided by the data node.
[0128] It should be understood that after obtaining the architecture description data at a certain data acquisition time, if before the data acquisition time arrives, the application node receives a connection establishment request for the database initiated by the user, then the application node can select the correct data node from the database based on the currently obtained architecture description data and send a connection establishment request to it. Specifically, taking the query of the first architecture description data with the maximum timestamp from the first gateway device of the gateway layer as an example, after obtaining the first architecture description data, the correct data node can be selected from the database based on the first architecture description data and a connection can be established with it. For ease of understanding, please refer to Figure 5 , Figure 5 This is a flow chart of establishing a connection between architecture description data and data nodes provided by an embodiment of the present application. Figure 2 This corresponds to the process after querying the first architecture description data with the maximum timestamp from the first gateway device of the gateway layer in the embodiment, such as Figure 5 As shown, the process may include at least the following steps S501 to S504:
[0129] Step S501: receiving a connection establishment request for a database initiated by an application management object.
[0130] Specifically, an application management object can refer to the management object of the application corresponding to the application node, specifically a user. A database connection request can be understood as a data operation request for the database. Data operation requests include data read / write requests, data read requests, and data write requests. Each data operation request is used to request data read / write in the database, and therefore requires establishing a connection with a data node so that the data node can provide the corresponding function (such as data read / write function, data read function) to the application. Therefore, a data operation request can be understood as a connection request.
[0131] Step S502: determining the operation attributes of the application node on the database based on the connection establishment request; the operation attributes include read-write operation attributes and read-only operation attributes.
[0132] Specifically, from the above, it can be seen that a connection establishment request can be used to request an operation on the database, such as: data read and write operations or data read-only operations. Then, based on the connection establishment request, the operation attributes of the application node on the database can be determined (including read and write operation attributes and read-only operation attributes. The read and write operation attributes can indicate that the application node will perform data read and write operations on the database, and the read-only operation attributes can indicate that the application node will perform data read-only operations on the database).
[0133] Step S503: determining a target connection node for establishing a connection request from the N data nodes according to the operation attribute and the first architecture description data.
[0134] In a specific implementation, the specific implementation process of determining a target connection node for establishing a connection request from N data nodes according to the operation attribute and the first architecture description data may at least include: determining a master node set and a slave node set at the first data acquisition moment from the N data nodes according to the first architecture description data; wherein any master node in the master node set refers to a data node whose node master-slave attribute is a master attribute at the first data acquisition moment (i.e., the data node whose node master-slave attribute is recorded as a master attribute in the first architecture description data), and any slave node in the slave node set refers to a data node whose node master-slave attribute is a slave attribute at the first data acquisition moment (i.e., the data node whose node master-slave attribute is recorded as a slave attribute in the first architecture description data); if the operation attribute is a read-write operation attribute, then any master node may be selected from the master node set as the target connection node for establishing a connection request, and the application node may write data to or read data from the database through the target connection node (i.e., perform a data read-write operation); and if the operation attribute is a read-only operation attribute, then any slave node may be selected from the slave node set as the target connection node for establishing a connection request, and the application node may read data from the database through the target connection node (i.e., perform a data read-only operation).
[0135] Step S504: Apply to the target connection node to establish a connection between the application node and the target connection node.
[0136] Specifically, after determining the correct target connection node corresponding to the connection establishment request, the application node can apply to establish a connection with the target connection node. The application node can apply to the target connection node to establish a connection between the application node and the target connection node, and the target connection node can respond to the application request issued by the application node. Under normal circumstances, if the target connection node is operating normally at this time and the master-slave attributes also meet the user's operation requirements, then the target connection node can quickly make a connection response. If after the application is issued, the connection response information returned by the target connection node is not received within the response waiting time period (this waiting time period can be set based on specific business needs, for example, it can be set to 5 minutes, 6 minutes, etc.), then it can be determined that the connection between the application node and the target connection node has failed. At this time, The target connection node may be determined as an incorrect connection node of the application node because it is considered that the target connection node may not be a normally operating node, or a node whose master-slave attributes do not meet user requirements; it should be understood that since the target connection node is determined based on the first architecture description data provided by the first gateway device, its node master-slave attributes should be correct, and the node operation status should also be a healthy operation status, and there should be no connection failure. Once a connection failure occurs, it can be considered that the first architecture description data provided by the first gateway device is not the latest architecture description data in the database, and the first gateway device may be abnormal. The first gateway device can be marked as abnormal, and the architecture description data of the database can be refused from the first gateway device within a specified time period (for example, 24 hours, one month, etc.).
[0137] It should be understood that after obtaining the architecture description data provided by a gateway device, the embodiment of the present application can determine the correct data node based on the architecture description data and apply to establish a connection with it. If a connection cannot be established with the determined data node, then it can be considered that there is an abnormality in the gateway device. In this way, the gateway devices in the gateway layer can be detected to achieve high availability of the gateway devices.
[0138] Further, see Figure 6 , Figure 6 This is a structural diagram of a data processing device provided in an embodiment of the present application. The data processing device may be a computer program (including program code) running on a computer device, for example, the data processing device is an application node software; the data processing device may be used to execute Figure 3 As shown in the method. Figure 6 As shown, the data processing device 1 may include: a data acquisition module 11 , an attribute determination module 12 and a connection update module 13 .
[0139] The data acquisition module 11 is configured to query the first architecture description data having the maximum timestamp from the first gateway device in the gateway layer when a first data acquisition time is reached;
[0140] The data acquisition module 11 is further configured to acquire the second architecture description data with the maximum timestamp retrieved from the second gateway device of the gateway layer at a second data acquisition time; the second data acquisition time is a data acquisition time preceding the first data acquisition time;
[0141] an attribute determination module 12, configured to determine architecture change attributes of N data nodes based on the first architecture description data and the second architecture description data;
[0142] The connection updating module 13 is configured to update the node connection of the application node to the database if the architecture change attributes of the N data nodes indicate that the N data nodes have architecture changes.
[0143] The specific implementation of the data acquisition module 11, the attribute determination module 12 and the connection update module 13 can be found in the above Figure 2 The description of steps S101 to S104 in the corresponding embodiment will not be repeated here.
[0144] In one embodiment, the attribute determination module 12 determines a specific implementation method of the architecture change attributes of the N data nodes based on the first architecture description data and the second architecture description data, including:
[0145] Determine, based on the first architecture description data, node master-slave attributes and node operation attributes of each data node in the database at the first data acquisition moment;
[0146] Determine, based on the second architecture description data, node master-slave attributes and node operation attributes of each data node in the database at the second data acquisition moment;
[0147] Determining a node master-slave switching attribute of each data node based on the node master-slave attribute of each data node at the first data acquisition time and the second data acquisition time; the single-node master-slave switching attribute includes a first switching attribute and a second switching attribute, the first switching attribute is used to indicate whether the data node has switched between master and slave attributes, and the second switching attribute is used to indicate whether the data node has not switched between master and slave attributes;
[0148] Determine, based on the node operation attributes of each data node at the first data acquisition time and the second data acquisition time, a node operation change attribute of each data node; the node operation change attribute includes a first operation change attribute and a second operation change attribute, the first operation change attribute is used to indicate that there is a change in the operation state of the data node, and the second operation change attribute is used to indicate that there is no change in the operation state of the data node;
[0149] According to the node master-slave switching attribute and the node operation change attribute of each data node, the architecture change attributes of N data nodes are determined.
[0150] In one embodiment, the attribute determination module 12 determines a specific implementation method of the node master-slave switching attribute of each data node based on the node master-slave attribute of each data node at the first data acquisition time and the second data acquisition time, including:
[0151] Determine any data node among the N data nodes as the target data node;
[0152] Comparing the node master-slave attribute of the target data node at the first data acquisition moment with the node master-slave attribute of the target data node at the second data acquisition moment;
[0153] If the node master-slave attribute of the target data node at the first data acquisition moment is different from the node master-slave attribute of the target data node at the second data acquisition moment, determining that the node master-slave switching attribute of the target data node is the first switching attribute;
[0154] If the node master-slave attribute of the target data node at the first data acquisition moment is the same as the node master-slave attribute of the target data node at the second data acquisition moment, the node master-slave switching attribute of the target data node is determined to be the second switching attribute.
[0155] In one embodiment, the attribute determination module 12 determines the specific implementation method of the architecture change attributes of N data nodes based on the node master-slave switching attribute and the node operation change attribute of each data node, including:
[0156] Traverse N data nodes;
[0157] If there is a data node among the N data nodes whose node master-slave switching attribute is the first switching attribute, or whose node operation change attribute is the first operation change attribute, then the architecture change attribute of the N data nodes is determined as the first architecture change attribute; the first architecture change attribute is used to indicate that an architecture change has occurred on the N data nodes;
[0158] If the node master-slave switching attributes of the data nodes among the N data nodes are all the second switching attributes, and the node operation change attributes are all the second operation change attributes, then the architecture change attributes of the N data nodes are determined to be the second architecture change attributes; the second architecture change attributes are used to indicate that there is no architecture change for the N data nodes.
[0159] In one embodiment, the architecture change of the N data nodes refers to a master-slave attribute switch occurring among the N data nodes.
[0160] The specific implementation of the connection update module 13 for updating the node connection of the application node to the database includes:
[0161] Determine, among the N data nodes, a data node that has established a connection with the application node at the first data acquisition time, and determine the data node that has established a connection with the application node at the first data acquisition time as a connected node;
[0162] If the connected node is a data node among the N data nodes where a master-slave attribute switch occurs, the connection between the connected node and the application node is closed, and a first correct node is selected for the application node from the N data nodes based on the first architecture description data, and a connection is established between the application node and the first correct node; the node slave attribute of the first correct node at the first data acquisition moment is the same as the node slave attribute of the connected node at the second data acquisition moment.
[0163] In one embodiment, the architecture change existing in the N data nodes refers to a change in the running state of a data node among the N data nodes;
[0164] The specific implementation of the connection update module 13 for updating the node connection of the application node to the database includes:
[0165] Determine, among the N data nodes, a data node that has established a connection with the application node at the first data acquisition time, and determine the data node that has established a connection with the application node at the first data acquisition time as a connected node;
[0166] If the connected node is a data node whose operating status changes among the N data nodes, the connection between the connected node and the application node is closed, and a second correct node is selected for the application node from the N data nodes based on the first architecture description data, and a connection is established between the application node and the second correct node; the node operating attributes of the second correct node at the first data acquisition moment are normal operating attributes.
[0167] In one embodiment, after the data acquisition module 11 queries the first architecture description data with the maximum timestamp from the first gateway device of the gateway layer, the data processing apparatus 1 further includes: a connection establishment module 14 .
[0168] The connection establishment module 14 is used to receive a connection establishment request for a database initiated by an application management object;
[0169] The connection establishment module 14 is further configured to determine the operation attributes of the application node on the database based on the connection establishment request; the operation attributes include read-write operation attributes and read-only operation attributes;
[0170] The connection establishment module 14 is further configured to determine a target connection node for establishing a connection request from the N data nodes according to the operation attribute and the first architecture description data;
[0171] The connection establishing module 14 is further configured to apply to the target connection node for establishing a connection between the application node and the target connection node.
[0172] The specific implementation of the connection establishment module 14 can be found in the above Figure 5 The description of steps 501 to S504 in the corresponding embodiment will not be repeated here.
[0173] In one embodiment, the connection establishment module 14 determines a specific implementation method for establishing a target connection node for the connection request from the N data nodes according to the operation attribute and the first architecture description data, including:
[0174] According to the first architecture description data, a master node set and a slave node set at a first data acquisition time are determined from N data nodes; any master node in the master node set refers to a data node whose node master-slave attribute is a master attribute at the first data acquisition time, and any slave node in the slave node set refers to a data node whose node master-slave attribute is a slave attribute at the first data acquisition time;
[0175] If the operation attribute is a read-write operation attribute, any master node is selected from the master node set as the target connection node for establishing the connection request;
[0176] If the operation attribute is a read-only operation attribute, any slave node is selected from the slave node set as the target connection node for establishing the connection request.
[0177] In one embodiment, after the connection establishment module 14 applies to the target connection node for establishing a connection between the application node and the target connection node, the connection establishment module is further configured to determine that the connection between the application node and the target connection node has failed if no connection response information returned by the target connection node is received within a response waiting period, and to determine the target connection node as an incorrect connection node of the application node;
[0178] The connection establishing module 14 is further configured to mark the first gateway device as abnormal and refuse to query the database for architecture description data from the first gateway device within a specified time period.
[0179] In one embodiment, after the data acquisition module 11 queries the first architecture description data with the maximum timestamp from the first gateway device of the gateway layer when the first data acquisition time is reached, the data processing device 1 further includes: a data clearing module 15 .
[0180] The data clearing module 15 is configured to query the third architecture description data having the maximum timestamp from the third gateway device in the gateway layer at the first data acquisition time;
[0181] The data clearing module 15 is further configured to obtain a first data update time corresponding to the first architecture description data and a second data update time corresponding to the second architecture description data; the first data update time and the second data update time both refer to the time when the architecture of the N data nodes changes once;
[0182] The data clearing module 15 is further configured to determine a pseudo-active device from the first gateway device and the second gateway device based on the first data update time and the second data update time;
[0183] The data clearing module 15 is further configured to clear the corresponding architecture description data retrieved from the pseudo-active device.
[0184] In one embodiment, the data clearing module determines a specific implementation of a pseudo-active device from the first gateway device and the second gateway device based on the first data update time and the second data update time, including:
[0185] Comparing the first data update time with the second data update time, and determining the earliest time from the first data update time and the second data update time according to the comparison result;
[0186] Determine both the first gateway device and the second gateway device as candidate pseudo-active devices;
[0187] The candidate false active device corresponding to the earliest time is determined as the false active device.
[0188] The specific implementation of the data clearing module 15 can be found in the above Figure 2 The relevant description of step S104 in the corresponding embodiment will not be repeated here.
[0189] In an embodiment of the present application, a database direct connection architecture is provided, which can use a gateway device to monitor the architectural changes of data nodes in the database in real time. When there is an architectural change in the data node, the application node can obtain the architectural change of the data node in real time through the direct connection relationship between the application node and the gateway layer. In this way, the application node can promptly determine which data nodes are currently available and meet the application operation requirements, and change the node connection between itself and the data node based on the data node that currently meets the application operation requirements. This can effectively prevent the application node from erroneously connecting to the data node that does not currently meet the operation requirements and promptly connect to the data node that currently meets the operation requirements. Moreover, in this process, since there is a direct connection relationship between the application node and the database, the application node and the database can directly exchange data, and the database can respond to the node connection related requests of the application node in a timely manner, thereby reducing the response delay of the database. It can be seen that through the solution provided by the present application, when the database architecture changes, it can promptly determine the available data nodes based on the database architecture change and promptly change the node connection status, thereby reducing the response delay of the database while achieving high availability of the data node and improving the reliability of the data provided by the data node.
[0190] Further, see Figure 7 , Figure 7 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. Figure 7 As shown, the above-mentioned computer device 8000 may include: a processor 8001, a network interface 8004 and a memory 8005. In addition, the above-mentioned computer device 8000 also includes: a user interface 8003, and at least one communication bus 8002. The communication bus 8002 is used to realize the connection and communication between these components. The user interface 8003 may include a display screen (Display), a keyboard (Keyboard), and the user interface 8003 may optionally include a standard wired interface and a wireless interface. The network interface 8004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 8005 may be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk memory. The memory 8005 may optionally also be at least one storage device located away from the aforementioned processor 8001. As Figure 7 As shown, the memory 8005 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a device control application node program.
[0191] exist Figure 7In the computer device 8000 shown, the network interface 8004 can provide network communication functions; the user interface 8003 is mainly used to provide an interface for user input; and the processor 8001 can be used to call the device control application node program stored in the memory 8005 to achieve:
[0192] When the first data acquisition time is reached, querying the first architecture description data having the maximum timestamp from the first gateway device in the gateway layer;
[0193] Acquiring second architecture description data with a maximum timestamp from a second gateway device in the gateway layer at a second data acquisition time; the second data acquisition time is a data acquisition time before the first data acquisition time;
[0194] Determining architecture change attributes of N data nodes based on the first architecture description data and the second architecture description data;
[0195] If the architecture change attributes of the N data nodes indicate that the N data nodes have architecture changes, the node connection of the application node to the database is updated.
[0196] It should be understood that the computer device 8000 described in the embodiment of the present application can execute the above Figures 2 to 5 The description of the data processing method in the corresponding embodiment can also be performed as described above. Figure 6 The description of the data processing device 1 in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated here either.
[0197] In addition, it should be noted that: the embodiment of the present application also provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program executed by the computer device 8000 for data processing mentioned above, and the computer program includes program instructions. When the processor executes the program instructions, the computer program can execute the above-mentioned data processing. Figures 2 to 5 The description of the above-mentioned data processing method in the corresponding embodiment will therefore not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated. For technical details not disclosed in the computer-readable storage medium embodiment involved in this application, please refer to the description of the method embodiment of this application.
[0198] The computer-readable storage medium may be the data processing device provided in any of the aforementioned embodiments or the internal storage unit of the computer device, such as the hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device. Furthermore, the computer-readable storage medium may also include both the internal storage unit of the computer device and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
[0199] In one aspect of the present application, a computer program product is provided, comprising a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, causing the computer device to perform the method provided in one aspect of the embodiments of the present application.
[0200] The terms "first", "second", etc. in the description, claims, and drawings of the embodiments of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "comprising" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product, or device comprising a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules not listed, or may optionally include other step units inherent to these processes, methods, apparatuses, products, or devices.
[0201] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0202] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the composition and steps of each example according to function. Whether these functions are performed in hardware or software depends on the specific application nodes and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application node, but such implementation should not be considered to be beyond the scope of this application.
[0203] The methods and related devices provided by the embodiments of the present application are described with reference to the method flow charts and / or structural diagrams provided by the embodiments of the present application. Specifically, each process and / or block in the method flow charts and / or structural diagrams, as well as the combination of processes and / or blocks in the flow charts 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, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 Schematic diagram of one or more processes and / or structures Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including the instruction device, which implements the function specified in the process. Figure 1 Schematic diagram of one or more processes and / or structures Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the process. Figure 1 The flow or flows and / or structures illustrate the steps of the functions specified in one block or multiple blocks.
[0204] The above disclosure is only a preferred embodiment of the present application, and certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A data processing method, characterized in that: The method is applied to a database direct connection architecture; The database direct connection architecture includes: the application layer, the gateway layer, and the database; the gateway layer and the database are both directly connected to the application layer; the gateway layer includes at least one gateway device, each of which is used to monitor and record changes in the database's architecture description data; the database's architecture description data is used to describe the architecture of N data nodes in the database; N is a positive integer; the method is executed by any application node of the application layer, and the method includes: When a first data acquisition time is reached, querying the first architecture description data having the maximum timestamp from the first gateway device of the gateway layer; Acquiring second architecture description data with a maximum timestamp from a second gateway device of the gateway layer at a second data acquisition time; the second data acquisition time is a data acquisition time before the first data acquisition time; Determining architecture change attributes of the N data nodes according to the first architecture description data and the second architecture description data; If the architecture change attributes of the N data nodes indicate that there is an architecture change in the N data nodes, then the node connection of the application node to the database is updated.
2. The method according to claim 1, characterized in that The determining, according to the first architecture description data and the second architecture description data, architecture change attributes of the N data nodes includes: Determining, based on the first architecture description data, node master-slave attributes and node operation attributes of each data node in the database at the first data acquisition moment; Determining, based on the second architecture description data, node master-slave attributes and node operation attributes of each data node in the database at the second data acquisition moment; Determining a node master-slave switching attribute of each data node according to the node master-slave attribute of each data node at the first data acquisition time and the second data acquisition time, wherein the node master-slave switching attribute includes a first switching attribute and a second switching attribute, the first switching attribute being used to indicate that a master-slave attribute switching of the data node exists, and the second switching attribute being used to indicate that a master-slave attribute switching of the data node does not exist; Determining a node operation change attribute of each data node according to the node operation attributes of each data node at the first data acquisition time and the second data acquisition time, respectively; the node operation change attribute includes a first operation change attribute and a second operation change attribute, the first operation change attribute is used to indicate that there is a change in the operation state of the data node, and the second operation change attribute is used to indicate that there is no change in the operation state of the data node; The architecture change attributes of the N data nodes are determined according to the node master-slave switching attribute and the node operation change attribute of each of the data nodes.
3. The method according to claim 2, characterized in that The determining the node master-slave switching attribute of each data node according to the node master-slave attribute of each data node at the first data acquisition time and the second data acquisition time includes: Determine any one of the N data nodes as a target data node; Comparing the node master-slave attribute of the target data node at the first data acquisition moment with the node master-slave attribute of the target data node at the second data acquisition moment; If the node master-slave attribute of the target data node at the first data acquisition time is different from the node master-slave attribute of the target data node at the second data acquisition time, determining that the node master-slave switching attribute of the target data node is the first switching attribute; If the node master-slave attribute of the target data node at the first data acquisition moment is the same as the node master-slave attribute of the target data node at the second data acquisition moment, the node master-slave switching attribute of the target data node is determined to be the second switching attribute.
4. The method according to claim 2, characterized in that Determining the architecture change attributes of the N data nodes according to the node master-slave switching attribute and the node operation change attribute of each data node includes: Traversing the N data nodes; If there is a data node among the N data nodes whose node master-slave switching attribute is the first switching attribute, or whose node operation change attribute is the first operation change attribute, then determining the architecture change attribute of the N data nodes as the first architecture change attribute; the first architecture change attribute is used to indicate that an architecture change has occurred on the N data nodes; If the node master-slave switching attributes of the data nodes among the N data nodes are all the second switching attributes, and the node operation change attributes are all the second operation change attributes, then the architecture change attributes of the N data nodes are determined to be the second architecture change attributes; the second architecture change attributes are used to indicate that there is no architecture change for the N data nodes.
5. The method according to claim 1, wherein The architectural change of the N data nodes refers to a master-slave attribute switch occurring among the N data nodes; The updating of the node connection of the application node to the database includes: Determining, among the N data nodes, a data node that has established a connection with the application node at the first data acquisition time, and determining the data node that has established a connection with the application node at the first data acquisition time as a connected node; If the connected node is a data node among the N data nodes where a master-slave attribute switch occurs, the connection between the connected node and the application node is closed, and a first correct node is selected for the application node from the N data nodes based on the first architecture description data, and a connection is established between the application node and the first correct node; the node slave attribute of the first correct node at the first data acquisition moment is the same as the node slave attribute of the connected node at the second data acquisition moment.
6. The method according to claim 1, characterized in that The architectural change of the N data nodes refers to a change in the operating state of a data node among the N data nodes; The updating of the node connection of the application node to the database includes: Determining, among the N data nodes, a data node that has established a connection with the application node at the first data acquisition time, and determining the data node that has established a connection with the application node at the first data acquisition time as a connected node; If the connected node is a data node whose operating status changes among the N data nodes, the connection between the connected node and the application node is closed, and a second correct node is selected for the application node from the N data nodes based on the first architecture description data, and a connection is established between the application node and the second correct node; the node operating attribute of the second correct node at the time of obtaining the first data is a normal operating attribute.
7. The method according to claim 1, characterized in that After querying the first architecture description data having the maximum timestamp from the first gateway device of the gateway layer, the method further includes: receiving a connection establishment request for the database initiated by the application management object; Determining, based on the connection establishment request, an operation attribute of the application node on the database; the operation attribute includes a read-write operation attribute and a read-only operation attribute; Determining a target connection node for the connection establishment request from the N data nodes according to the operation attribute and the first architecture description data; Apply to the target connection node to establish a connection between the application node and the target connection node.
8. The method according to claim 7, characterized in that The determining, from the N data nodes, a target connection node for the connection establishment request according to the operation attribute and the first architecture description data includes: Determining, from the N data nodes, a master node set and a slave node set at the first data acquisition moment according to the first architecture description data; any master node in the master node set refers to a data node whose node master-slave attribute is a master attribute at the first data acquisition moment, and any slave node in the slave node set refers to a data node whose node master-slave attribute is a slave attribute at the first data acquisition moment; If the operation attribute is a read-write operation attribute, selecting any master node from the master node set as the target connection node for the connection establishment request; If the operation attribute is a read-only operation attribute, any slave node is selected from the slave node set as the target connection node for the connection establishment request.
9. The method according to claim 7, characterized in that After applying to the target connection node for establishing a connection between the application node and the target connection node, the method further includes: If no connection response information returned by the target connection node is received within the response waiting period, it is determined that the connection between the application node and the target connection node has failed, and the target connection node is determined as an erroneous connection node of the application node; The first gateway device is marked as abnormal, and querying the architecture description data of the database from the first gateway device is refused within a specified time period.
10. The method according to claim 1, characterized in that When the first data acquisition time is reached, after querying the first architecture description data having the maximum timestamp from the first gateway device of the gateway layer, the method further includes: querying third architecture description data having a maximum timestamp from a third gateway device in the gateway layer at the first data acquisition time; Obtaining a first data update time corresponding to the first architecture description data and a second data update time corresponding to the second architecture description data; the first data update time and the second data update time both refer to the time when the architecture of the N data nodes changes once; Determining a pseudo-active device from the first gateway device and the second gateway device based on the first data update time and the second data update time; The corresponding architecture description data retrieved from the pseudo-active device is cleared.
11. The method according to claim 10, characterized in that The determining the pseudo-active device from the first gateway device and the second gateway device based on the first data update time and the second data update time includes: Comparing the first data update time with the second data update time, and determining the earliest time from the first data update time and the second data update time according to the comparison result; Determine both the first gateway device and the second gateway device as candidate pseudo-active devices; The candidate pseudo-active device corresponding to the earliest time is determined as the pseudo-active device.
12. A data processing device, characterized by: The device is applied to a database direct connection architecture, which includes: the application layer, the gateway layer, and the database; the gateway layer and the database are both connected to the application layer; the gateway layer includes at least one gateway device, each of which is used to monitor and record changes in the database's architecture description data; the database's architecture description data is used to describe the architecture of N data nodes in the database; N is a positive integer; the device is specifically applied to any application node in the application layer, and includes: a data acquisition module, configured to query first architecture description data having a maximum timestamp from a first gateway device in the gateway layer when a first data acquisition time is reached; The data acquisition module is further configured to acquire second architecture description data having a maximum timestamp queried from a second gateway device of the gateway layer at a second data acquisition time; the second data acquisition time is a data acquisition time previous to the first data acquisition time; an attribute determination module, configured to determine architecture change attributes of the N data nodes based on the first architecture description data and the second architecture description data; A connection update module is configured to update a node connection of the application node to the database if the architecture change attributes of the N data nodes indicate that an architecture change exists in the N data nodes.
13. A computer device, characterized in that: include: processor, memory, and network interface; The processor is connected to the memory and the network interface, wherein the network interface is used to provide a network communication function, the memory is used to store a computer program, and the processor is used to call the computer program so that the computer device executes the method according to any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the method according to any one of claims 1 to 11.
15. A computer program product, characterized in that The computer program product comprises a computer program stored in a computer-readable storage medium. The computer program is suitable for being read and executed by a processor, so as to enable a computer device having the processor to perform the method according to any one of claims 1 to 11.