Processing strategy execution method, device, electronic device, medium and program product
By utilizing the CLC and SMC socket state change mechanisms of SMCR technology in the RDMA network, the data loss problem caused by the host-to-host primary and backup network card switching perception delay is solved, and fast response and data transmission stability are achieved.
Patent Information
- Application Number
- CN202510957230.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-11
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2045-07-11
AI Technical Summary
In a Remote Direct Memory Access (RDMA) network, there is a delay in the host's perception of the peer host's primary and backup network adapter switching, resulting in data loss.
By changing the state of the first type of socket after receiving the first message and triggering the state change of the second type of socket, the application is notified to execute the corresponding processing strategy for the master-slave switching, and the CLC and SMC sockets created by SMCR technology are used to achieve rapid perception and response.
This avoids the perceived delay of upper-layer applications, avoids data loss, and improves the communication robustness and efficiency of the RDMA network.
Smart Images

Figure CN120455254B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network communication technology, and in particular to a method, device, electronic device, medium, and program product for executing a processing strategy. Background Art
[0002] Remote Direct Memory Access (RDMA) networking is a high-performance network technology that enables remote direct memory access, thereby improving network transmission efficiency. In RDMA networks, active / standby failover occurs when the primary network interface card (NIC) in an environment fails, and the standby NIC takes over its functions to ensure high system availability. However, current RDMA network active / standby failover methods have several issues, such as long failover times and data loss. Specifically, during an active / standby failover, a host in an RDMA network sends a Transmission Control Protocol Reset Segment (TCP) RST (Reset) message to the peer host. However, this RST message is not communicated to the upper-layer applications on the peer host. Consequently, the peer host's applications cannot detect the link disconnection until the connection with the host that sent the RST message times out. This results in delays and data loss during active / standby failover.
[0003] Regarding the related technology, in the Remote Direct Memory Access (RDMA) network, there is a delay in the host's perception of the switching of the primary and backup network cards of the other host, which easily leads to data loss and has not yet been effectively solved. Summary of the Invention
[0004] The present application provides a method, device, electronic device, medium and program product for executing a processing strategy to at least solve the problem in the related art of remote direct memory access (RDMA) network, in which the host has a delay in perceiving the switching of the primary and backup network cards of the other host, which easily leads to data loss.
[0005] The present application provides a method for executing a processing strategy, which is applied to a network cluster including at least two hosts, each host in the network cluster is deployed with a target network card, including: changing a first state corresponding to the first type of socket according to a received first message through a first type of socket, wherein the first type of socket is a socket in the first host of the at least two hosts for establishing a communication link, and the first message is a message sent by the second host of the at least two hosts when executing the master-slave switching of the target network card; triggering a state change of the second type of socket of the first host through the changed first state to notify an application on the first host to execute the processing strategy corresponding to the master-slave switching, wherein the second type of socket is a socket in the first host for transmitting a second message carrying communication data.
[0006] The present application also provides an execution device for a processing strategy, which is applied to a network cluster including at least two hosts, each host in the network cluster is deployed with a target network card, including: a change module, used to change a first state corresponding to the first type of socket according to a received first message through a first type of socket, wherein the first type of socket is a socket in the first host of the at least two hosts for establishing a communication link, and the first message is a message sent by the second host of the at least two hosts when executing the master-slave switching of the target network card; a trigger module, used to trigger a state change of the second type of socket of the first host through the changed first state, so as to notify an application on the first host to execute the processing strategy corresponding to the master-slave switching, wherein the second type of socket is a socket in the first host for transmitting a second message carrying communication data.
[0007] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of the execution method of any of the above-mentioned processing strategies when executing the computer program.
[0008] The present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of the execution method of any of the above-mentioned processing strategies are implemented.
[0009] The present application also provides a computer program product, including a computer program, which implements the steps of the execution method of any of the above-mentioned processing strategies when the computer program is executed by a processor.
[0010] According to the present application, in a network cluster including at least two hosts, each host in the network cluster is deployed with a target network card. A first type socket in a first host of the at least two hosts is used to change the first state corresponding to the first type socket according to a received first message, wherein the first type socket is a socket in the first host used to establish a communication link, and the first message is a message sent by the second host of the at least two hosts when performing a master-slave switch of the target network card; the changed first state triggers a state change of the second type socket of the first host to notify the application on the first host to execute a processing strategy corresponding to the master-slave switch, wherein the second type socket is a socket in the first host used to transmit a second message carrying communication data. Therefore, the technical problem in the related art that in a remote direct memory access (RDMA) network, the host's perception of the master-slave network card switch of the other host is delayed, which easily leads to data loss, can be solved. Thus, the first state of the first type socket, which changes after receiving the first message, triggers the state change of the second type socket, so that the application can quickly perceive the master-slave switch of the second host and thus execute the corresponding processing strategy. That is to say, through this application, the technical effect of avoiding the perceived delay of the upper-layer application of the first host and thus avoiding data loss is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0012] Figure 1 This is a hardware structure block diagram of a computer terminal for a method for executing a processing strategy according to an embodiment of the present application;
[0013] Figure 2 is a flowchart of a method for executing a processing strategy according to an embodiment of the present application;
[0014] Figure 3 1 is a schematic diagram of the SMCR establishment process according to an embodiment of the present application;
[0015] Figure 4 is a schematic diagram of sock association processing according to an embodiment of the present application;
[0016] Figure 5 It is a structural block diagram of a device for executing a processing strategy according to an embodiment of the present application. DETAILED DESCRIPTION
[0017] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0018] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.
[0019] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0020] In conjunction with the specific application environment architecture or specific hardware architecture on which the execution of the execution method of the processing strategy depends, the specific application environment architecture or specific hardware architecture is described here.
[0021] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a computer terminal as an example, Figure 1 This is a hardware structure block diagram of a computer terminal for executing a processing strategy according to an embodiment of the present application. Figure 1 As shown, the computer terminal may include one or more ( Figure 1 Only one is shown) a processor 102 (the processor 102 may include but is not limited to a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. The computer terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above-mentioned computer terminal. For example, the computer terminal may also include Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.
[0022] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the execution method of the processing strategy in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implementing the above-mentioned method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely located relative to the processor 102, and these remote memories can be connected to the computer terminal via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0023] Transmission device 106 is used to receive or transmit data via a network. A specific example of the aforementioned network may include a wireless network provided by a computer terminal's communications provider. In one embodiment, transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0024] Figure 2 This is a flow chart of a method for executing a processing strategy according to an embodiment of the present application, which is applied to a network cluster comprising at least two hosts, each of which is equipped with a target network card. Figure 2 As shown, the process includes the following steps:
[0025] Step S202: Changing, through a first type socket, a first state corresponding to the first type socket according to a received first message, wherein the first type socket is a socket used to establish a communication link in a first host among the at least two hosts, and the first message is a message sent by a second host among the at least two hosts when performing active / standby switching of the target network adapter;
[0026] It should be noted that the network cluster may be a Software Defined Networking (SDN) network cluster, the target network card is an RDMA network card, and the master / slave switching of the target network card is performed between the master RDMA network card and the backup RDMA network card on the second host. The first message is an RST message.
[0027] Step S204, triggering the state change of the second type socket of the first host through the changed first state to notify the application on the first host to execute the processing strategy corresponding to the master-slave switching, wherein the second type socket is a socket in the first host used to transmit the second message carrying communication data.
[0028] The first type of socket and the second type of socket are related to the Shared Memory Communication over RDMA (SMCR) technology.
[0029] SMCR technology allows applications to utilize the underlying Remote Direct Memory Access (RDMA over Converged Ethernet, RoCE) network without modification, requiring only the protocol used. SMCR significantly improves RoCE network availability. SMCR actually creates two sockets: a Shared Memory Communication (SMC) socket and a Connection-less Communication (CLC) socket. The first type of socket is a CLC socket, and the second type is an SMC socket. The CLC socket is responsible for link establishment, while the SMC socket is responsible for message transmission.
[0030] Through the above steps, in a network cluster including at least two hosts, each host in the network cluster is deployed with a target network card, and a first type socket in a first host of the at least two hosts is used to change the first state corresponding to the first type socket according to a received first message, wherein the first type socket is a socket in the first host used to establish a communication link, and the first message is a message sent by the second host of the at least two hosts when performing a master-slave switch of the target network card; the changed first state triggers a state change of the second type socket of the first host to notify the application on the first host to execute the processing strategy corresponding to the master-slave switch, wherein the second type socket is a socket in the first host used to transmit a second message carrying communication data. Therefore, the technical problem in the related art that in a remote direct memory access (RDMA) network, the host's perception of the master-slave network card switch of the other host is delayed, which easily leads to data loss, can be solved. Therefore, the first state of the first type socket, which changes after receiving the first message, triggers the state change of the second type socket, so that the application can quickly perceive the master-slave switch of the second host and thus execute the corresponding processing strategy. That is to say, through this application, the technical effect of avoiding the perceived delay of the upper-layer application of the first host and thus avoiding data loss is achieved.
[0031] The embodiments of the present application provide a method for executing a processing strategy, and the method is described in detail in conjunction with the execution flow of the method for executing the processing strategy.
[0032] In an exemplary embodiment, changing the first state corresponding to the first type of socket according to the received first message through the first type of socket includes: receiving a third message sent by the second host through the first type of socket; determining that the third message is the first message when a preset flag bit in the message header of the third message is a target value; and changing the first state of the first type of socket to a closed state according to the first message.
[0033] When the CLC socket receives the third packet, it first checks the TCP header of the third packet. The RST packet has a specific flag set in the TCP header. Specifically, the RST flag (equivalent to the preset flag) is set to 1 (equivalent to the target value).
[0034] Furthermore, the first state of the first type of socket is changed to a closed state according to the first message, including: parsing the first identifier of the second host carried in the first message, and determining the second identifier corresponding to the first type of socket; when the first identifier and the second identifier are consistent, the first state of the first type of socket is changed to a closed state.
[0035] The RST message carries the second host's first identifier. The first host compares this identifier with the peer identifier (the "second identifier") stored in the CLC socket. When these two identifiers match, the received RST message is confirmed to have originated from the intended peer host. Based on the identifier match, the CLC socket's state changes from active to closed. Once the CLC socket changes to closed, it indicates that the underlying communication link is unavailable, requiring further action, such as notifying the SMC socket for a status update to alert applications to the change in network connectivity.
[0036] Through the above solution, the system can accurately identify RST messages from specific peer hosts and make corresponding state change operations, thereby ensuring rapid response and correct processing in the event of active-standby switchover or network failure, reducing application waiting timeouts or unnecessary data packet loss, and improving the robustness and efficiency of the entire RDMA network communication.
[0037] In an exemplary embodiment, the state change of the second type socket of the first host is triggered by the changed first state to notify the application on the first host to execute the processing strategy corresponding to the active-standby switching, including: determining whether the changed first state is a closed state through the first state change function corresponding to the first type socket; when the changed first state is a closed state, triggering the state change of the second type socket through the first state change function to notify the application on the first host to execute the processing strategy corresponding to the active-standby switching.
[0038] Furthermore, the state change of the second type of socket is triggered through the first state change function to notify the application on the first host to execute the processing strategy corresponding to the active-standby switching, including: calling the second state change function corresponding to the second type of socket through the first state change function to change the second state of the second type of socket to a closed state through the second state change function, and notifying the application to execute the processing strategy corresponding to the active-standby switching, wherein the second state change function has been injected into the first state change function when the first type of socket is initialized.
[0039] That is, in this application, when a specific change occurs in the state of the first type of socket (CLC socket), it can further trigger a state change of the second type of socket (SMC socket), thereby notifying the upper-layer application to execute the active-standby switching processing strategy.
[0040] Specifically, when the CLC socket is initialized, the second state change function corresponding to the SMC socket is pre-injected into the first state change function corresponding to the CLC socket. This dependency ensures that when the CLC socket state changes, the SMC socket state can be linked.
[0041] The CLC socket's first state change function continuously monitors the CLC socket's status. When the CLC socket's state changes to closed after receiving and processing an RST message, the system immediately calls the injected SMC socket's state change function, changing the SMC socket's state to closed as well, triggering a response at the application level.
[0042] The SMC socket shutdown notification allows the application to detect abnormal network connection status. The application then executes a pre-defined active / standby failover strategy, such as reestablishing the connection or attempting to communicate using the standby network interface.
[0043] The key to this is the linkage between state change functions. When the CLC socket becomes closed due to receiving an RST message, the pre-established function dependency automatically triggers a change in the SMC socket state, without requiring additional detection or intervention by the application. This approach not only simplifies application design but also ensures rapid adjustment of communication strategies in the event of a primary / backup switchover or network failure, avoiding data loss and prolonged service interruptions, thereby enhancing overall system robustness and user experience.
[0044] Optionally, notifying the application to execute the processing strategy corresponding to the active-standby switching includes: notifying the application of target information through the second state change function so that the application executes the processing strategy corresponding to the active-standby switching, wherein the target information includes: the second state of the second type of socket is changed to a closed state; and / or the application perceives the target information through polling and executes the processing strategy corresponding to the active-standby switching.
[0045] In other words, the methods for notifying applications to execute the corresponding active / standby switchover strategy include: 1) an event-driven notification mechanism, where the second state change function corresponding to the second type of socket is responsible for sending target information to the application. The target information can be delivered to the application through semaphores, events, callback functions, etc. 2) the application autonomously perceives the target information through a polling mechanism.
[0046] Whether detecting state changes through event-driven notification mechanisms or polling, the ultimate goal is to ensure that applications can promptly and accurately execute the corresponding active / standby failover strategies to address network changes and maintain high system availability and service continuity. This application notification solution leverages the characteristics of RDMA networks. Through refined socket state management and immediate feedback, it enables rapid response and handling of network failures. This has important practical implications for modern data centers, cloud computing environments, and high-performance computing applications that rely on high-bandwidth, low-latency communications.
[0047] In an exemplary embodiment, a state change of the second type socket of the first host is triggered by the changed first state to notify the application on the first host to execute the processing strategy corresponding to the master-slave switching, including: triggering a state change of the second type socket by the changed first state to notify the application to close the application; or triggering a state change of the second type socket by the changed first state to notify the application to re-initiate a connection to the second host.
[0048] In an exemplary embodiment, after triggering the state change of the second type socket by the changed first state to notify the application to re-initiate the connection to the second host, the method also includes: recreating the first type socket and the second type socket through the application; sending a connection request to the second host through the recreated first type socket; when the application monitors that the recreated first type socket enters the connection state with the second host, injecting the third state change function corresponding to the recreated second type socket into the fourth state change function, and transmitting a fourth message carrying communication data with the second host through the recreated second type socket, wherein the fourth state change function is the state change function corresponding to the recreated first type socket.
[0049] That is to say, this application recreates and configures the CLC socket and SMC socket, and re-establishes the linkage relationship between the state change functions, so that the network recovery after the master-slave switch can be carried out quickly and automatically, ensuring service continuity and data transmission efficiency.
[0050] In an exemplary embodiment, before transmitting the fourth message carrying communication data with the second host through the re-created second type socket, the method also includes: sending a test data packet to the second host through the re-created second type socket; determining that the application allows the resumption of communication with the second host if the first timeout period is not exceeded and a confirmation message based on the test data packet is received from the second host; and determining that the application does not allow the resumption of communication with the second host if the first timeout period is exceeded or the confirmation message based on the test data packet is not received from the second host.
[0051] Optionally, before re-transmitting the fourth message to the second host based on the re-created first type socket and the re-created second type socket, it can be verified by sending a test data packet that communication can indeed be achieved again between the first host and the second host.
[0052] In an exemplary embodiment, after triggering the state change of the second type socket of the first host by the changed first state to notify the application on the first host to execute the processing strategy corresponding to the active-standby switching, the method further includes: determining the response time of the application to the active-standby switching by the first timestamp and the second timestamp included in the first message, wherein the second timestamp is the timestamp when the application executes the processing strategy; updating the second timeout time by the response time, wherein the second timeout time is the timeout time that the application is allowed to execute the processing strategy when the changed first state cannot trigger the state change of the second type socket.
[0053] Among them, updating the second timeout time according to the response time includes: obtaining the response time fed back by at least one host in the network cluster; determining the average response time corresponding to at least one of the response times; and updating the second timeout time according to the average response time.
[0054] In the RDMA network fast master / slave switchover method, optimizing the application's response time to master / slave switchover is key to improving overall system efficiency and reliability. By monitoring and analyzing the application's response time to master / slave switchover, the timeout policy can be dynamically adjusted to reduce unnecessary waiting and improve fault recovery speed. The specific process includes:
[0055] The first timestamp records the moment when the first-type socket (i.e., the CLC socket) receives an RST packet and triggers a state change to the closed state. The second timestamp records the moment when the application executes the active / standby switchover strategy (e.g., reestablishing a connection). The difference between the second timestamp and the first timestamp yields the application's response time to the active / standby switchover.
[0056] The application or system management module collects response time data from all hosts in the network cluster. Statistical analysis (such as averaging or median calculations) is used to determine the average response time for the entire cluster. This step ensures that timeout settings are more closely aligned with actual performance. The second timeout is then updated based on the calculated average response time. This second timeout is the maximum amount of time the application will wait to execute its processing policy if a CLC socket status change fails to trigger an SMC socket status change in a timely manner.
[0057] Through the above steps, this application can dynamically adjust the timeout period based on the actual response time, thereby reducing unnecessary waiting time and accelerating the fault recovery process. This ensures that even under poor network conditions, reasonable timeout settings can prevent applications from being unresponsive for extended periods, improving service continuity and user experience. Furthermore, through more precise timeout control, resources can be prevented from being occupied in ineffective waiting, improving the overall resource utilization efficiency of the system.
[0058] In order to better understand the process of executing the above-mentioned processing strategy, the implementation process of the above-mentioned processing strategy execution method is described below in combination with an optional embodiment, but it is not used to limit the technical solution of the embodiment of this application.
[0059] With the advancement of network technology, RDMA networks have become increasingly widely used, for example in cloud computing, data centers, and supercomputing. However, master-slave switching in RDMA networks remains a challenge. If the underlying hosts in a network cluster use a master-slave binding mode, during a master-slave switchover, the host at the master-slave switching end (equivalent to the second host in the above embodiment) sends a TCP RST packet to the other host (equivalent to the first host in the above embodiment) via a CLC socket. The CLC socket on the other end receives the RST packet, but the CLC socket fails to promptly notify the SMC socket of the RST packet. Consequently, applications cannot detect the link disconnection until the SMC connection times out. This leads to latency and data loss during master-slave switchover. Therefore, a fast RDMA master-slave switchover method is needed to address these issues. This method also needs to consider factors such as network reliability, real-time performance, and security. Furthermore, data consistency and integrity must be ensured during the switchover process.
[0060] To address the above-mentioned issues, the present application proposes a method for fast RDMA master-slave switching (equivalent to the execution method of the processing strategy in the above-mentioned embodiment). When one or more cloud hosts (hereinafter referred to as hosts) switch between master and standby, the peer hosts connected to the cloud hosts can quickly perceive the connection status change and respond in a timely manner. This greatly reduces the network latency and data packet loss of the RDMA network during network failures or master-slave switching, which is of great significance to existing services that use RDMA networks for communication.
[0061] In order to realize the RDMA fast master-slave switching method, combined with Figure 3 , the embodiment of the present application first describes the establishment process of SMCR.
[0062] In the existing SMCR connection, CLC sock (socket is referred to as sock) is established through interaction. Figure 3 The underlying data link shown in the figure, after the link is established, the application in the host can perform RDMA communication through the data link, and the data passes through Figure 3 Communicates through the upper network port of the network card shown in the figure. If the upper network port of the network card of host A (equivalent to the second host in the above embodiment) fails, host A will perform a master-slave switch. During the master-slave switch, the switch action will eliminate the SMCR connection resources on host A and send a RST message to host B (equivalent to the first host in the above embodiment) via host A's CLC socket. This RST message is then received by host B's CLC socket (equivalent to the first type of socket in the above embodiment), but no special processing is performed upon receipt. Host B will wait until the SMCR connection times out, typically for 30 seconds (equivalent to the second timeout period in the above embodiment). While waiting for host A to complete the master-slave switch, host B cannot send any data packets to host A. To address the above drawbacks, this application proposes a method for fast RDMA master-slave switch. This method encapsulates the state-change callback interface of the host's CLC socket, first calling the SMC socket callback interface, and then modifying the SMC socket state, thereby achieving fast master-slave switch.
[0063] The basic concept of the RDMA fast active / standby switching method in the embodiment of the present application is:
[0064] 1) During a master / slave switchover, the SMCR sends an RST message to the peer host via the CLC socket. Upon receiving the RST message, the peer host modifies the state of the CLC socket on the peer host (i.e., the first state in the above embodiment).
[0065] 2) When the state of the CLC socket of the opposite host is changed, the state of the SMC socket of the opposite host is also modified, so that the state of the SMC socket (i.e., the second state in the above embodiment) also enters the closed state;
[0066] 3) When the SMC socket status changes, the status change flag needs to be modified in a timely manner so that the host application on the other end can perceive the status change in a timely manner;
[0067] 4) For the application on the peer host, the application should poll the status changes of the underlying SMC socket. When it senses that the status of the underlying SMC socket has changed to the closed state, it needs to close the application in time or re-initiate the connection.
[0068] The difficulty with this basic concept lies in how to promptly notify the SMC socket when the CLC socket's status changes. Essentially, the states of the two sockets are not directly related.
[0069] When the RDMA fast active-standby switching method in the embodiment of the present application is implemented at the bottom layer, the state change of the SMC socket is associated with the CLC socket.
[0070] like Figure 4 As shown, the SMC creates two sockets. When the CLC socket is initialized, the present application injects the state change function of the SMC socket (equivalent to the second state change function in the above embodiment) into the state change function of the CLC socket (equivalent to the first state change function in the above embodiment). When the state of the CLC socket changes, it can be decided whether to notify the SMC socket based on the different states of the CLC socket.
[0071] In this application, if a host (i.e., the second host) undergoes a master-slave switch, it will send an RST message to the other end. After the CLC socket of the opposite host receives the RST message, it will modify the state of the CLC socket to the closed state. At this time, the state change function of the CLC socket is called. In this function, if it is found that the state of the CLC socket has changed to the closed state, then the state change function of the SMC socket, which is pre-injected into the state change function of the CLC socket, will be used to modify the state of the SMC socket to the closed state. Then, the state change interface of the SMC socket is called, and then the SMCsocket application will perceive the state change, and through polling, it will perceive that the state of the SMC socket is closed, thereby initiating a new connection or taking other actions. This avoids waiting for a long time for connection timeout processing, greatly reduces the delay of the state change processing flow, and improves the system's fast processing capability.
[0072] The application scenario of the embodiment of the present application is generally an SDN cluster, and the hosts in the cluster need to have RDMA network cards. The steps of implementing the RDMA fast master-slave switching method in the SDN cluster include:
[0073] Step 1: Deploy an SDN network cluster. The cluster needs to have multiple hosts, each of which has an RDMA network card.
[0074] Step 2: The application on the host uses SMCR for RDMA communication, and the application polls the status of the SMC socket in real time;
[0075] Step 3: The application starts and sends and receives messages normally between multiple hosts;
[0076] Step 4: One or more hosts switch to a primary / secondary state. The switched host sends an RST message to the connected peer host.
[0077] Step 5: After receiving the RST message, the peer host can promptly notify the application;
[0078] Step 6: After the application on the peer host senses the SMC socket status change, it can initiate a reconnection or disconnection in a timely manner.
[0079] In summary, the embodiments of the present application propose a method for fast master-slave switching of an RDMA network, which achieves fast master-slave switching by encapsulating the state-change callback interface of the CLC socket and modifying the state of the SMC socket. This greatly reduces the network delay and data packet loss of the RDMA network during network failure or master-slave switching, which is of great significance to existing services that use RDMA networks for communication.
[0080] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.
[0081] This embodiment also provides a device for executing a processing strategy, which is used to implement the above-mentioned embodiments and preferred embodiments. Details already described will not be repeated here. As used below, the term "module" may refer to a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation using hardware, or a combination of software and hardware, is also possible and contemplated.
[0082] Figure 5 is a structural block diagram of an execution device for a processing strategy according to an embodiment of the present application, such as Figure 5 As shown, the device is applied to a network cluster including at least two hosts, each host in the network cluster is deployed with a target network card, and the device includes:
[0083] a changing module 52, configured to change, through a first type socket, a first state corresponding to the first type socket according to a received first message, wherein the first type socket is a socket used by a first host among the at least two hosts to establish a communication link, and the first message is a message sent by a second host among the at least two hosts when performing active / standby switching of the target network adapter;
[0084] The trigger module 54 is used to trigger the state change of the second type socket of the first host through the changed first state, so as to notify the application on the first host to execute the processing strategy corresponding to the master-slave switching, wherein the second type socket is a socket in the first host used to transmit the second message carrying communication data.
[0085] Through the above-mentioned device, in a network cluster including at least two hosts, each host in the network cluster is deployed with a target network card, and a first type socket in a first host of the at least two hosts is used to change the first state corresponding to the first type socket according to a received first message, wherein the first type socket is a socket in the first host used to establish a communication link, and the first message is a message sent by the second host of the at least two hosts when performing a master-slave switch of the target network card; the changed first state triggers a state change of the second type socket of the first host to notify the application on the first host to execute the processing strategy corresponding to the master-slave switch, wherein the second type socket is a socket in the first host used to transmit a second message carrying communication data. Therefore, it can solve the technical problem in the related art that in a remote direct memory access (RDMA) network, the host has a delay in perceiving the master-slave network card switch of the other host, which easily leads to data loss. Therefore, the first state of the first type socket, which changes after receiving the first message, triggers the state change of the second type socket, so that the application can quickly perceive the master-slave switch of the second host and thus execute the corresponding processing strategy. That is to say, through this application, the technical effect of avoiding the perceived delay of the upper-layer application of the first host and thus avoiding data loss is achieved.
[0086] In an exemplary embodiment, the change module 52 is also used to: receive a third message sent by the second host through the first type socket; determine that the third message is the first message when the preset flag bit in the message header of the third message is the target value; and change the first state of the first type socket to a closed state according to the first message.
[0087] In an exemplary embodiment, the change module 52 is also used to: parse out the first identifier of the second host carried in the first message, and determine the second identifier corresponding to the first type of socket; when the first identifier and the second identifier are consistent, change the first state of the first type of socket to a closed state.
[0088] In an exemplary embodiment, the trigger module 54 is also used to: determine whether the changed first state is a closed state through the first state change function corresponding to the first type of socket; when the changed first state is a closed state, trigger the state change of the second type of socket through the first state change function to notify the application on the first host to execute the processing strategy corresponding to the master-slave switching.
[0089] In an exemplary embodiment, the trigger module 54 is also used to: call the second state change function corresponding to the second type of socket through the first state change function, so as to change the second state of the second type of socket to a closed state through the second state change function, and notify the application to execute the processing strategy corresponding to the master-slave switching, wherein the second state change function has been injected into the first state change function when the first type of socket is initialized.
[0090] In an exemplary embodiment, the trigger module 54 is also used to: notify the application of target information through the second state change function, so that the application executes the processing strategy corresponding to the active-standby switching, wherein the target information includes: the second state of the second type of socket is changed to a closed state; and / or the application perceives the target information through polling and executes the processing strategy corresponding to the active-standby switching.
[0091] In an exemplary embodiment, the trigger module 54 is further used to: trigger a state change of the second type socket through the changed first state to notify the application to close the application; or trigger a state change of the second type socket through the changed first state to notify the application to re-initiate a connection to the second host.
[0092] In an exemplary embodiment, after triggering the state change of the second type socket by the changed first state to notify the application to re-initiate the connection to the second host, the device also includes a reconnection module, which is used to: recreate the first type socket and the second type socket through the application; send a connection request to the second host through the recreated first type socket; when the application monitors that the recreated first type socket enters the connection state with the second host, inject the third state change function corresponding to the recreated second type socket into the fourth state change function, and transmit the fourth message carrying communication data with the second host through the recreated second type socket, wherein the fourth state change function is the state change function corresponding to the recreated first type socket.
[0093] In an exemplary embodiment, before transmitting the fourth message carrying communication data with the second host through the re-created second type socket, the device also includes a testing module, which is used to: send a test data packet to the second host through the re-created second type socket; determine that the application allows the resumption of communication with the second host if the first timeout period is not exceeded and a confirmation message based on the test data packet is received from the second host; and determine that the application does not allow the resumption of communication with the second host if the first timeout period is exceeded or the confirmation message based on the test data packet is not received from the second host.
[0094] In an exemplary embodiment, after triggering the state change of the second type socket of the first host by the changed first state to notify the application on the first host to execute the processing strategy corresponding to the active-standby switching, the device also includes an update module for: determining the response time of the application to the active-standby switching by the first timestamp and second timestamp included in the first message, wherein the second timestamp is the timestamp when the application executes the processing strategy; updating the second timeout time by the response time, wherein the second timeout time is the timeout time that the application is allowed to execute the processing strategy when the changed first state cannot trigger the state change of the second type socket.
[0095] In an exemplary embodiment, the update module is further used to: obtain the response time fed back by at least one host in the network cluster; determine an average response time corresponding to at least one of the response times; and update the second timeout time according to the average response time.
[0096] For the description of the features in the embodiment corresponding to the execution device of the processing strategy, please refer to the relevant description of the embodiment corresponding to the execution method of the processing strategy, and no further details will be given here.
[0097] An embodiment of the present application further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in the embodiment of the execution method of any of the above-mentioned processing strategies.
[0098] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of the execution method embodiment of any of the above-mentioned processing strategies when running.
[0099] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0100] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in the embodiment of the execution method of any of the above-mentioned processing strategies are implemented.
[0101] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the execution method embodiment of any of the above-mentioned processing strategies are implemented.
[0102] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0103] The above is a detailed introduction to the execution of a processing strategy provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only intended to help understand the method and core ideas of the present application. It should be pointed out that, for those skilled in the art, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
Claims
1. A method for executing a processing strategy, characterized in that: Applied to a network cluster comprising at least two hosts, each host in the network cluster being deployed with a target network card, including: Changing, by a first-type socket, a first state corresponding to the first-type socket according to a received first message, wherein the first-type socket is a socket used to establish a communication link in a first host among the at least two hosts, and the first message is a message sent by a second host among the at least two hosts when performing active / standby switching of the target network adapter; Triggering a state change of the second type socket of the first host through the changed first state to notify the application on the first host to execute the processing strategy corresponding to the active-standby switching, including: determining whether the changed first state is a closed state through a first state change function corresponding to the first type socket, wherein the second type socket is a socket in the first host for transmitting a second message carrying communication data, wherein, When the changed first state is the closed state, triggering a state change of the second type socket by using the first state change function to notify the application on the first host to execute a processing strategy corresponding to the active / standby switching includes: The second state change function corresponding to the second type of socket is called through the first state change function to change the second state of the second type of socket to a closed state through the second state change function, and the application is notified to execute the processing strategy corresponding to the master-slave switching, wherein the second state change function has been injected into the first state change function when the first type of socket is initialized.
2. The method for executing a processing strategy according to claim 1, wherein: Changing, through the first type socket, a first state corresponding to the first type socket according to the received first message, includes: receiving, through the first type socket, a third message sent by the second host; When the preset flag bit in the message header of the third message is a target value, determining that the third message is the first message; The first state of the first type socket is changed to a closed state according to the first message.
3. The method for executing a processing strategy according to claim 2, wherein: Changing the first state of the first type socket to a closed state according to the first message includes: Parsing the first identifier of the second host carried in the first message, and determining a second identifier corresponding to the first type of socket; When the first identifier and the second identifier are consistent, the first state of the first type socket is changed to a closed state.
4. The method for executing a processing strategy according to claim 1, wherein: Notifying the application to execute a processing strategy corresponding to the active / standby switchover includes: Notifying the application of target information through the second state change function so that the application executes the processing strategy corresponding to the active-standby switching, wherein the target information includes: the second state of the second type socket is changed to a closed state; and / or The target information is perceived by the application program in a polling manner, and the processing strategy corresponding to the active / standby switching is executed.
5. The method for executing a processing strategy according to claim 1, wherein: Triggering a state change of the second type socket of the first host by using the changed first state to notify an application on the first host to execute a processing strategy corresponding to the active / standby switching includes: triggering a state change of the second type socket through the changed first state to notify the application to close the application; or The changed first state triggers a state change of the second type socket to notify the application to re-initiate a connection to the second host.
6. The method for executing a processing strategy according to claim 5, wherein: After triggering a state change of the second type socket by using the changed first state to notify the application to re-initiate a connection to the second host, the method further includes: recreating the first type socket and the second type socket by the application; Sending a connection request to the second host through the recreated first type socket; When the application monitors that the recreated first type socket enters a connection state with the second host, the third state change function corresponding to the recreated second type socket is injected into the fourth state change function, and the fourth message carrying communication data is transmitted with the second host through the recreated second type socket, wherein the fourth state change function is the state change function corresponding to the recreated first type socket.
7. The method for executing a processing strategy according to claim 6, wherein: Before transmitting the fourth message carrying communication data with the second host through the recreated second type socket, the method further includes: Sending a test data packet to the second host through the recreated second type socket; If a first timeout period is not exceeded and a confirmation message fed back by the second host based on the test data packet is received, determining that the application is allowed to resume communication with the second host; When the first timeout period has expired or the confirmation message fed back by the second host based on the test data packet is not received, it is determined that the application is not allowed to resume communication with the second host.
8. The method for executing a processing strategy according to claim 1, wherein: After triggering a state change of the second type socket of the first host by using the changed first state to notify an application on the first host to execute a processing strategy corresponding to the active / standby switching, the method further includes: Determining a response time of the application to the active / standby switching by using a first timestamp and a second timestamp included in the first message, wherein the second timestamp is a timestamp when the application executes the processing strategy; A second timeout period is updated according to the response time, wherein the second timeout period is a timeout period during which the application is allowed to execute the processing policy when the changed first state cannot trigger a state change of the second type of socket.
9. The method for executing a processing strategy according to claim 8, wherein: Updating the second timeout period according to the response time includes: Obtaining the response time fed back by at least one host in the network cluster; determining an average response time corresponding to at least one of the response times; The second timeout period is updated according to the average response time.
10. A device for executing a processing strategy, characterized in that: Applied to a network cluster comprising at least two hosts, each host in the network cluster being deployed with a target network card, including: a changing module, configured to change, through a first type socket, a first state corresponding to the first type socket according to a received first message, wherein the first type socket is a socket used to establish a communication link in a first host among the at least two hosts, and the first message is a message sent by a second host among the at least two hosts when performing active / standby switching of the target network adapter; A triggering module is configured to trigger a state change of a second type socket of the first host through the changed first state, so as to notify an application on the first host to execute a processing strategy corresponding to the active / standby switching, wherein the second type socket is a socket in the first host for transmitting a second message carrying communication data, wherein, The trigger module is further configured to determine, through a first state change function corresponding to the first type of socket, whether the changed first state is a closed state; if the changed first state is a closed state, trigger a state change of the second type of socket through the first state change function to notify the application on the first host to execute the processing strategy corresponding to the active / standby switching; The trigger module is also used to call the second state change function corresponding to the second type of socket through the first state change function, so as to change the second state of the second type of socket to a closed state through the second state change function, and notify the application to execute the processing strategy corresponding to the master-slave switching, wherein the second state change function has been injected into the first state change function when the first type of socket is initialized.
11. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the method for executing the processing strategy according to any one of claims 1 to 9 when executing the computer program.
12. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the method for executing the processing strategy according to any one of claims 1 to 9 are implemented.
13. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method for executing the processing strategy according to any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Main-auxiliary switching method, device, equipment and system
CN103259678A
Main / standby switch hot backup realization method for TCP (Transmission Control Protocol)
CN108111350A