Example 1
There is also provided, in accordance with an embodiment of the present invention, an embodiment of a data processing method, it should be noted that the steps illustrated in the flowchart of the accompanying drawings may be performed in a computer system such as a set of computer executable instructions, and that, although a logical order is illustrated in the flowchart, in some cases, the steps illustrated or described may be performed in an order different than that herein.
The data processing method provided by the first embodiment of the present application may be executed in a mobile terminal, a computer terminal, or a similar computing device. Fig. 1 shows a hardware configuration block diagram of a computer terminal (or mobile device) for implementing a data processing method. As shown in fig. 1, the computer terminal 10 (or mobile device 10) may include one or more (shown as 102a, 102b, … …, 102 n) processors 102 (the processors 102 may include, but are not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. Besides, the method can also comprise the following steps: a display, an input/output interface (i.e., an I/O interface), a Universal Serial Bus (USB) port (which may be included as one of the ports of the I/O interface), a network interface, a power source, and/or a camera. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration and is not intended to limit the structure of the electronic device. For example, the computer terminal 10 may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
It should be noted that the one or more processors 102 and/or other data processing circuitry described above may be referred to generally herein as "data processing circuitry". The data processing circuitry may be embodied in whole or in part in software, hardware, firmware, or any combination thereof. Further, the data processing circuit may be a single stand-alone processing module, or incorporated in whole or in part into any of the other elements in the computer terminal 10 (or mobile device). As referred to in the embodiments of the application, the data processing circuit acts as a processor control (e.g. selection of a variable resistance termination path connected to the interface).
The memory 104 may be used to store software programs and modules of application software, such as program instructions/data storage devices corresponding to the data processing method in the embodiment of the present invention, and the processor 102 executes various functional applications and data processing by executing the software programs and modules stored in the memory 104, that is, implementing the data processing method described above. The memory 104 may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 106 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network adapter (NIC) that can be connected to other Network devices through a base station to communicate with the internet. In one example, the transmission device 106 can be a Radio Frequency (RF) module, which is used to communicate with the internet in a wireless manner.
The display may be, for example, a touch screen type Liquid Crystal Display (LCD) that may enable a user to interact with a user interface of the computer terminal 10 (or mobile device).
Fig. 1 shows a block diagram of a hardware structure, which may be taken as an exemplary block diagram of the computer terminal 10 (or the mobile device) and also taken as an exemplary block diagram of the server, and in an alternative embodiment, fig. 2 shows a schematic diagram of a data processing method network terminal, and as shown in fig. 2, the computer terminal 10 (or the mobile device) may be connected or electronically connected to one or more servers (e.g., a security server, a resource server, a game server, etc.) via a data network. In an alternative embodiment, the computer terminal 10 (or mobile device) may be any mobile computing device or the like. The data network connection may be a local area network connection, a wide area network connection, an internet connection, or other type of data network connection. The computer terminal 10 (or mobile device) may execute to connect to a network service executed by a server (e.g., a secure server) or a group of servers. A web server is a network-based user service such as social networking, cloud resources, email, online payment, or other online applications.
Under the above operating environment, the present application provides a data processing method as shown in fig. 3. Fig. 3 is a flowchart of a data processing method according to a first embodiment of the present invention. As shown in fig. 3, the method includes:
step S302, a designated node in the distributed network receives an access request of a page;
step S304, the appointed node determines the sender of the access request;
and step S306, when the node corresponding to the sender is consistent with the designated node, the designated node forwards the access request to other nodes in the distributed network.
Through the steps, the appointed node in the distributed network can be adopted to receive the access request of the page, the appointed node determines the sender of the access request, and when the node corresponding to the sender is consistent with the appointed node, the appointed node is utilized to forward the access request to other nodes in the distributed network. In this embodiment, when there is an access request, it may be determined whether a request sender is consistent with a designated node, if so, the access request may be forwarded to other nodes in the distributed network, and the state information of the page corresponding to the access request is cached by other nodes, thereby implementing multiple storage of data, avoiding that the page information is lost after downtime when the designated node is a management node, and caching the state information of the page by other nodes, so that the state information of the page of the access request may be retrieved by other nodes after downtime occurs on the designated node, and data processing is completed, so that the access delay occurring during downtime or the frequency of loss of the access request may be reduced, the time during data recovery in which data is inaccessible is greatly reduced, the availability of the system is improved, and further solving the problem that some nodes in the distributed system in the related art are down, the system cannot immediately open the data managed by the downtime node for the user to access, and the usability of the system is reduced.
The embodiment of the application can be applied to a distributed system, especially a distributed shared database system, for example, a plurality of nodes in a distributed network are managed. According to the embodiment of the application, the distributed system or the distributed network is managed from the perspective of the designated node, and data processing of the down of the node is achieved. When a node goes down, other nodes are selected for data recovery, in the recovery process, all the page information modified by the down node can be immediately and completely recovered from all the nodes, at the moment, the modified pages can be locked, and the reading and writing of all the data can be recovered.
The present application will be described below with reference to the respective steps.
Step S302, a designated node in the distributed network receives an access request of a page.
In the embodiment of the present invention, the distributed network may be a network including a plurality of nodes, the network structure includes nodes distributed at different locations and having a plurality of terminals connected to each other, any node in the network is connected to at least two lines, and when any line fails, communication may be completed via another link.
In the embodiment of the invention, the network comprises a plurality of nodes for sharing cache data, and other nodes are managed through one or more designated nodes, wherein an information table is recorded in the designated nodes, and the information table comprises each managed node and cache data or cache data pages in each node. If a node (node 1) needs to access a data page, an access request needs to be sent to a designated node (node2) corresponding to the data page, the designated node (node2) checks an information table stored by itself, determines which node cache currently has the data page, sends the access request to the node (node 3), and the node (node 3) directly sends the data page to the initial node (namely, node 1).
In some embodiments of the present application, each node maintains state information and page data for the pages it manages.
The designated Node in the embodiment of the present invention may be defined as a modified Node and a management Node, and the number of other nodes managed by the designated Node is not limited in the embodiment of the present invention, for example, the defined Node2 manages other three nodes Node1, Node3, and Node 4.
When a page data request is specifically processed, a page access request is received through the designated node, and since a distributed network may include a plurality of designated nodes, each of which manages a plurality of nodes, when sending the access request, it needs to manage its own designated node to send the access request to obtain corresponding page data.
The access request of the page may include, but is not limited to: for content requests of web page videos, articles, voices, songs and the like, a distributed node may cache a plurality of page data.
In step S304, the designated node determines the sender of the access request.
After the designated node receives the access request of the page, it may first determine which node sends the access request, and in an alternative embodiment, the determining, by the designated node, the sender of the access request includes: the appointed node acquires the page identifier of the page from the access request; and the designated node determines a node identifier corresponding to the page based on the page identifier, and takes the node corresponding to the node identifier as a sender.
The page identifier of the page may include, but is not limited to: page links (e.g., URLs), identifying numbers and/or letters on the page, page rank numbers, etc. The node to which the access request belongs can be determined through the page identification, and then the sender of the access request is determined.
In another optional embodiment of the present invention, the determining, by the designated node, the node identifier corresponding to the page based on the page identifier includes: carrying out hash operation on the page identification by the designated node to obtain a hash value; and determining the node identification corresponding to the page based on the hash value.
Namely, in some embodiments of the present invention, hash operation may be performed on the page identifier, and the node identifier to which the page identifier belongs may be determined by the hash value. For example, if the page identifier is the page number of the page, hash operation is performed on the page number, and the node identifier corresponding to the page is determined according to the hash value. Certainly, since the access request for sending the page may be the designated Node, or may be other nodes managed by the designated Node, Node identifiers of different nodes are different, if the access request for sending the page is the designated Node, for example, the designated Node2, the Node identifier may be determined according to a Hash value by making a Hash of the page number.
The node identification may include: node number, node code, etc., and the node identifier may be a designated node number or other node numbers. The designated node number corresponding to the access request of the page can be determined through the hash value.
In some embodiments of the present invention, if a node needs to access a data page, an access request needs to be sent to a designated node corresponding to the data page. In the first case, other nodes send access requests to the designated nodes, that is, other nodes need to acquire page data; and secondly, the designated node sends an access request to the designated node, namely the designated node also needs to acquire corresponding page data. For the first case, because other nodes send access requests to their designated nodes, when they send access requests, they will record the content of the access requests themselves, and record the content of the access requests through the designated nodes or other nodes, and at the same time, the nodes visited by the pages of each access request will record the state information of the pages, so that even if the designated nodes are down or otherwise have faults, the page states and the contents of the accessed pages of the pages corresponding to the access requests can be acquired and recovered from other nodes. For the second case, because the node requesting access is the self, and is not cached by other nodes, the situation that the page data cannot be accessed may occur during downtime, and only after waiting for the Redo log of the downtime node to be scanned once, the set of the modified pages is acquired, and then the other page information sets acquired from other nodes, the union of the two sets is obtained, and after all the pages in the union are locked, the data originally managed by the downtime node can be accessed (the access to the locked pages is recovered and completed by the blocked specified pages).
And step S306, when the node corresponding to the sender is consistent with the designated node, the designated node forwards the access request to other nodes in the distributed network.
That is, in the embodiment of the present invention, after the designated node receives the access request from the sender, if it is determined that the sender is the designated node itself, the access request may be forwarded to other nodes in the distributed network, and then the page state of the page corresponding to the access request is cached by the other nodes, so as to perform notification (record) processing.
Optionally, in the embodiment of the present invention, if the designated node sends the access request to the other nodes, the other nodes may record state information of the page requested by the access request (record that the page is exclusively locked), so that when the designated node goes down, the page state of the page requested by the access request is acquired from the other nodes.
In another optional embodiment of the present invention, before the designated node forwards the access request to other nodes in the distributed network, the method further includes: the designated node determines a target node number based on the node identification of the designated node and the number of nodes in the distributed network; and taking the node corresponding to the target node number as the other node.
When other nodes are selected, the node identification of the designated node and the number of nodes in the distributed network need to be referred to, wherein the position of the designated node can be determined through the node identification of the designated node, and the nodes around the designated node can be inquired, the surrounding nodes can be preferably selected to serve as the other nodes, and the fact that several other nodes are required to cache the access request can be determined through the number of nodes in the distributed network. For example, the node number of the designated node is determined, and then the access request is forwarded to the ((designated node number + 1)% total node number) th node.
After receiving the access request, the other nodes may record the state information of the page requested by the access request. In an optional embodiment of the present invention, the method further includes: other nodes determine the type of the access request; when the type is the exclusive lock request, the state information of the page is recorded, and the state information is used for indicating that the page is in a locked state. That is, if the type of the access request is an exclusive lock request, it is necessary to record the state information of the page, and the state information indicates that the page is in a locked state.
When the page lock request sent to the master node of the page (i.e. the node managing the page) comes from the node (i.e. the requester is the master node), the request is sent to another node (i.e. the other node) for storage at the same time, so that two copies of the lock information of the page can be reserved. Thus, all pages have information held by at least two nodes: for example, when the master node of page 0 is node1, if node2 requests this page, then there will be information for the page at both node2 and node1 (who holds what lock the page has); if node1 requests page 0, node1 will forward the request message to another node (e.g., node3) so that node3 also has the locking information (avoiding only node1 having information, so that when any node hangs up, the locking information can always be re-established from the other nodes.
Optionally, after the designated node forwards the access request to other nodes in the distributed network, the method further includes: after the specified node is down, acquiring the state information of the page from other nodes; the designated node restores the page state of the page based on the state information of the page.
That is, when the designated node goes down, one of the remaining nodes (that is, the other nodes) may be selected to perform data recovery, in the recovery process, the state information of the page may be acquired from the other nodes, and then the designated node recovers the page state of the page based on the state information of the page, if the state information of the page indicates that the page is in a locked state, in this way, during the recovery, the page may be unlocked and the page data of the page may be continuously acquired.
In the embodiment of the invention, all the page information modified by the down node can be immediately and completely recovered from all the nodes. Similarly, the designated node may also recover the page state of the page through the page information according to the state information of the page acquired by the other node.
Another optional feature of the method further comprises: when the type is not an exclusive lock request and the node corresponding to the sender is consistent with the designated node, determining the node corresponding to the page; the appointed node sends an access request to a node corresponding to the page; and the designated node receives page data sent by the node corresponding to the page, wherein the page data is the page data corresponding to the page.
That is, if it is determined that the type of the access request is not the exclusive lock request, the page corresponding to the access request may be directly accessed, so that the designated node may send the access request to the node corresponding to the page, and then receive page data sent by the node corresponding to the page, where the page data is page data corresponding to the page. For example, the designated Node (Node2) determines which Node's cache currently holds the page, and sends a request to the Node (e.g., Node1), and the Node receives the request and directly sends the page to the first read requesting Node (e.g., Node 3).
Through the embodiment, data processing can be performed in the distributed network, in the processing process, if the access request for sending the page is the designated node (namely, the management node) itself, the access request can be sent to one other node, and the other node records the state information of the page corresponding to the access request (namely, records that the page is added with an exclusive lock), so that even if the designated node goes down, the state information of the page can be obtained through the other node, the page state of the page is recovered based on the state information of the page, and then the page data sent by the node corresponding to the page is received, so that the data inaccessible time in the data recovery process can be greatly reduced, and the availability of the system is improved.
The invention is illustrated below by means of a further alternative embodiment.
Fig. 4 is a first flowchart of another alternative data processing method according to an embodiment of the present invention, as shown in fig. 4, the method includes:
step S402, a designated node in the distributed network receives an access request of a page;
step S404, appointing a node to determine a sender of the access request;
step S406, when the node corresponding to the sender is consistent with the designated node, the designated node notifies other nodes in the distributed network of the current state of the page.
Through the steps, the appointed node in the distributed network is adopted to receive the access request of the page, the appointed node determines the sender of the access request, and when the node corresponding to the sender is consistent with the appointed node, the appointed node informs other nodes in the distributed network of the current state of the page. In this embodiment, in the distributed network, if the sender is the designated node itself, the current state of the page may be recorded by other nodes, so that even if the designated node goes down, the state information of the page may be retrieved by other nodes to complete data processing, thereby reducing the access delay or the frequency of losing access requests when the designated node goes down, greatly reducing the time during which data is inaccessible in the data recovery process, and improving the availability of the system.
Optionally, the notifying, by the designated node, the current state of the page to other nodes in the distributed network includes: the designated node sends an access request to other nodes, and the access request is used for determining the state of the page.
That is, a state access request can be sent by a designated node to determine the state of the page where the access request for sending the page is located, and optionally, the state can be an exclusive lock or a non-exclusive lock. The state can be determined directly by the access request, for example, when the type is an exclusive lock request, state information of the page is recorded, and the state information is used for indicating that the page is in a locked state; when the type is not an exclusive lock request and the node corresponding to the sender is consistent with the designated node, determining the node corresponding to the page; the appointed node sends an access request to a node corresponding to the page; and the designated node receives page data sent by the node corresponding to the page, wherein the page data is the page data corresponding to the page.
The invention is illustrated below by means of a further alternative embodiment.
Fig. 5 is a second flowchart of another alternative data processing method according to an embodiment of the present invention, as shown in fig. 5, the method includes:
step S502, a designated node in the distributed network receives an access request of a page;
step S504, the appointed node transmits the access request to other nodes in the distributed network;
step S506, other nodes determine the type of the access request;
in step S508, when the type is the exclusive lock request, the other nodes record the state information of the page, where the state information is used to indicate that the page is in the locked state.
Through the steps, the designated node in the distributed network receives the access request of the page, the designated node forwards the access request to other nodes in the distributed network, the other nodes determine the type of the access request, and when the type of the other nodes is the exclusive lock request, the other nodes record the state information of the page, wherein the state information is used for indicating that the page is in the locking state. In this embodiment, the access request may be forwarded to other nodes in the distributed network through the designated node, and the state information of the page of the access request is recorded by using other nodes, so as to implement multiple storage of data, avoid that the page information is lost after downtime when the designated node is a management node, retrieve the state information of the page sending the access request through other nodes, and complete data processing, thereby reducing access delay or access request loss frequency occurring during downtime, greatly reducing data inaccessibility time in the data recovery process, improving system availability, and further solving the technical problems that in the related art, due to downtime of some nodes in the distributed system, the system cannot immediately open the data managed by the downtime node for a user to access, and the system availability is reduced.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
Through the above description of the embodiments, those skilled in the art can clearly understand that the data processing method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
Example 4
Embodiments of the present invention may provide a computer device, which may be any one of a group of computer devices, located in a distributed network. Optionally, in this embodiment, the computer device may also be replaced with a device such as a mobile terminal.
Optionally, in this embodiment, the computer device may be located in at least one network device of a plurality of network devices of a distributed computer network.
Optionally, the computer device comprises: a processor; and a memory coupled to the processor for providing instructions to the processor for processing the following processing steps: receiving an access request of a page; determining a sender of the access request; and when the node corresponding to the sender is consistent with the computer equipment, forwarding the access request to other nodes in the distributed network.
In this embodiment, the computer device described above may further execute program code for the following steps in the data processing method: acquiring a page identifier of a page from the access request; and determining a node identifier corresponding to the page based on the page identifier, and taking the node corresponding to the node identifier as a sender.
In this embodiment, the computer device described above may further execute program code for the following steps in the data processing method: carrying out hash operation on the page identification to obtain a hash value; and determining the node identification corresponding to the page based on the hash value.
In this embodiment, the computer device described above may further execute program code for the following steps in the data processing method: determining a target node number based on the node identification of the designated node and the number of nodes in the distributed network; and taking the node corresponding to the target node number as the other node.
In this embodiment, the computer device described above may further execute program code for the following steps in the data processing method: other nodes determine the type of the access request; when the type is the exclusive lock request, the state information of the page is recorded, and the state information is used for indicating that the page is in a locked state.
In this embodiment, the computer device described above may further execute program code for the following steps in the data processing method: after the access request is forwarded to other nodes in the distributed network, the designated node acquires the state information of the page from other nodes after the node is down; the designated node restores the page state of the page based on the state information of the page.
In this embodiment, the computer device described above may further execute program code for the following steps in the data processing method: when the type is not an exclusive lock request and the node corresponding to the sender is consistent with the designated node, determining the node corresponding to the page; the appointed node sends an access request to a node corresponding to the page; and the designated node receives page data sent by the node corresponding to the page, wherein the page data is the page data corresponding to the page.
Alternatively, fig. 8 is a block diagram of a computer terminal according to an embodiment of the present invention. As shown in fig. 8, the computer terminal a may include: one or more processors, memory, and network interfaces, input/output interfaces, keyboards, displays.
The memory may be configured to store software programs and modules, such as program instructions/modules corresponding to the data processing method and apparatus in the embodiments of the present invention, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory, so as to implement the data processing method. The memory may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory may further include memory remotely located from the processor, and these remote memories may be connected to terminal a through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The processor can call the information and application program stored in the memory through the transmission device to execute the following steps: receiving an access request of a page; determining a sender of the access request; and when the node corresponding to the sender is consistent with the computer equipment, forwarding the access request to other nodes in the distributed network.
Optionally, the processor may further execute the program code of the following steps: acquiring a page identifier of a page from the access request; and determining a node identifier corresponding to the page based on the page identifier, and taking the node corresponding to the node identifier as a sender.
Optionally, the processor may further execute the program code of the following steps: carrying out hash operation on the page identification to obtain a hash value; and determining the node identification corresponding to the page based on the hash value.
Optionally, the processor may further execute the program code of the following steps: determining a target node number based on the node identification of the designated node and the number of nodes in the distributed network; and taking the node corresponding to the target node number as the other node.
Optionally, the processor may further execute the program code of the following steps: other nodes determine the type of the access request; when the type is the exclusive lock request, the state information of the page is recorded, and the state information is used for indicating that the page is in a locked state.
Optionally, the processor may further execute the program code of the following steps: after the access request is forwarded to other nodes in the distributed network, the designated node acquires the state information of the page from other nodes after the node is down; the designated node restores the page state of the page based on the state information of the page.
The embodiment of the invention provides a data processing scheme. The method comprises the steps that the designated nodes in the distributed network are adopted to receive the access requests of the pages, the designated nodes determine the sending party of the access requests, and when the nodes corresponding to the sending party are consistent with the designated nodes, the designated nodes forward the access requests to other nodes in the distributed network, so that the access delay or the access request loss frequency occurring in the downtime process is reduced, the data inaccessible time in the data recovery process is greatly reduced, and the usability of the system is improved.
It can be understood by those skilled in the art that the structure shown in fig. 8 is only an illustration, and the computer terminal may also be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palmtop computer, a Mobile Internet Device (MID), a PAD, and the like. Fig. 8 does not limit the structure of the electronic device. For example, the computer terminal a may also include more or fewer components (e.g., network interfaces, display devices, etc.) than shown in fig. 8, or have a different configuration than shown in fig. 8.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by a program instructing hardware associated with the terminal device, where the program may be stored in a computer-readable storage medium, and the storage medium may include: flash disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.