CN113726827A - Data packet processing method and device based on distributed cluster - Google Patents
Data packet processing method and device based on distributed cluster Download PDFInfo
- Publication number
- CN113726827A CN113726827A CN202010447924.1A CN202010447924A CN113726827A CN 113726827 A CN113726827 A CN 113726827A CN 202010447924 A CN202010447924 A CN 202010447924A CN 113726827 A CN113726827 A CN 113726827A
- Authority
- CN
- China
- Prior art keywords
- data packet
- packet
- distributed cluster
- response
- data
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 20
- 230000004044 response Effects 0.000 claims abstract description 68
- 238000000034 method Methods 0.000 claims abstract description 51
- 238000013507 mapping Methods 0.000 claims abstract description 47
- 238000012545 processing Methods 0.000 claims abstract description 40
- 230000008569 process Effects 0.000 claims abstract description 29
- 230000001360 synchronised effect Effects 0.000 claims description 16
- 238000004590 computer program Methods 0.000 claims description 9
- 230000003993 interaction Effects 0.000 claims description 6
- 238000012856 packing Methods 0.000 claims description 5
- 238000000926 separation method Methods 0.000 abstract description 4
- 238000010586 diagram Methods 0.000 description 12
- 238000004891 communication Methods 0.000 description 11
- 230000005540 biological transmission Effects 0.000 description 9
- 230000006870 function Effects 0.000 description 6
- 230000003287 optical effect Effects 0.000 description 4
- 239000003795 chemical substances by application Substances 0.000 description 3
- 238000013461 design Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000007246 mechanism Effects 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 238000012795 verification Methods 0.000 description 2
- 238000013459 approach Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000008520 organization Effects 0.000 description 1
- 238000004806 packaging method and process Methods 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
- H04L67/141—Setup of application sessions
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/2866—Architectures; Arrangements
- H04L67/30—Profiles
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The embodiment of the disclosure discloses a data packet processing method and device based on a distributed cluster. One embodiment of the method comprises: receiving a data packet sent by target equipment, wherein the target equipment is connected with the distributed cluster; determining the type of the data packet; and in response to determining that the type of the data packet belongs to is a response packet, selecting a matched node from the distributed cluster to process the data packet according to a preset mapping relation table, wherein the mapping relation table is used for recording the attribution relation between the sent message and the nodes in the distributed cluster. The implementation mode realizes the separation of node matching and processing logic, thereby simplifying the logic complexity and improving the program operation efficiency.
Description
Technical Field
The embodiment of the disclosure relates to the technical field of computers, in particular to a data packet processing method and device based on a distributed cluster.
Background
With the rapid development of internet technology, clusters based on a distributed architecture are also widely applied. In the prior art, a distributed synchronous interface design is often used as a main mode among business systems in an organization. Due to the advantages of high efficiency and stability of long TCP (Transmission Control Protocol) connections, the external connection provided by the mechanism (e.g., financial mechanism) with frequent operation and point-to-point communication requirements is usually an n-in n-out asynchronous simplex TCP long connection.
The relevant approach is typically to persist the request data after the requestor sends the request so that the asynchronous response can continue to the following processing logic as it arrives.
Disclosure of Invention
The embodiment of the disclosure provides a data packet processing method and device based on a distributed cluster.
In a first aspect, an embodiment of the present disclosure provides a method for processing a packet based on a distributed cluster, where the method includes: receiving a data packet sent by target equipment, wherein the target equipment is connected with the distributed cluster; determining the type of the data packet; and in response to the fact that the type of the data packet is determined to be a response packet, selecting a matched node from the distributed cluster to process the data packet according to a preset mapping relation table, wherein the mapping relation table is used for recording the attribution relation between the sent message and the nodes in the distributed cluster.
In some embodiments, the selecting the matched node from the distributed cluster according to the preset mapping relationship table to process the data packet includes: responding to the response packet which is determined to be corresponding to the request sent by the node, analyzing the data packet and generating response data; and calling the thread matched with the data packet to process the response data according to a preset corresponding relation table, wherein the corresponding relation table is used for representing the corresponding relation between the sent data and the thread.
In some embodiments, the selecting the matched node from the distributed cluster according to the preset mapping relationship table to process the data packet includes: and responding to a response packet corresponding to the request which is determined that the data packet is not sent by the node, and forwarding the data packet to the matched node according to the mapping relation table so that the matched node processes the data packet.
In some embodiments, the method further comprises: in response to determining that the type of the data packet is a request packet, analyzing the data packet to generate request data; calling a synchronous interface to obtain a return result corresponding to the request data, wherein the synchronous interface is used for interaction among nodes in the distributed cluster; packing the return result into a return data packet with the format consistent with that of the data packet; the return packet is sent over the long connection.
In some embodiments, the sending the return packet over the long connection includes: acquiring the state of a sending link corresponding to the long connection; and selecting an idle transmission link to transmit a return data packet.
In some embodiments, the method further comprises: acquiring a request data packet to be sent; sending a request data packet through the long connection; and updating the mapping relation table based on the request data packet and the identifier of the node.
In a second aspect, an embodiment of the present disclosure provides a packet processing apparatus based on a distributed cluster, where the apparatus includes: the receiving unit is configured to receive a data packet sent by a target device, wherein the target device is connected with the distributed cluster; a determining unit configured to determine a type to which the packet belongs; and the processing unit is configured to select a matched node from the distributed cluster to process the data packet according to a preset mapping relation table in response to the fact that the type to which the data packet belongs is determined to be a response packet, wherein the mapping relation table is used for recording the attribution relation between the sent message and the nodes in the distributed cluster.
In some embodiments, the processing unit is further configured to: responding to the response packet which is determined to be corresponding to the request sent by the node, analyzing the data packet and generating response data; and calling the thread matched with the data packet to process the response data according to a preset corresponding relation table, wherein the corresponding relation table is used for representing the corresponding relation between the sent data and the thread.
In some embodiments, the processing unit is further configured to, in response to determining that the packet is not a response packet corresponding to the request sent by the node, forward the packet to the matching node according to the mapping table, so that the matching node processes the packet.
In some embodiments, the apparatus further comprises: the first sending unit is configured to respond to the fact that the type of the data packet is determined to be a request packet, analyze the data packet and generate request data; calling a synchronous interface to obtain a return result corresponding to the request data, wherein the synchronous interface is used for interaction among nodes in the distributed cluster; packing the return result into a return data packet with the format consistent with that of the data packet; the return packet is sent over the long connection.
In some embodiments, the first sending unit includes: an acquisition module configured to acquire a state of a transmission link corresponding to a long connection; and the sending module is configured to select an idle sending link to send the return data packet.
In some embodiments, the apparatus further comprises: an acquisition unit configured to acquire a request packet to be transmitted; a second transmission unit configured to transmit the request packet through the long connection; and the updating unit is configured to update the mapping relation table based on the request data packet and the identifier of the node.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including: one or more processors; a storage device having one or more programs stored thereon; when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the method as described in any implementation of the first aspect.
In a fourth aspect, embodiments of the present disclosure provide a computer-readable medium on which a computer program is stored, which when executed by a processor implements the method as described in any of the implementations of the first aspect.
The embodiment of the disclosure provides a distributed cluster-based data packet processing method and device, which receive a data packet sent by a target device. Wherein the target device is connected with the distributed cluster. Then, the type to which the packet belongs is determined. And finally, in response to the fact that the type of the data packet is determined to be the response packet, selecting the matched node from the distributed cluster according to a preset mapping relation table to process the data packet. The mapping relation table is used for recording the attribution relation between the sent message and the nodes in the distributed cluster. Therefore, the separation of node matching and processing logic is realized, and the logic complexity is simplified. Moreover, external asynchronous connection is converted into a synchronous service interface between nodes in the cluster, so that the data access times are reduced, the program operation efficiency is improved, and the problem searching and positioning can be performed more easily through a result log.
Drawings
Other features, objects and advantages of the disclosure will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which one embodiment of the present disclosure may be applied;
FIG. 2 is a flow diagram for one embodiment of a distributed cluster-based packet processing method according to the present disclosure;
fig. 3 is a schematic diagram of an application scenario of a distributed cluster-based packet processing method according to an embodiment of the present disclosure;
FIG. 4 is a flow diagram of yet another embodiment of a distributed cluster-based packet processing method according to the present disclosure;
FIG. 5 is a schematic block diagram illustrating one embodiment of a distributed cluster-based packet processing apparatus according to the present disclosure;
FIG. 6 is a schematic structural diagram of an electronic device suitable for use in implementing embodiments of the present disclosure.
Detailed Description
The present disclosure is described in further detail below with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that, in the present disclosure, the embodiments and features of the embodiments may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates an exemplary architecture 100 to which the distributed cluster-based packet processing method or distributed cluster-based packet processing apparatus of the present disclosure may be applied.
As shown in fig. 1, the system architecture 100 may include end devices 101, 102, 103, a network 104, and a server cluster 105. The network 104 serves to provide a medium of communication links between the terminal devices 101, 102, 103 and the server cluster 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The terminal devices 101, 102, 103 interact with the server cluster 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have various communication client applications installed thereon, such as a web browser application, a shopping application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal apparatuses 101, 102, and 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices having a display screen and supporting communication, including but not limited to smart phones, tablet computers, e-book readers, laptop portable computers, desktop computers, and the like. When the terminal apparatuses 101, 102, 103 are software, they can be installed in the electronic apparatuses listed above. It may be implemented as multiple pieces of software or software modules (e.g., software or software modules used to provide distributed services) or as a single piece of software or software module. And is not particularly limited herein.
The server cluster 105 may be implemented as a distributed server cluster of multiple servers, which may include servers providing various services, such as background web servers providing support for web pages displayed on the terminal devices 101, 102, 103. The background web server may analyze and perform other processing on the received data such as the web page request, and feed back a processing result (e.g., web page data) to the terminal device.
It should be noted that the servers 1051, 1052, 1053, 1054 in the server cluster 105 may interact with each other mainly through a distributed synchronization interface design. The server cluster 105 may be communicatively connected to the terminal devices 101, 102, 103 via an n-in n-out asynchronous simplex TCP long connection. The server may be hardware or software. And is not particularly limited herein.
It should be noted that the packet processing method based on the distributed cluster provided by the embodiment of the present disclosure may be executed by a server in the server cluster 105, or may be executed by a client in a client cluster (not shown in the figure); accordingly, the distributed cluster-based packet processing apparatus may be provided in a server or a client.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to fig. 2, a flow 200 of one embodiment of a distributed cluster-based packet processing method in accordance with the present disclosure is shown. The data packet processing method based on the distributed cluster comprises the following steps:
In this embodiment, an execution subject of the packet processing method based on the distributed cluster (for example, any server in the server cluster 105 shown in fig. 1) may receive the packet sent by the target device in a wired connection manner or a wireless connection manner. Wherein, the target device may generally include an electronic device that is long-connected to the distributed cluster. The long connection may be, for example, an n-in n-out asynchronous simplex TCP long connection.
In step 202, the type of the data packet is determined.
In this embodiment, the execution entity may determine the type of the data packet received in step 201 in various ways. The type of the data packet may be determined according to an actual application scenario. It may include, but is not limited to, at least one of the following: heartbeat packet, request packet, response packet.
In this embodiment, the execution body may extract, according to different communication protocols, a field representing a type of the received packet from the received packet. Then, the type of the data packet is determined according to the extracted field.
In this embodiment, in response to determining that the type of the data packet is a response packet, the execution body may extract a return field from the response packet. The feedback field may be used to identify the request for the response packet. Then, according to a preset mapping relationship table, the execution subject may select a node to which the request belongs from the distributed cluster as a matched node. The mapping relationship table may be configured to record an attribution relationship between a sent packet and a node in the distributed cluster.
It should be noted that, along with the sending of the message, the execution body may also update the content in the mapping relationship table. Typically, the mapping table is maintained by nodes of the distributed cluster.
In some optional implementations of this embodiment, the execution main body may first determine, according to the preset mapping relationship table, whether the data packet is a response packet corresponding to the request sent by the execution main body (i.e., the local node). In response to determining that the data packet is a response packet corresponding to the request sent by the execution main body, the execution main body may select a matching node from the distributed cluster to process the data packet according to the following steps:
first, the data packet is parsed to generate response data.
In these implementations, the execution body may parse the packet according to a format of the packet, so as to obtain the response data. The format of the data packet may be, for example, a TLV (tag-length-value).
And step two, calling a thread matched with the data packet to process response data according to a preset corresponding relation table.
In these implementations, according to a preset mapping table, the execution body may invoke a thread matching the data packet to process the response data generated in the first step. The correspondence table may be used to represent a correspondence between the transmitted data and the thread of the execution subject (i.e., the local node). The execution agent may first determine a request corresponding to the response data. Then, the execution agent may specify a thread corresponding to the request as the matching thread based on the correspondence table. Then, the execution subject may call the matching thread to process the response data.
Alternatively, the thread may enter a sleep state after sending the request packet. The execution subject may wake up the matching thread after determining the matching thread. The matching thread may then process the response data.
In some optional implementations of this embodiment, in response to determining that the packet is not a response packet corresponding to the request sent by the execution main body (i.e., the node), the execution main body may forward the packet to the matching node according to the mapping relationship table, so that the matching node processes the packet. The matched node may be a node to which the request corresponding to the response packet recorded in the mapping relationship table belongs.
In some optional implementation manners of this embodiment, in response to determining that the type of the data packet is a request packet, the execution main body may continue to perform the following steps:
firstly, the data packet is analyzed to generate request data.
In these implementations, the execution body may parse the data packet according to a format of the data packet, so as to obtain the request data. The format of the data packet may be TLV, for example.
And step two, calling a synchronous interface to obtain a return result corresponding to the request data.
In these implementations, the execution agent may call a synchronization interface to obtain a return result corresponding to the request data generated in the first step. The synchronization interface may be used for interaction between nodes in the distributed cluster. The nodes in the distributed cluster can transmit service processing data through the synchronous interface.
And thirdly, packaging the return result into a return data packet with the format consistent with that of the data packet.
In these implementations, the execution body may package the return result obtained in the second step into a return data packet in a format (e.g., TLV format) consistent with the data packet format in various ways.
And fourthly, sending the return data packet through long connection.
In these implementations, the execution body may send the return packet generated in the third step through the long-connection link for external communication.
Alternatively, the execution body may be responsible for maintaining a plurality of long connected links. So that the executing body can also first acquire the state of the transmission link corresponding to the long connection. Wherein the long connection may be maintained by a heartbeat packet. Then, the execution body may select an idle transmission link to transmit the return packet.
With continued reference to fig. 3, fig. 3 is a schematic diagram of an application scenario of a distributed cluster-based data packet processing method according to an embodiment of the present disclosure. In the application scenario of fig. 3, a user 301 may send a reply packet 303 to a server 304-a via a terminal device 302. The response packet 303 may include, for example, a field (e.g., "request 1") for identifying a corresponding request and data (e.g., "1234" as an authentication code). The server 304-a may determine the type of reply packet 303 described above. According to the preset mapping relation table 305, the server 304-a may determine that the response packet is a response to the request sent by the node, so that the response packet 303 may continue to be processed (for example, identity verification is performed by using the verification code "1234").
Currently, one of the prior arts is to persist the requested data after the request is sent by the requester, which results in large amount of data to be stored and complex processing logic. In the method provided by the embodiment of the disclosure, the matched node is selected for processing by determining the type of the received data packet and the preset mapping relation table, so that the separation of node matching and processing logic is realized, and the logic complexity is simplified. Moreover, external asynchronous connection is converted into a synchronous service interface between nodes in the cluster, so that the data access times are reduced, the program operation efficiency is improved, and the problem searching and positioning can be performed more easily through a result log.
With further reference to fig. 4, a flow 400 of yet another embodiment of a distributed cluster-based packet processing method is shown. The flow 400 of the distributed cluster-based packet processing method includes the following steps:
In this embodiment, an executing entity (for example, a server in the server cluster 105 shown in fig. 1) of the packet processing method based on the distributed cluster may first obtain a request packet to be sent in a wired or wireless manner. As an example, the execution subject may obtain the request packet sent by the thread from the local. As another example, the execution main body may also obtain the request packet to be sent from a synchronization interface in the distributed cluster. The format of the request packet may include various formats suitable for long connections, such as TLV.
In this embodiment, the executing entity may send the request packet obtained in step 401 through a long-connection link between the distributed cluster and external communication.
In some optional implementations of the present embodiment, the execution body may be responsible for maintaining a plurality of long connected links. So that the executing body can also first acquire the state of the transmission link corresponding to the long connection. Wherein the long connection may be maintained by a heartbeat packet. Then, the execution body may select an idle transmission link to transmit the request packet.
In this embodiment, based on the request packet and the identifier of the execution entity (i.e., the node), the execution entity may update the mapping relation table in various ways. The mapping relationship table may be configured to record an attribution relationship between a sent packet and a node in the distributed cluster. The identification may include various forms such as an IP (Internet Protocol) address, a label, a character string, and the like.
At step 405, the type of packet is determined.
And step 406, in response to determining that the type of the data packet is the response packet, selecting a matched node from the distributed cluster according to a preset mapping relation table to process the data packet.
As can be seen from fig. 4, the flow 400 of the packet processing method based on the distributed cluster in this embodiment represents a step of updating the mapping table according to the transmitted request packet and the identifier of this node. Therefore, the scheme described in this embodiment can maintain the update of the mapping relationship table, thereby providing a basis for allocating the data responsible for processing to each node in the distributed cluster.
With further reference to fig. 5, as an implementation of the methods shown in the above-mentioned figures, the present disclosure provides an embodiment of a packet processing apparatus based on a distributed cluster, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 2, and the apparatus may be specifically applied to various electronic devices.
As shown in fig. 5, the packet processing apparatus 500 based on distributed cluster according to this embodiment includes a receiving unit 501, a determining unit 502, and a processing unit 503. The receiving unit 501 is configured to receive a data packet sent by a target device, where the target device is connected to the distributed cluster; a determining unit 502 configured to determine a type to which the packet belongs; and the processing unit 503 is configured to, in response to determining that the type to which the data packet belongs is the response packet, select a matching node from the distributed cluster to process the data packet according to a preset mapping relationship table, where the mapping relationship table is used to record an attribution relationship between the sent packet and the nodes in the distributed cluster.
In this embodiment, in the packet processing apparatus 500 based on distributed cluster: the specific processing of the receiving unit 501, the determining unit 502, and the processing unit 503 and the technical effects thereof can refer to the related descriptions of step 201, step 202, and step 203 in the corresponding embodiment of fig. 2, which are not repeated herein.
In some optional implementations of this embodiment, the processing unit 503 may be further configured to: responding to the response packet which is determined to be corresponding to the request sent by the node, analyzing the data packet and generating response data; and calling the thread matched with the data packet to process the response data according to the preset corresponding relation table. The correspondence table may be used to characterize the correspondence between the sent data and the threads.
In some optional implementations of this embodiment, the processing unit 503 may be further configured to, in response to determining that the packet is not a response packet corresponding to the request sent by the node, forward the packet to the matching node according to the mapping relationship table, so that the matching node processes the packet.
In some optional implementations of this embodiment, the packet processing apparatus 500 based on a distributed cluster may further include: a first sending unit (not shown in the figure) configured to respond to the type of the data packet determined to be the request packet, analyze the data packet and generate request data; calling a synchronous interface to obtain a return result corresponding to the request data, wherein the synchronous interface can be used for interaction among nodes in the distributed cluster; packing the return result into a return data packet with the format consistent with that of the data packet; the return packet is sent over the long connection.
In some optional implementation manners of this embodiment, the first sending unit may include: an acquisition module (not shown in the figure), and a sending module (not shown in the figure). The obtaining module may be configured to obtain a state of a transmission link corresponding to the long connection. The sending module may be configured to select an idle sending link to send the return data packet.
In some optional implementations of this embodiment, the packet processing apparatus 500 based on a distributed cluster may further include: an acquisition unit (not shown), a second sending unit (not shown), and an updating unit (not shown). The obtaining unit may be configured to obtain a request packet to be sent. The second transmitting unit may be configured to transmit the request packet via the long connection. The updating unit may be configured to update the mapping relationship table based on the request packet and the identifier of the node.
The apparatus provided by the above embodiment of the present disclosure receives, by the receiving unit 501, a data packet sent by a target device. Wherein the target device is connected with the distributed cluster. Then, the determination unit 502 determines the type to which the packet belongs. Finally, in response to determining that the type of the data packet is the response packet, the processing unit 503 selects a matching node from the distributed cluster according to a preset mapping relationship table to process the data packet. The mapping relation table is used for recording the attribution relation between the sent message and the nodes in the distributed cluster. Therefore, the separation of node matching and processing logic is realized, and the logic complexity is simplified. Moreover, external asynchronous connection is converted into a synchronous service interface between nodes in the cluster, so that the data access times are reduced, the program operation efficiency is improved, and the problem searching and positioning can be performed more easily through a result log.
Referring now to FIG. 6, a schematic diagram of an electronic device (e.g., the server of FIG. 1) 600 suitable for use in implementing embodiments of the present disclosure is shown. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like. The server shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 6, electronic device 600 may include a processing means (e.g., central processing unit, graphics processor, etc.) 601 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM603, various programs and data necessary for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Generally, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keyboard, mouse, camera, etc.; an output device 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 6 illustrates an electronic device 600 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided. Each block shown in fig. 6 may represent one device or may represent multiple devices as desired.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 609, or may be installed from the storage means 608, or may be installed from the ROM 602. The computer program, when executed by the processing device 601, performs the above-described functions defined in the methods of embodiments of the present disclosure.
It should be noted that the computer readable medium described in the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In embodiments of the present disclosure, however, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: receiving a data packet sent by target equipment, wherein the target equipment is connected with the distributed cluster; determining the type of the data packet; and in response to the fact that the type of the data packet is determined to be a response packet, selecting a matched node from the distributed cluster to process the data packet according to a preset mapping relation table, wherein the mapping relation table is used for recording the attribution relation between the sent message and the nodes in the distributed cluster.
Computer program code for carrying out operations for embodiments of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a receiving unit, a determining unit, and a processing unit. The names of these units do not in some cases form a limitation on the units themselves, and for example, a receiving unit may also be described as a unit that receives a packet sent by a target device, where the target device is long-connected to the distributed cluster.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the embodiments of the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is made without departing from the inventive concept as defined above. For example, the above features and (but not limited to) technical features with similar functions disclosed in the embodiments of the present disclosure are mutually replaced to form the technical solution.
Claims (10)
1. A data packet processing method based on a distributed cluster comprises the following steps:
receiving a data packet sent by target equipment, wherein the target equipment is connected with the distributed cluster;
determining the type of the data packet;
and in response to the fact that the type of the data packet is determined to be a response packet, selecting a matched node from the distributed cluster to process the data packet according to a preset mapping relation table, wherein the mapping relation table is used for recording the attribution relation between the sent message and the nodes in the distributed cluster.
2. The method of claim 1, wherein the selecting the matching node from the distributed clusters according to a preset mapping relation table for processing the data packet comprises:
in response to the fact that the data packet is determined to be a response packet corresponding to the request sent by the node, analyzing the data packet to generate response data; and calling a thread matched with the data packet to process the response data according to a preset corresponding relation table, wherein the corresponding relation table is used for representing the corresponding relation between the sent data and the thread.
3. The method of claim 1, wherein the selecting the matching node from the distributed clusters according to a preset mapping relation table for processing the data packet comprises:
and in response to determining that the data packet is not a response packet corresponding to the request sent by the node, forwarding the data packet to the matched node according to the mapping relation table, so that the matched node processes the data packet.
4. The method of claim 1, wherein the method further comprises:
in response to the fact that the type of the data packet is determined to be a request packet, analyzing the data packet and generating request data; calling a synchronous interface to obtain a return result corresponding to the request data, wherein the synchronous interface is used for interaction among the nodes in the distributed cluster; packing the return result into a return data packet with the format consistent with that of the data packet; and sending the return data packet through the long connection.
5. The method of claim 4, wherein the sending the return packet over the long connection comprises:
acquiring the state of a sending link corresponding to the long connection;
and selecting an idle sending link to send the return data packet.
6. The method according to one of claims 1-5, wherein the method further comprises:
acquiring a request data packet to be sent;
sending the request data packet through a long connection;
and updating the mapping relation table based on the request data packet and the identifier of the node.
7. A distributed cluster-based packet processing apparatus, comprising:
a receiving unit configured to receive a data packet sent by a target device, wherein the target device is connected with the distributed cluster;
a determining unit configured to determine a type to which the data packet belongs;
and the processing unit is configured to select a matched node from the distributed cluster to process the data packet according to a preset mapping relation table in response to the fact that the type of the data packet is determined to be a response packet, wherein the mapping relation table is used for recording the attribution relation between the sent message and the nodes in the distributed cluster.
8. The apparatus of claim 7, wherein the apparatus further comprises:
the sending unit is configured to respond to the fact that the type to which the data packet belongs is determined to be a request packet, analyze the data packet and generate request data; calling a synchronous interface to obtain a return result corresponding to the request data, wherein the synchronous interface is used for interaction among the nodes in the distributed cluster; packing the return result into a return data packet with the format consistent with that of the data packet; and sending the return data packet through the long connection.
9. An electronic device, comprising:
one or more processors;
a storage device having one or more programs stored thereon;
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-6.
10. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010447924.1A CN113726827A (en) | 2020-05-25 | 2020-05-25 | Data packet processing method and device based on distributed cluster |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010447924.1A CN113726827A (en) | 2020-05-25 | 2020-05-25 | Data packet processing method and device based on distributed cluster |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113726827A true CN113726827A (en) | 2021-11-30 |
Family
ID=78671619
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010447924.1A Pending CN113726827A (en) | 2020-05-25 | 2020-05-25 | Data packet processing method and device based on distributed cluster |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113726827A (en) |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9172584B1 (en) * | 2012-09-21 | 2015-10-27 | Emc Corporation | Method and system for high-availability cluster data protection |
CN108073696A (en) * | 2017-12-11 | 2018-05-25 | 厦门亿力吉奥信息科技有限公司 | GIS application processes based on distributed memory database |
US20180189417A1 (en) * | 2017-01-04 | 2018-07-05 | International Business Machines Corporation | Dynamic faceting for personalized search and discovery |
CN110046062A (en) * | 2019-03-07 | 2019-07-23 | 佳都新太科技股份有限公司 | Distributed data processing method and system |
CN110245014A (en) * | 2018-03-09 | 2019-09-17 | 北京京东尚科信息技术有限公司 | Data processing method and device |
CN110633296A (en) * | 2018-05-31 | 2019-12-31 | 北京京东尚科信息技术有限公司 | Data query method, device, medium and electronic equipment |
CN110795503A (en) * | 2019-10-18 | 2020-02-14 | 北京达佳互联信息技术有限公司 | Multi-cluster data synchronization method and related device of distributed storage system |
CN110995656A (en) * | 2019-11-06 | 2020-04-10 | 深信服科技股份有限公司 | Load balancing method, device, equipment and storage medium |
CN111026709A (en) * | 2019-12-10 | 2020-04-17 | 中盈优创资讯科技有限公司 | Data processing method and device based on cluster access |
-
2020
- 2020-05-25 CN CN202010447924.1A patent/CN113726827A/en active Pending
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9172584B1 (en) * | 2012-09-21 | 2015-10-27 | Emc Corporation | Method and system for high-availability cluster data protection |
US20180189417A1 (en) * | 2017-01-04 | 2018-07-05 | International Business Machines Corporation | Dynamic faceting for personalized search and discovery |
CN108073696A (en) * | 2017-12-11 | 2018-05-25 | 厦门亿力吉奥信息科技有限公司 | GIS application processes based on distributed memory database |
CN110245014A (en) * | 2018-03-09 | 2019-09-17 | 北京京东尚科信息技术有限公司 | Data processing method and device |
CN110633296A (en) * | 2018-05-31 | 2019-12-31 | 北京京东尚科信息技术有限公司 | Data query method, device, medium and electronic equipment |
CN110046062A (en) * | 2019-03-07 | 2019-07-23 | 佳都新太科技股份有限公司 | Distributed data processing method and system |
CN110795503A (en) * | 2019-10-18 | 2020-02-14 | 北京达佳互联信息技术有限公司 | Multi-cluster data synchronization method and related device of distributed storage system |
CN110995656A (en) * | 2019-11-06 | 2020-04-10 | 深信服科技股份有限公司 | Load balancing method, device, equipment and storage medium |
CN111026709A (en) * | 2019-12-10 | 2020-04-17 | 中盈优创资讯科技有限公司 | Data processing method and device based on cluster access |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107622135B (en) | Method and apparatus for displaying information | |
CN107302597B (en) | Message file pushing method and device | |
CN110781373B (en) | List updating method and device, readable medium and electronic equipment | |
US11758087B2 (en) | Multimedia conference data processing method and apparatus, and electronic device | |
CN111443909A (en) | Method and device for generating page | |
CN108549586B (en) | Information processing method and device | |
CN111881216A (en) | Data acquisition method and device based on shared template | |
CN114513552B (en) | Data processing method, device, equipment and storage medium | |
CN111427899A (en) | Method, device, equipment and computer readable medium for storing file | |
CN113313623A (en) | Watermark information display method, watermark information display device, electronic equipment and computer readable medium | |
CN110708238B (en) | Method and apparatus for processing information | |
CN113542335A (en) | Information sharing method and device, electronic equipment and storage medium | |
CN112948138A (en) | Method and device for processing message | |
CN111460020B (en) | Method, device, electronic equipment and medium for resolving message | |
CN110858240A (en) | Front-end module loading method and device | |
CN115454666A (en) | Data synchronization method and device among message queue clusters | |
CN113726827A (en) | Data packet processing method and device based on distributed cluster | |
CN112732457A (en) | Image transmission method, image transmission device, electronic equipment and computer readable medium | |
CN113779018A (en) | Data processing method and device | |
US10372436B2 (en) | Systems and methods for maintaining operating consistency for multiple users during firmware updates | |
CN112311833B (en) | Data updating method and device | |
CN114513548B (en) | Directional call information processing method and device | |
CN113132480B (en) | Data transmission method, device and system | |
CN114253520B (en) | Interface code generation method and device | |
CN111090485B (en) | Multi-cluster-oriented help data processing method and device, medium and equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |