Data Packet Processing Method and Apparatus Based on Distributed Cluster

By receiving data packets in a distributed cluster and selecting matching nodes according to the mapping relationship table, the problems of high logic complexity of data packet processing and high number of data accesses in the prior art are solved, and more efficient data processing and problem positioning are achieved.

CN113726827BActive Publication Date: 2025-06-20BEIJING TONGBANGZHUOYI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010447924.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-05-25
Publication Date
2025-06-20
Estimated Expiration
2040-05-25

AI Technical Summary

Technical Problem

In the prior art, the data packet processing of distributed clusters has problems such as high logical complexity and frequent data access times, especially in asynchronous connection scenarios.

Method used

By receiving the data packets sent by the target device and selecting matching nodes from the distributed cluster according to the preset mapping relationship table for processing, the separation of node matching and processing logic is achieved.

Benefits of technology

It simplifies logical complexity, reduces the number of data accesses, improves program operation efficiency, and makes problem finding and positioning easier.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113726827B_ABST
    Figure CN113726827B_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure disclose a data packet processing method and apparatus based on a distributed cluster. A specific implementation of the method includes: receiving a data packet sent by a target device, where the target device has a long connection with the distributed cluster; determining the type to which the data packet belongs; in response to determining that the type to which the data packet belongs is an acknowledgment packet, selecting a matching node from the distributed cluster according to a preset mapping relationship table to process the data packet, where the mapping relationship table is used to record the attribution relationship between the sent message and the nodes in the distributed cluster. This implementation realizes the separation of node matching and processing logic, thereby simplifying the logical complexity and improving the program running efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present disclosure relate to the field of computer technologies, and more particularly, to a method and apparatus for processing data packets based on a distributed cluster. Background Art

[0002] With the rapid development of Internet technologies, clusters based on a distributed architecture have also found increasingly widespread applications. In the prior art, the business systems within an organization often mainly adopt a distributed synchronous interface design. Due to the advantages of high efficiency and stability of TCP (Transmission Control Protocol) long connections, the external connections provided on the front-end systems or hardware devices of organizations with frequent operations and point-to-point communication requirements (such as financial institutions) are usually n-in n-out asynchronous simplex TCP long connections.

[0003] Related methods usually persist the request data after the requester sends a request so that the subsequent processing logic can continue when the asynchronous response arrives. Summary of the Invention

[0004] Embodiments of the present disclosure propose a method and apparatus for processing data packets based on a distributed cluster.

[0005] In a first aspect, embodiments of the present disclosure provide a method for processing data packets based on a distributed cluster, the method including: receiving a data packet sent by a target device, where the target device has a long connection with the distributed cluster; determining the type to which the data packet belongs; and in response to determining that the type to which the data packet belongs is a response packet, selecting a matching node from the distributed cluster according to a preset mapping relation table to process the data packet, where the mapping relation table is used to record the attribution relationship between the sent message and the nodes in the distributed cluster.

[0006] In some embodiments, the selecting a matching node from the distributed cluster according to a preset mapping relation table to process the data packet includes: in response to determining that the data packet is a response packet corresponding to a request sent by the present node, parsing the data packet to generate response data; and according to a preset corresponding relation table, invoking a thread matching the data packet to process the response data, where the corresponding relation table is used to represent the corresponding relationship between the sent data and the thread.

[0007] In some embodiments, the selecting a matching node from the distributed cluster according to a preset mapping relation table to process the data packet includes: in response to determining that the data packet is not a response packet corresponding to a request sent by the present node, forwarding the data packet to a matching node according to the mapping relation table so that the matching node processes the data packet.

[0008] In some embodiments, the method further includes: in response to determining that the type of the data packet is a request packet, parsing the data packet to generate request data; invoking a synchronization interface to obtain a return result corresponding to the request data, where the synchronization interface is used for interaction between nodes in a distributed cluster; packing the return result into a return data packet with the same format as the data packet; and sending the return data packet through a long connection.

[0009] In some embodiments, the above-mentioned sending the return data packet through a long connection includes: obtaining the status of the sending link corresponding to the long connection; and selecting an idle sending link to send the return data packet.

[0010] In some embodiments, the method further includes: obtaining 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 local node.

[0011] In a second aspect, an embodiment of the present disclosure provides a data packet processing apparatus based on a distributed cluster. The apparatus includes: a receiving unit configured to receive a data packet sent by a target device, where the target device has a long connection with the distributed cluster; a determining unit configured to determine the type of the data packet; and a processing unit configured to, in response to determining that the type of the data packet is a response packet, select a matching node from the distributed cluster according to a preset mapping relation table to process the data packet, where the mapping relation table is used to record the attribution relationship between the sent message and the nodes in the distributed cluster.

[0012] In some embodiments, the above-mentioned processing unit is further configured to: in response to determining that the data packet is a response packet corresponding to a request sent by the local node, parse the data packet to generate response data; and according to a preset correspondence table, invoke a thread matching the data packet to process the response data, where the correspondence table is used to represent the correspondence relationship between the sent data and the thread.

[0013] In some embodiments, the above-mentioned processing unit is further configured to, in response to determining that the data packet is not a response packet corresponding to a request sent by the local node, forward the data packet to a matching node according to the mapping relation table so that the matching node processes the data packet.

[0014] In some embodiments, the apparatus further includes: a first sending unit configured to, in response to determining that the type of the data packet is a request packet, parse the data packet to generate request data; invoke a synchronization interface to obtain a return result corresponding to the request data, where the synchronization interface is used for interaction between nodes in a distributed cluster; pack the return result into a return data packet with the same format as the data packet; and send the return data packet through a long connection.

[0015] In some embodiments, the first sending unit includes: an obtaining module configured to obtain the status of a sending link corresponding to a long connection; a sending module configured to select an idle sending link to send a return data packet.

[0016] In some embodiments, the apparatus further includes: an obtaining unit configured to obtain a request data packet to be sent; a second sending unit configured to send the request data packet through a long connection; and an updating unit configured to update a mapping relation table based on the request data packet and the identifier of the local node.

[0017] In a third aspect, an embodiment of the present disclosure provides an electronic device, which includes: one or more processors; a storage device storing one or more programs 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 described in any implementation manner of the first aspect.

[0018] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, and when the program is executed by a processor, the method described in any implementation manner of the first aspect is implemented.

[0019] The method and apparatus for processing data packets based on a distributed cluster provided by the embodiments of the present disclosure receive data packets sent by a target device. Among them, the target device has a long connection with the distributed cluster. Then, the type to which the data packet belongs is determined. Finally, in response to determining that the type to which the data packet belongs is a response packet, a matching node is selected from the distributed cluster according to a preset mapping relation table to process the data packet. The mapping relation table is used to record the attribution relationship between the sent message and the nodes in the distributed cluster. Thereby, the separation of node matching and processing logic is achieved, thus simplifying the logical complexity. Moreover, by converting an external asynchronous connection into a synchronous service interface between nodes inside the cluster, the number of data accesses is reduced, the program running efficiency is improved, and it is also easier to find and locate problems through result logs. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] By reading the detailed description of the non-limiting embodiments with reference to the following drawings, other features, objects, and advantages of the present disclosure will become more apparent:

[0021] Figure 1 is an exemplary system architecture diagram to which an embodiment of the present disclosure can be applied;

[0022] Figure 2 is a flowchart of an embodiment of the method for processing data packets based on a distributed cluster according to the present disclosure;

[0023] Figure 3It is a schematic diagram of an application scenario of a data packet processing method based on a distributed cluster according to an embodiment of the present disclosure;

[0024] Figure 4 It is a flowchart of another embodiment of the data packet processing method based on a distributed cluster according to the present disclosure;

[0025] Figure 5 It is a schematic structural diagram of an embodiment of a data packet processing device based on a distributed cluster according to the present disclosure;

[0026] Figure 6 It is a schematic structural diagram of an electronic device suitable for implementing the embodiments of the present disclosure. Detailed implementation manners

[0027] The present disclosure will be further described in detail below with reference to the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the related invention, rather than limiting the invention. Additionally, it should be noted that for the sake of description, only parts related to the relevant invention are shown in the drawings.

[0028] It should be noted that, without conflict, the embodiments in the present disclosure and the features in the embodiments can be combined with each other. The present disclosure will be described in detail below with reference to the drawings and embodiments.

[0029] Figure 1 An exemplary architecture 100 is shown to which the data packet processing method based on a distributed cluster or the data packet processing device based on a distributed cluster of the present disclosure can be applied.

[0030] As Figure 1 shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server cluster 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server cluster 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.

[0031] The terminal devices 101, 102, 103 interact with the server cluster 105 through the network 104 to receive or send messages, etc. Various communication client applications may be installed on the terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0032] The terminal devices 101, 102, and 103 can be hardware or software. When the terminal devices 101, 102, and 103 are hardware, they can be various electronic devices with a display screen and supporting communication, including but not limited to smartphones, tablet computers, e-book readers, laptop computers, desktop computers, and so on. When the terminal devices 101, 102, and 103 are software, they can be installed in the above-listed electronic devices. It can be implemented as multiple software or software modules (such as software or software modules for providing distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.

[0033] The server cluster 105 can be implemented as a distributed server cluster composed of multiple servers, which can include servers providing various services, such as a background web server that supports the web pages displayed on the terminal devices 101, 102, and 103. The background web server can analyze and process data such as web page requests received, and feedback the processing results (such as web page data) to the terminal devices.

[0034] It should be noted that the servers 1051, 1052, 1053, and 1054 in the above server cluster 105 can mainly interact through a distributed synchronization interface design. The above server cluster 105 can communicate with the terminal devices 101, 102, and 103 through an n-in n-out asynchronous simplex TCP long connection. The server can be hardware or software. No specific limitation is made here.

[0035] It should be noted that the method for processing data packets based on a distributed cluster provided by the embodiments of the present disclosure can be executed by the servers in the server cluster 105, or can be executed by the clients in a client cluster (not shown in the figure); correspondingly, the apparatus for processing data packets based on a distributed cluster can be set in the server or the client.

[0036] It should be understood that Figure 1 the numbers of the terminal devices, the network, and the servers in

[0037] Continue to refer to Figure 2 , which shows a flow 200 of an embodiment of the method for processing data packets based on a distributed cluster according to the present disclosure. The method for processing data packets based on a distributed cluster includes the following steps:

[0038] Step 201, receive a data packet sent by a target device.

[0039] In this embodiment, the execution subject of the method for processing data packets based on a distributed cluster (such as Figure 1Any server in the server cluster 105 shown can receive data packets sent by the target device through a wired connection or a wireless connection. Among them, the above-mentioned target device usually can include an electronic device that has a long connection with the above-mentioned distributed cluster. The above-mentioned long connection can be, for example, an n-in n-out asynchronous simplex TCP long connection.

[0040] Step 202, determine the type to which the data packet belongs.

[0041] In this embodiment, the above-mentioned execution entity can determine the type to which the data packet received in the above-mentioned step 201 belongs in various ways. Among them, the type to which the above-mentioned data packet belongs can be determined according to the actual application scenario. It can include but is not limited to at least one of the following: heartbeat packet, request packet, response packet.

[0042] In this embodiment, the above-mentioned execution entity can extract the field characterizing the type to which the data packet belongs from the above-mentioned received data packet according to different communication protocols. Then, determine the type to which the data packet belongs according to the above-mentioned extracted field.

[0043] Step 203, in response to determining that the type to which the data packet belongs is a response packet, select a matching node from the distributed cluster according to a preset mapping relationship table to process the data packet.

[0044] In this embodiment, in response to determining that the type to which the data packet belongs is a response packet, the above-mentioned execution entity can extract a return field from the above-mentioned response packet. Among them, the above-mentioned return field can be used to identify the request that the above-mentioned response packet is directed to. Then, according to the preset mapping relationship table, the above-mentioned execution entity can select the node to which the above-mentioned request belongs in the above-mentioned distributed cluster as the matching node. Among them, the above-mentioned mapping relationship table can be used to record the attribution relationship between the sent message and the nodes in the above-mentioned distributed cluster.

[0045] It should be noted that as the message is sent, the above-mentioned execution entity can also update the content in the above-mentioned mapping relationship table. Usually, the above-mentioned mapping relationship table is jointly maintained by the nodes of the above-mentioned distributed cluster.

[0046] In some optional implementation manners of this embodiment, the above-mentioned execution entity can first determine whether the data packet is a response packet corresponding to the request sent by the above-mentioned execution entity (i.e., this node) according to the above-mentioned preset mapping relationship table. In response to determining that the data packet is a response packet corresponding to the request sent by the above-mentioned execution entity, the above-mentioned execution entity can process the data packet by selecting a matching node from the distributed cluster according to the following steps:

[0047] The first step, parse the data packet to generate response data.

[0048] In these implementation manners, the above-mentioned execution entity may parse the above-mentioned data packet according to the format of the data packet, so as to obtain the above-mentioned response data. Among them, the format of the above-mentioned data packet may be, for example, TLV (tag-length-value, type-length-value).

[0049] In the second step, according to the preset correspondence table, call the thread that matches the data packet to process the response data.

[0050] In these implementation manners, according to the preset correspondence table, the above-mentioned execution entity may call the thread that matches the above-mentioned data packet to process the response data generated in the above-mentioned first step. Among them, the above-mentioned correspondence table may be used to represent the correspondence between the data sent and the threads of the above-mentioned execution entity (i.e., this node). The above-mentioned execution entity may first determine the request corresponding to the above-mentioned response data. Then, according to the above-mentioned correspondence table, the above-mentioned execution entity may determine the thread corresponding to the above-mentioned request as the above-mentioned matching thread. Then, the above-mentioned execution entity may call the above-mentioned matching thread to process the above-mentioned response data.

[0051] Optionally, the thread may enter the sleep state after sending the request packet. The above-mentioned execution entity may wake up the above-mentioned matching thread after determining the matching thread. Then, the above-mentioned matching thread may process the above-mentioned response data.

[0052] In some optional implementation manners of this embodiment, in response to determining that the above-mentioned data packet is not the response packet corresponding to the request sent by the above-mentioned execution entity (i.e., this node), the above-mentioned execution entity may forward the above-mentioned data packet to the matching node according to the above-mentioned mapping relationship table, so that the matching node processes the above-mentioned data packet. Among them, the above-mentioned matching node may be the node to which the request corresponding to the response packet recorded in the above-mentioned mapping relationship table belongs.

[0053] In some optional implementation manners of this embodiment, in response to determining that the type of the above-mentioned data packet is a request packet, the above-mentioned execution entity may continue to execute the following steps:

[0054] In the first step, parse the data packet to generate request data.

[0055] In these implementation manners, the above-mentioned execution entity may parse the above-mentioned data packet according to the format of the data packet, so as to obtain the above-mentioned request data. Among them, the format of the above-mentioned data packet may be, for example, TLV.

[0056] In the second step, call the synchronization interface to obtain the return result corresponding to the request data.

[0057] In these implementation manners, the above-mentioned execution entity may call a synchronous interface to obtain a return result corresponding to the request data generated in the above-mentioned first step. Among them, the above-mentioned synchronous interface may be used for interaction between nodes in the above-mentioned distributed cluster. Business processing data may be transmitted between nodes in the above-mentioned distributed cluster through the above-mentioned synchronous interface.

[0058] Step 3: Pack the return result into a return data packet that is consistent with the data packet format.

[0059] In these implementation manners, the above-mentioned execution entity may pack the return result obtained in the above-mentioned second step into a return data packet that is consistent with the above-mentioned data packet format (such as the TLV format) in various ways.

[0060] Step 4: Send the return data packet through a long connection.

[0061] In these implementation manners, the above-mentioned execution entity may send the return data packet generated in the above-mentioned third step through the link of the above-mentioned long connection for external communication.

[0062] Optionally, the above-mentioned execution entity may be responsible for maintaining multiple long connection links. Thus, the above-mentioned execution entity may first obtain the status of the sending link corresponding to the long connection. Among them, the above-mentioned long connection may be maintained through heartbeat packets. Then, the above-mentioned execution entity may select an idle sending link to send the above-mentioned return data packet.

[0063] Continue to refer to Figure 3 , Figure 3 is a schematic diagram of an application scenario of a data packet processing method based on a distributed cluster according to an embodiment of the present disclosure. In Figure 3 's application scenario, user 301 may send a response packet 303 to server 304-a through terminal device 302. Among them, the above-mentioned response packet 303 may include, for example, a field for identifying a corresponding request (such as "Request 1") and data (such as "1234" as a verification code). Server 304-a may determine the type of the above-mentioned response packet 303. According to the preset mapping relation table 305, the above-mentioned server 304-a may determine that this response packet is a response to a request sent by this node, and thus may continue to process the above-mentioned response packet 303 (such as performing identity verification using the verification code "1234").

[0064] Currently, one of the existing technologies usually persists the request data after the requester sends a request, resulting in a large amount of data to be stored and complex processing logic. However, the method provided by the above-mentioned embodiments of the present disclosure selects a matching node for processing by determining the type of the received data packet and a preset mapping relationship table, realizing the separation of node matching and processing logic, thereby simplifying the logical complexity. Moreover, by converting an external asynchronous connection into a synchronous service interface between nodes within the cluster, the number of data accesses is reduced, the program running efficiency is improved, and it is also easier to find and locate problems through the result log.

[0065] Further referring to Figure 4 , which shows the flow 400 of another embodiment of the data packet processing method based on a distributed cluster. The flow 400 of the data packet processing method based on a distributed cluster includes the following steps:

[0066] Step 401, obtain a request data packet to be sent.

[0067] In this embodiment, the execution entity of the data packet processing method based on a distributed cluster (such as Figure 1 the server in the server cluster 105 shown) can first obtain the request data packet to be sent through wired or wireless means. As an example, the above execution entity can obtain the request data packet sent by a thread from the local. As another example, the above execution entity can also obtain the request data packet to be sent from the synchronous interface in the above distributed cluster. Among them, the format of the above request data packet can include various formats suitable for long connections, such as TLV.

[0068] Step 402, send the request data packet through a long connection.

[0069] In this embodiment, the above execution entity can send the request data packet obtained in step 401 through the link of the long connection for communication between the above distributed cluster and the external.

[0070] In some optional implementation manners of this embodiment, the above execution entity can be responsible for maintaining multiple long connection links. Thus, the above execution entity can also first obtain the status of the sending link corresponding to the long connection. Among them, the above long connection can be maintained through heartbeat packets. Then, the above execution entity can select an idle sending link to send the above request data packet.

[0071] Step 403, update the mapping relationship table based on the request data packet and the identifier of the present node.

[0072] In this embodiment, based on the request data packet and the identifier of the above-mentioned execution entity (i.e., this node), the above-mentioned execution entity can update the mapping relationship table in various ways. Among them, the above-mentioned mapping relationship table can be used to record the attribution relationship between the sent message and the nodes in the above-mentioned distributed cluster. The above-mentioned identifier can include various forms, such as IP (Internet Protocol) address, label, string, and so on.

[0073] Step 404: Receive the data packet sent by the target device.

[0074] Step 405: Determine the type to which the data packet belongs.

[0075] Step 406: In response to determining that the type to which the data packet belongs is a response packet, select a matching node from the distributed cluster according to the preset mapping relationship table to process the data packet.

[0076] The above Step 404, Step 405, and Step 406 are respectively consistent with Step 201, Step 202, and Step 203 in the foregoing embodiment. The descriptions of Step 201, Step 202, and Step 203 above also apply to Step 404, Step 405, and Step 406, and will not be elaborated here.

[0077] From Figure 4 it can be seen that the process 400 of the data packet processing method based on the distributed cluster in this embodiment reflects the step of updating the mapping relationship table according to the sent request data packet and the identifier of this node. Thus, the solution described in this embodiment can maintain the update of the mapping relationship table, thereby providing a basis for allocating the data to be processed to each node in the distributed cluster.

[0078] Further referring to Figure 5 , as an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a data packet processing device based on a distributed cluster. This device embodiment corresponds to the Figure 2 shown method embodiment, and this device can be specifically applied to various electronic devices.

[0079] As Figure 5As shown in the figure, the packet processing device 500 based on a distributed cluster provided in this embodiment includes a receiving unit 501, a determining unit 502, and a processing unit 503. Among them, the receiving unit 501 is configured to receive a packet sent by a target device, where the target device has a long connection with the distributed cluster; the determining unit 502 is configured to determine the type to which the packet belongs; the processing unit 503 is configured to, in response to determining that the type to which the packet belongs is an acknowledgment packet, select a matching node from the distributed cluster according to a preset mapping relation table to process the packet, where the mapping relation table is used to record the attribution relationship between the sent message and the nodes in the distributed cluster.

[0080] In this embodiment, in the packet processing device 500 based on a distributed cluster: the specific processing of the receiving unit 501, the determining unit 502, and the processing unit 503 and the technical effects brought by them can respectively refer to Figure 2 the relevant descriptions of steps 201, step 202, and step 203 in the corresponding embodiment, which will not be elaborated here.

[0081] In some optional implementation manners of this embodiment, the above processing unit 503 may be further configured to: in response to determining that the packet is an acknowledgment packet corresponding to a request sent by this node, parse the packet to generate acknowledgment data; and according to a preset corresponding relation table, call a thread matching the packet to process the acknowledgment data. Wherein, the corresponding relation table may be used to represent the corresponding relationship between the sent data and the thread.

[0082] In some optional implementation manners of this embodiment, the above processing unit 503 may be further configured to, in response to determining that the packet is not an acknowledgment packet corresponding to a request sent by this node, forward the packet to a matching node according to the mapping relation table so that the matching node processes the packet.

[0083] In some optional implementation manners of this embodiment, the above packet processing device 500 based on a distributed cluster may further include: a first sending unit (not shown in the figure), configured to, in response to determining that the type to which the packet belongs is a request packet, parse the packet to generate request data; call a synchronization interface to obtain a return result corresponding to the request data, where the synchronization interface may be used for interaction between nodes in the distributed cluster; pack the return result into a return packet with the same format as the packet; and send the return packet through the long connection.

[0084] In some optional implementation manners of this embodiment, the above first sending unit may include: an obtaining module (not shown in the figure), a sending module (not shown in the figure). Among them, the above obtaining module may be configured to obtain the state of the sending link corresponding to the long connection. The above sending module may be configured to select an idle sending link to send the return packet.

[0085] In some alternative implementation manners of this embodiment, the above-mentioned data packet processing device 500 based on a distributed cluster may further include: an obtaining unit (not shown in the figure), a second sending unit (not shown in the figure), and an updating unit (not shown in the figure). Among them, the above-mentioned obtaining unit may be configured to obtain a request data packet to be sent. The above-mentioned second sending unit may be configured to send the request data packet through a long connection. The above-mentioned updating unit may be configured to update the mapping relation table based on the request data packet and the identifier of this node.

[0086] The device provided in the above embodiment of the present disclosure receives a data packet sent by a target device through the receiving unit 501. Among them, the target device has a long connection with the distributed cluster. Then, the determining unit 502 determines the type to which the data packet belongs. Finally, in response to determining that the type to which the data packet belongs is a response packet, the processing unit 503 selects a matching node from the distributed cluster according to a preset mapping relation table to process the data packet. Among them, the mapping relation table is used to record the attribution relationship between the sent message and the nodes in the distributed cluster. Thereby, the separation of node matching and processing logic is realized, thereby simplifying the logical complexity. Moreover, by converting an external asynchronous connection into a synchronous service interface between nodes inside the cluster, the number of data accesses is reduced, the program running efficiency is improved, and it is also easier to find and locate problems through the result log.

[0087] The following refers to Figure 6 , which shows a schematic structural diagram of an electronic device (such as the server in Figure 1 ) 600 suitable for implementing the embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Tablet Computers), PMPs (Portable Multimedia Players), etc. and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The server shown is only an example and should not bring any limitation to the functions and usage scopes of the embodiments of the present disclosure.

[0088] As Figure 6 shown, the electronic device 600 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which may perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0089] Typically, the following devices can be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 can allow the electronic device 600 to communicate with other devices wirelessly or wiredly to exchange data. Although Figure 6 the electronic device 600 with various devices is shown, it should be understood that it is not required to implement or have all the shown devices. Instead, more or fewer devices can be implemented or had. Figure 6 Each block shown in

[0090] Specifically, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program codes for performing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above functions defined in the method of the embodiment of the present disclosure are executed.

[0091] It should be noted that the computer-readable medium described in the embodiments of the present disclosure can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the embodiments of the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, apparatus, or device. In the embodiments of the present disclosure, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and this computer-readable signal medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted by any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0092] The above computer-readable medium can be included in the above electronic device; or it can exist separately and not be assembled into the electronic device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by the electronic device, the electronic device: receives a data packet sent by a target device, where the target device has a long connection with the distributed cluster; determines the type to which the data packet belongs; in response to determining that the type to which the data packet belongs is an acknowledgment packet, selects a matching node from the distributed cluster according to a preset mapping relationship table to process the data packet, where the mapping relationship table is used to record the attribution relationship between the sent message and the nodes in the distributed cluster.

[0093] Computer program code for performing the operations of the embodiments of the present disclosure may be written in one or more programming languages or combinations thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and also including conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0094] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations 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 diagram may represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system that performs the specified functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.

[0095] The units involved in the embodiments described in the present disclosure may be implemented in software or in hardware. The described units may also be provided in a processor. For example, it may be described as a processor including a receiving unit, a determining unit, and a processing unit. Among them, the names of these units do not constitute a limitation to the unit itself in some cases. For example, the receiving unit may also be described as "a unit that receives data packets sent by a target device, where the target device has a long connection with the distributed cluster".

[0096] The above description is only a preferred embodiment of the present disclosure and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above inventive concept. For example, the technical solutions formed by mutually replacing the above features with the technical features (but not limited to) disclosed in the embodiments of the present disclosure that have similar functions.

Claims

1. A method for processing data packets based on a distributed cluster, comprising: Receive data packets sent by the target device, where the target device has a long connection with the distributed cluster; Determine the type to which the data packet belongs, where the types to which the data packet belongs include response packets and request packets; In response to determining that the type to which the data packet belongs is a response packet, extract a return field from the data packet, where the return field is used to identify the request that the data packet targets; Select, from the distributed cluster, the node to which the request belongs as the matching node according to a preset mapping relation table to process the data packet, where the mapping relation table is used to record the belonging relationship between the sent message and the nodes in the distributed cluster.

2. The method according to claim 1, wherein, The processing of selecting a matching node from the distributed cluster according to a preset mapping relation table to process the data packet includes: In response to determining that the data packet is a response packet corresponding to a request sent by the local node, parse the data packet to generate response data; and according to a preset corresponding relation table, call a thread matching the data packet to process the response data, where the corresponding relation table is used to represent the corresponding relationship between the sent data and the thread.

3. The method according to claim 1, wherein, The processing of selecting a matching node from the distributed cluster according to a preset mapping relation table to process the data packet includes: In response to determining that the data packet is not a response packet corresponding to a request sent by the local node, forward the data packet to a matching node according to the mapping relation table so that the matching node processes the data packet.

4. The method according to claim 1, wherein, The method further includes: In response to determining that the type to which the data packet belongs is a request packet, parse the data packet to generate request data; call a synchronization interface to obtain a return result corresponding to the request data, where the synchronization interface is used for interaction between nodes in the distributed cluster; pack the return result into a return data packet with the same format as the data packet; and send the return data packet through the long connection.

5. The method according to claim 4, wherein, The sending of the return data packet through the long connection includes: Obtain the status of the sending link corresponding to the long connection; Select an idle sending link to send the return data packet.

6. The method according to any one of claims 1-5, wherein, The method further includes: Obtain a request data packet to be sent; Send the request data packet through the long connection; Update the mapping relation table based on the request data packet and the identifier of the local node.

7. A data packet processing apparatus based on a distributed cluster, comprising: A receiving unit, configured to receive data packets sent by the target device, where the target device has a long connection with the distributed cluster; A determining unit, configured to determine the type to which the data packet belongs, where the types to which the data packet belongs include response packets and request packets; A processing unit, configured to, in response to determining that the type to which the data packet belongs is a response packet, extract a return field from the data packet, where the return field is used to identify the request that the data packet targets; select, from the distributed cluster, the node to which the request belongs as the matching node according to a preset mapping relation table to process the data packet, where the mapping relation table is used to record the belonging relationship between the sent message and the nodes in the distributed cluster.

8. The apparatus according to claim 7, wherein, The apparatus further includes: A sending unit, configured to, in response to determining that the type to which the data packet belongs is a request packet, parse the data packet to generate request data; call a synchronization interface to obtain a return result corresponding to the request data, where the synchronization interface is used for interaction between nodes in the distributed cluster; pack the return result into a return data packet having the same format as the data packet; and send the return data packet through a long connection.

9. An electronic device, comprising: One or more processors; A storage device having stored thereon one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1-6.

10. A computer-readable medium having a computer program stored thereon, wherein, When the program is executed by a processor, the method according to any one of claims 1-6 is implemented.

Citation Information

Patent Citations

  • GIS application method based on distributive memory database

    CN108073696A

  • Data processing method and device

    CN110245014A