Connection reconstruction method, electronic equipment, server and storage medium
By waiting for the proxy client to exit the deactivated state during the client upgrade process and receiving and responding to the connection establishment request of the target virtual machine, the communication connection is directly established, which solves the problem of extended connection establishment time caused by virtual machine shutdown, and improves the efficiency of connection establishment.
Patent Information
- Application Number
- CN202411975563.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-15
AI Technical Summary
During client upgrades, the virtual machine needs to be shut down to avoid data loss, resulting in extended connection establishment time and reduced efficiency.
After the target virtual machine disconnects the communication connection from the proxy client, waits for the proxy client to exit the deactivated state, and receives and responds to the connection establishment request of the target virtual machine after it exits the deactivated state, the communication connection is directly established.
This reduces the time required to establish a communication connection and improves the efficiency of connection establishment, so that the target virtual machine can establish a connection immediately after the proxy client exits the upgrade and deactivates state, without waiting for the proxy client to restart.
Smart Images

Figure CN119835318A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a connection reconstruction method, electronic equipment, server and storage medium. Background Art
[0002] With the rapid development of computer technology, user-mode clients can provide interfaces for interacting with the system or other services, execute specific application logic, process user input and output, and use the infrastructure provided by the operating system to complete tasks. Therefore, user-mode clients are widely used.
[0003] In the related art, during the client upgrade process, the virtual machine connected to the client will be shut down to avoid data loss. However, after the virtual machine is shut down, it must be restarted after the proxy client upgrade is completed. Only after the restart can a connection with the proxy client be established again, which prolongs the time required to establish the connection and reduces the efficiency of connection establishment. Summary of the invention
[0004] In order to solve the above-mentioned problems in the prior art, the example of the present application provides a connection reconstruction method, an electronic device, a server and a storage medium, which can reduce the time required to establish a communication connection and improve the efficiency of establishing a communication connection.
[0005] In a first aspect, an embodiment of the present application provides a connection reestablishment method, which is applied to a host machine; the host machine includes a proxy client; the method includes:
[0006] After the target virtual machine disconnects the communication connection with the proxy client, waiting for the proxy client to exit the deactivated state;
[0007] After the proxy client exits the deactivated state, receiving a connection establishment request sent by the target virtual machine through the proxy client, and sending a connection establishment response corresponding to the connection establishment request to the target virtual machine through the proxy client; the connection establishment response is used to indicate that a communication connection is established between the target virtual machine and the proxy client;
[0008] A creation request sent by the target virtual machine is received through the proxy client based on the communication connection, and a virtual machine instance corresponding to the target virtual machine is created based on the creation request.
[0009] Through the above method, the host machine can directly receive the connection establishment request sent by the target virtual machine through the proxy client and establish a corresponding communication connection after the proxy client upgrade is completed, that is, after the proxy client exits the deactivated state. The connection establishment request sent by the target virtual machine is not sent only after the proxy client upgrade is completed, but is continuously sent to the proxy client starting from the time the proxy client enters the upgraded deactivated state. Therefore, the target virtual machine can immediately establish a communication connection with the proxy client after the proxy client exits the upgraded deactivated state, which reduces the time required to establish a connection and improves the efficiency of connection establishment.
[0010] In a possible implementation manner, after creating the virtual machine instance corresponding to the target virtual machine based on the creation request, the method further includes:
[0011] Receiving a first acquisition request sent by the target virtual machine through the proxy client based on the communication connection;
[0012] Based on the first acquisition request, the connection status between the proxy client and the shared memory area is sent to the target virtual machine through the proxy client; the shared memory area is used to transmit data between the target virtual machine and the proxy client.
[0013] Through the above method, the shared memory area can be used to realize data transmission between the proxy client and the target virtual machine. Through the shared memory, data can be exchanged directly between the proxy client and the target virtual machine, avoiding traditional network protocols and copy operations, thereby reducing data transmission delays and system overhead.
[0014] In a possible implementation manner, the connection status between the proxy client and the shared memory area is obtained in the following manner:
[0015] Accessing shared memory management data based on the address stored in the proxy client to determine whether the shared memory management data contains data of the original shared memory area stored in the proxy client; the shared memory management data contains attributes and data of the shared memory area; the original shared memory area is for storing data before the proxy client enters the deactivated state;
[0016] If included, taking the original shared memory area corresponding to the original shared memory area address stored in the shared memory management data as the target shared memory area;
[0017] If not, and the data stored in the shared memory management data has not been added to the process of any virtual machine, then the data in the original shared memory area is updated based on the data in the shared memory management data, and the original shared memory area is used as the target shared memory area;
[0018] A connection is established with the target shared memory area through the proxy client, and the connection status is obtained based on the established connection.
[0019] Through the above method, a connection can be established between the shared memory area and the proxy client without the virtual machine's awareness, and if the data stored in the shared memory area changes during the proxy client upgrade process, the data stored in the shared memory area can be updated. Therefore, the relevant technical means of establishing a connection with the shared memory area in the present application can enable the proxy client in the present application to be upgraded online without shutting down the virtual machine.
[0020] In a possible implementation manner, after creating the virtual machine instance corresponding to the target virtual machine based on the creation request, the method further includes:
[0021] Sending a status detection request to the virtual machine instance corresponding to the target virtual machine, and determining the status of the virtual machine instance according to a status response returned by the virtual machine instance;
[0022] If the state of the virtual machine instance is running, receiving a message sent by the target virtual machine through the proxy client based on the communication connection, or sending a message to the target virtual machine through the proxy client based on the communication connection;
[0023] If the state of the virtual machine instance is response timeout, reading unread content in the virtual machine instance corresponding to the target virtual machine, and changing the state of the virtual machine instance to deactivated;
[0024] If the status of the virtual machine instance is disabled, the virtual machine instance is deleted.
[0025] Through the above method, after obtaining the status of the virtual machine instance, different processing can be performed on different situations, ensuring the data consistency between the proxy client and the target virtual machine after the proxy client is upgraded, improving the stability and reliability of the system, and reducing the complexity of manual intervention and operation and maintenance.
[0026] In a possible implementation manner, after creating the virtual machine instance corresponding to the target virtual machine based on the creation request, the method further includes:
[0027] A buffer queue is received through the proxy client based on the communication connection and sent by the target virtual machine; the buffer queue stores a message sent by the target virtual machine to the proxy client in the deactivated state;
[0028] Parsing each message in the order stored in the buffer queue to obtain a parsing result of each message, and determining a target operation corresponding to each message based on the parsing result of each message;
[0029] The target operation corresponding to each message is executed, and each execution result is sent to the target virtual machine through the proxy client.
[0030] Through the above method, the messages generated by the virtual machine during the proxy client upgrade process are added to the buffer queue, and are sent to the proxy client in a blocking manner while waiting for the network to recover, thereby ensuring the continuity of the data communication process and management messages. This is equivalent to the virtual machine not being shut down during the proxy client upgrade process, and data communication is still carried out as usual, thereby improving the efficiency of the system.
[0031] In a second aspect, an embodiment of the present application provides a connection reestablishment method, which is applied to a server; the server runs at least one virtual machine; the method comprises:
[0032] For any virtual machine, if it is detected that the connection between the any virtual machine and the proxy client has timed out, disconnecting the communication connection between the any virtual machine and the proxy client;
[0033] Sending a connection establishment request to the proxy client at set time intervals through any one of the virtual machines;
[0034] receiving a connection establishment response sent by the proxy client in response to the connection establishment request, and establishing a communication connection between the any one virtual machine and the proxy client based on the connection establishment response;
[0035] A creation request for creating a virtual machine instance corresponding to the target virtual machine is sent to the proxy client.
[0036] Through the above method, the connection establishment request sent by the target virtual machine is not sent after the proxy client upgrade is completed, but is continuously sent to the proxy client after the proxy client enters the upgrade disabled state. Therefore, the target virtual machine can establish a communication connection with the proxy client immediately after the proxy client exits the upgrade disabled state, which reduces the time required to establish the connection and improves the efficiency of connection establishment.
[0037] In a possible implementation manner, after sending a creation request for creating a virtual machine instance corresponding to the target virtual machine to the proxy client, the method further includes:
[0038] Sending a buffer queue to the proxy client through the target virtual machine; the buffer queue stores a message sent by the target virtual machine to the proxy client in the deactivated state;
[0039] Receive each execution result sent by the proxy client after executing the corresponding target operation on each message in the buffer queue; the target operation corresponding to each message is determined by the parsing result of each message; the parsing result of each message is obtained by the proxy client parsing each message in the order stored in the buffer queue.
[0040] Through the above method, the messages generated by the virtual machine during the proxy client upgrade process are added to the buffer queue, and are sent to the proxy client in a blocking manner while waiting for the network to recover, thereby ensuring the continuity of the data communication process and management messages. This is equivalent to the virtual machine not being shut down during the proxy client upgrade process, and data communication is still carried out as usual, thereby improving the efficiency of the system.
[0041] In a third aspect, an embodiment of the present application provides an electronic device, including:
[0042] A memory for storing program instructions;
[0043] The processor is used to call the program instructions stored in the memory and execute the steps included in the method described in the first aspect according to the obtained program instructions.
[0044] In a fourth aspect, an embodiment of the present application provides a server, including:
[0045] A memory for storing program instructions;
[0046] The processor is used to call the program instructions stored in the memory and execute the steps included in the method described in the second aspect according to the obtained program instructions.
[0047] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect or any one of the second aspects is implemented.
[0048] An embodiment of the present application provides a connection reestablishment method, wherein the server can disconnect the corresponding communication connection for any virtual machine upon detecting that the connection with the proxy client has timed out. Compared with shutting down the virtual machine, disconnecting the communication connection can reduce the impact on the system and avoid more problems in the system. After the proxy client enters the deactivated state, a connection establishment request is sent to the proxy client at set time intervals. Therefore, the target virtual machine can establish a communication connection with the proxy client immediately after the proxy client exits the upgraded deactivated state, without having to wait for the proxy client to restart before restarting the virtual machine and sending a connection request, thereby reducing the time required to establish a connection and improving the efficiency of connection establishment. Based on the communication connection, the proxy client can also create a corresponding virtual machine instance after receiving a creation request sent by the target virtual machine. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. 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 paying creative labor.
[0050] Figure 1 A schematic diagram of an application scenario of a connection reestablishment method provided in an embodiment of the present application;
[0051] Figure 2 An interactive flow chart of a connection reestablishment method provided in an embodiment of the present application;
[0052] Figure 3 A specific interactive flow chart of a connection reestablishment method provided in an embodiment of the present application;
[0053] Figure 4 A structural block diagram of a connection reestablishment device provided in an embodiment of the present application;
[0054] Figure 5 A structural block diagram of a connection reestablishment device provided in an embodiment of the present application;
[0055] Figure 6 A structural block diagram of an electronic device provided in an embodiment of the present application;
[0056] Figure 7 A structural block diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0057] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Among them, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0058] In the description of the embodiments of the present application, unless otherwise specified, "and" means or. For example, A / B can mean A or B. The "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.
[0059] Specifically, in the description of the present application, it needs to be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present application, and, unless otherwise specified, the "connection" and "connection" mentioned in the present application include direct and indirect connections (connections).
[0060] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0061] The present application is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0062] In one possible embodiment, Figure 1 A schematic diagram of an application scenario of a connection reestablishment method provided in an embodiment of the present application is shown. Figure 1 As shown, Figure 1The system includes a host machine 100 and a server 200, wherein a proxy client 110 and a shared memory 120 are deployed in the host machine 100, and a virtual machine 210 is deployed in the server 200, wherein both the virtual machine 210 and the proxy client 110 have threads for processing tasks of the sending queue (including sending and receiving data), and a ring buffer area ringbuffer can be included between the threads of the virtual machine 210 and the proxy client 110, and the ringbuffer can connect the virtual machine 210 and the proxy client 110 and realize data interaction in an efficient manner, and the virtual machine 210 also includes an Epoll that can detect IO events, such as read and write events of a socket, and the Epoll in the proxy client 110 can monitor events from the virtual machine 210, and the shared memory 120 is connected to the virtual machine 210 and the proxy client 110 respectively, and can provide a mechanism for fast data transmission to the virtual machine 210 and the proxy client 110 respectively, and the IO data can be transmitted through the shared pages in the shared memory 120, and the IO events are transmitted through the communication connection between the virtual machine 210 and the proxy client 110. It should be noted that there may be multiple virtual machines in the server 200, each of which is connected to the proxy client 110, so as to achieve communication between the virtual machine and the proxy client 120, and this application does not limit the number of deployed virtual machines.
[0063] Figure 1 The application scenario is only an example of an application scenario for implementing the embodiment of the present application. The embodiment of the present application is not limited to the above Figure 1 The application scenarios described. The fault testing method provided by the exemplary embodiment of the present application is described below with reference to the accompanying drawings in combination with the application scenarios described above. It should be noted that the application scenarios described above are only shown to facilitate understanding of the spirit and principles of the present application, and the implementation of the present application is not limited in this respect.
[0064] Figure 2 An interactive flow chart of a connection reestablishment method provided in an embodiment of the present application is shown, such as Figure 2 As shown, the method may include the following steps:
[0065] Step S201: For any virtual machine, if the server detects that the connection between any virtual machine and the proxy client has timed out, the server disconnects the communication connection between any virtual machine and the proxy client.
[0066] In a possible embodiment, the proxy client can be upgraded online, that is, it enters a deactivated state. After the proxy client enters the deactivated state, if a virtual machine that has a communication connection with the proxy client sends a message to the proxy client, the corresponding virtual machine can detect that the connection with the proxy client has timed out, thereby disconnecting the communication connection between the corresponding virtual machine and the proxy client. In addition, after the proxy client enters the deactivated state, it will not only disconnect the communication connection with each connected virtual machine, but also disconnect the communication connection with the shared memory.
[0067] Step S202: The server sends a connection establishment request to the host machine.
[0068] In a possible embodiment, the server can send a connection establishment request to the proxy client at set time intervals through any virtual machine. It should be noted that the connection establishment request sent by the target virtual machine is not sent only after the proxy client upgrade is completed, but is continuously sent to the proxy client starting from when the proxy client enters the upgrade disabled state. Therefore, the target virtual machine can establish a communication connection with the proxy client immediately after the proxy client exits the upgrade disabled state, thereby reducing the time required to establish a connection.
[0069] Step S203: After the proxy client exits the deactivated state, the host machine receives the connection establishment request sent by the target virtual machine through the proxy client, and generates a corresponding connection establishment response.
[0070] In a possible embodiment, after determining that the proxy client has exited the deactivated state, the host machine can receive the connection establishment request continuously sent by the target virtual machine in step S202 through the proxy client, and generate a corresponding connection establishment response based on the connection establishment request. The connection establishment response may include content that the host machine agrees to establish a communication connection with the target virtual machine through the proxy client.
[0071] In a possible embodiment, after determining that the proxy client exits the deactivated state, the host machine may also reestablish the communication connection with the shared memory.
[0072] A shared memory area corresponds to a shared memory management area, which contains multiple shared memory management data. A shared memory management area can be opened up separately at the beginning of the first shared memory. The shared memory management area contains a specific magic number, which is a flag used to identify whether a specific resource structure (such as shared memory) needs to be reinitialized. When the proxy client restarts and determines that the magic number exists, it can be considered that the shared memory area needs to be mapped to the memory and a communication connection between the proxy client and the shared memory area needs to be established; the shared memory management area also contains version parameters and mem_param parameters. If the mem_param parameter changes, it can be determined that the shared memory area needs to be rebuilt or reinitialized. If the mem_param parameter remains unchanged, the consistency of the resources can be verified; shared memory management The area also contains the remapped shmem_size parameter, which is used to determine the size that needs to be mapped to the memory in the shared memory area. When mem_param does not change, the value of the node check total_node_nr parameter and the total_pg_nr parameter can be calculated according to the value of mem_param. The total_node_nr parameter is used to determine the number of nodes in the shared memory area, and the total_pg_nr parameter is used to determine the number of page groups for each node. The number of nodes and the number of page groups for each node are determined by mem_param, and then the integrity of the shared memory structure is verified according to these values; the shared memory management area also contains shared pages and page groups page_group_t parameters. Shared pages are combined into page groups (page_group_t). Each page group maintains a user_id, indicating which virtual machine the page group is currently using. If the virtual machine exits (the process disappears), the page group is recycled to the idle queue.
[0073] Specifically, the communication connection between the proxy client and the shared memory can be rebuilt in the following manner: initialize the shared memory manager, prepare to allocate and manage resources for the shared memory, use shm_open to open the shared memory area, if the opening fails, it means that there is no shared memory area, and the process can be ended; if the opening is successful, it can be checked whether the magic number in the shared memory management area exists, if the magic number exists, it means that the shared memory needs to be rebuilt, and the reconstruction process can be entered, and the configuration parameters of the shared memory (such as size and version) can be checked to be consistent with the original values, if the parameters have not changed, directly map the shared memory, and execute the original shared memory area corresponding to the original shared memory area address stored in the shared memory management data as the target shared memory area; if there is a change, it is necessary to determine that the data stored in the shared memory management data has not been added to the process of any virtual machine, and then update the data in the original shared memory area based on the data in the shared memory management data, and use the original shared memory area as the target shared memory area; if there is a change, and the data stored in the shared memory management data is added to the process of any virtual machine, it means that the shared memory is valid, and the resource recovery process is entered.
[0074] After the communication connection between the proxy client and the shared memory is rebuilt, step S204 may be performed.
[0075] Step S204: the host sends a connection establishment response to the server.
[0076] Step S205 , the server receives a connection establishment response sent by the host machine in response to the connection establishment request, and establishes a communication connection between any virtual machine and the proxy client based on the connection establishment response.
[0077] In a possible embodiment, the server can establish a communication connection between any virtual machine and the proxy client by receiving a connection establishment response sent by the proxy client in response to the connection establishment request and based on the connection establishment response. After the communication connection is established, the server can also send a first acquisition request to the proxy client through the target virtual machine, wherein the target virtual machine is a virtual machine that reestablishes a communication connection with the proxy client. The proxy client can send the connection status between the proxy client and the shared memory area to the target virtual machine through the proxy client based on the first acquisition request, wherein the connection status between the proxy client and the shared memory area has been reflected through the process of reestablishing the connection between the proxy client and the shared memory area in step S203, which will not be repeated here.
[0078] Step S206: The server sends a creation request to the host machine for creating a virtual machine instance corresponding to the target virtual machine.
[0079] In a possible embodiment, after completing the creation of the communication connection between the proxy client and the target virtual machine, the virtual machine instance corresponding to the target virtual machine can continue to be created in the proxy client, and the server can send a creation request to the host machine for creating the virtual machine instance corresponding to the target virtual machine.
[0080] Step S207: The host machine receives a creation request sent by the target virtual machine through the proxy client based on the communication connection, and creates a virtual machine instance corresponding to the target virtual machine based on the creation request.
[0081] In a possible embodiment, the host machine can receive the creation request sent by the target virtual machine through step S205 through the proxy client based on the communication connection, and create a virtual machine instance corresponding to the target virtual machine based on the creation request. After completing the creation of the virtual machine instance in step S206, the host machine can also send a status detection request to the virtual machine instance corresponding to the target virtual machine, and determine the status of the virtual machine instance according to the status response returned by the virtual machine instance. If the status of the virtual machine instance is running, the message sent by the target virtual machine is received through the proxy client based on the communication connection, or a message is sent to the target virtual machine through the proxy client based on the communication connection; if the status of the virtual machine instance is a response timeout, the unread content in the virtual machine instance corresponding to the target virtual machine is read, and the status of the virtual machine instance is changed to deactivated; if the status of the virtual machine instance is deactivated, the virtual machine instance is deleted.
[0082] Specifically, the structure of each virtual machine instance can be described as follows: located at the starting position of the virtual machine instance, is the header area, which is used to describe the status of the virtual machine instance and the data structure information of the I / O message communication. The instance status includes the following three types: disabled, running, and response timed out. After the header area, is the data structure header area of the I / O message communication, which describes the status and flags of the specific I / O message communication. The data structure header of all I / O message communications in the virtual machine instance is stored in the order of the I / O message communication id. The I / O message communication status includes: INACTIVE (instance unavailable), ACTIVE (instance available), RECOVERY (instance is in error processing state). Located after the I / O message communication data structure header is the data area, which stores specific data. Different I / O message communication data areas are stored in the order of the I / O message communication id.
[0083] In a possible embodiment, when the proxy client enters the deactivated state, the virtual machine instance in the proxy client may perform the following steps: the proxy client entering the deactivated state may cause the network connection to be disconnected, the virtual machine instance existing in the proxy client may be deleted, and unprocessed messages in the I / O message communication data structure may be cleared, and the state of the virtual machine instance may be changed to deactivated; when the proxy client exits the deactivated state, the communication connection is restored, the target virtual machine initiates a request to create a target virtual machine instance, the proxy client creates a virtual machine instance corresponding to the target virtual machine, and sets the state of the virtual machine instance to running.
[0084] In a possible embodiment, the I / O message communication can perform the following steps after the communication connection is disconnected or reconnected. When the connection is interrupted, if it is a receiving type of I / O message communication, all unread contents in the I / O message communication data structure will be read, and the processing results returned by the proxy client will be received and processed to maximize the processing of completed io requests; if it is a sending type of I / O message communication, the message will be emptied first, and the message that does not return the result in the I / O message communication data structure will be returned to the upper layer as a retryable error, and the hash value, linked list, etc. related to this message in the memory will be deleted. After executing the above two steps, the I / O message communication state can be set to INACTIVE, the data structure content is completely cleared, and the target virtual machine instance information is deleted, ensuring the consistency of data between the upgraded proxy client and the virtual machine. When the connection is restored, the shared memory file name is obtained from the proxy client and mapped to the memory, and messages are started to be received or sent, and the target virtual machine instance information and the I / O message communication data structure are completely restored. When requesting messages during the proxy client upgrade process, the virtual machine will add the requests to the buffer in a blocking manner. The buffer can be a buffer queue, but is not limited to a cache queue. After the communication connection between the virtual machine and the proxy client is reestablished, the request messages will be resent to the proxy client in the order in which they were added to the buffer, ensuring the continuity of data communication and management messages. For communication requests such as overwriting, the correctness of data communication can also be guaranteed.
[0085] In a possible embodiment, when the virtual machine instance is created, the server can send a buffer queue to the proxy client through the target virtual machine. In the buffer queue, there are messages sent by the target virtual machine to the proxy client in a deactivated state. For example, if the proxy client is in a deactivated state for 5 seconds, the messages sent by the target virtual machine within these 5 seconds are stored in the buffer queue. The host machine can receive the buffer queue sent by the target virtual machine through the proxy client based on the communication connection through the proxy client, parse each message in the order stored in the buffer queue, obtain the parsing result of each message, and determine the target operation corresponding to each message based on the parsing result of each message, execute the target operation corresponding to each message, and send each execution result to the target virtual machine through the proxy client. The target virtual machine can receive each execution result sent by the proxy client after executing the corresponding target operation for each message in the buffer queue. By setting the buffer queue, the messages generated by the virtual machine during the proxy client upgrade process are added to the buffer queue, and are sent to the proxy client in a blocking manner after waiting for the network to recover, thereby ensuring the continuity of the data communication process and management messages. This is equivalent to the virtual machine not being shut down during the proxy client upgrade process, and still performing data communication as usual, thereby improving the efficiency of the system.
[0086] An embodiment of the present application provides a connection reestablishment method, wherein the server can disconnect the corresponding communication connection for any virtual machine upon detecting that the connection with the proxy client has timed out. Compared with shutting down the virtual machine, disconnecting the communication connection can reduce the impact on the system and avoid more problems in the system. After the proxy client enters the deactivated state, a connection establishment request is sent to the proxy client at set time intervals. Therefore, the target virtual machine can establish a communication connection with the proxy client immediately after the proxy client exits the upgraded deactivated state, without having to wait for the proxy client to restart before restarting the virtual machine and sending a connection request, thereby reducing the time required to establish a connection and improving the efficiency of connection establishment. Based on the communication connection, the proxy client can also create a corresponding virtual machine instance after receiving a creation request sent by the target virtual machine.
[0087] In one possible embodiment, Figure 3 A specific interactive flow chart of a connection reestablishment method provided in an embodiment of the present application is shown, such as Figure 3 As shown, the method comprises the following steps:
[0088] Step S301: For any virtual machine, if the server detects that the connection between any virtual machine and the proxy client has timed out, the server disconnects the communication connection between any virtual machine and the proxy client.
[0089] Step S302: The server sends a connection establishment request to the host machine.
[0090] Step S303: after the proxy client exits the deactivated state, the host machine receives the connection establishment request sent by the target virtual machine through the proxy client, and generates a corresponding connection establishment response.
[0091] Step S304: the host sends a connection establishment response to the server.
[0092] Step S305 , the server receives a connection establishment response sent by the host machine in response to the connection establishment request, and establishes a communication connection between any virtual machine and the proxy client based on the connection establishment response.
[0093] Step S306: The server sends a creation request to the host machine for creating a virtual machine instance corresponding to the target virtual machine.
[0094] Step S307: The host machine receives a creation request sent by the target virtual machine through the proxy client based on the communication connection, and creates a virtual machine instance corresponding to the target virtual machine based on the creation request.
[0095] Step S308: The host machine sends a status detection request to the virtual machine instance corresponding to the target virtual machine, and determines the status of the virtual machine instance according to a status response returned by the virtual machine instance.
[0096] In a possible embodiment, if the state of the virtual machine instance is running, a message sent by the target virtual machine is received through the proxy client based on the communication connection, or a message is sent to the target virtual machine through the proxy client based on the communication connection.
[0097] In another possible embodiment, if the state of the virtual machine instance is response timeout, unread content in the virtual machine instance corresponding to the target virtual machine is read, and the state of the virtual machine instance is changed to disabled.
[0098] In another possible embodiment, if the status of the virtual machine instance is disabled, the virtual machine instance is deleted.
[0099] Step S309: the server sends a first acquisition request to the host machine.
[0100] Step S310: The host machine receives a first acquisition request sent by the target virtual machine through a proxy client.
[0101] Step S311: the host machine obtains the connection status of the communication connection between the proxy client and the shared memory area based on the first acquisition request.
[0102] Step S312: the host sends the connection status to the server.
[0103] Step S313: the server sends the buffer queue to the host machine.
[0104] In step S314, the host machine receives the buffer queue sent by the target virtual machine through the proxy client based on the communication connection, parses each message in the order saved in the buffer queue, obtains the parsing result of each message, and determines the target operation corresponding to each message based on the parsing result of each message, executes the target operation corresponding to each message, and obtains each execution result.
[0105] Step S315: the host sends each execution result to the server.
[0106] Step S316: the server receives each execution result sent by the proxy client after executing the corresponding target operation on each message in the buffer queue.
[0107] Based on the same inventive concept, Figure 4 A structural block diagram of a connection reconstruction device provided in an embodiment of the present application, the connection reconstruction device can be applied to a host machine, the host machine includes a proxy client, such as Figure 4 As shown, the connection reestablishment device 400 may include:
[0108] The communication connection establishing unit 401 is used to wait for the proxy client to exit the deactivated state after the target virtual machine disconnects the communication connection with the proxy client;
[0109] After the proxy client exits the deactivated state, receiving a connection establishment request sent by the target virtual machine through the proxy client, and sending a connection establishment response corresponding to the connection establishment request to the target virtual machine through the proxy client; the connection establishment response is used to indicate that a communication connection is established between the target virtual machine and the proxy client;
[0110] The virtual machine instance creation unit 402 is configured to receive a creation request sent by the target virtual machine through the proxy client based on the communication connection, and create a virtual machine instance corresponding to the target virtual machine based on the creation request.
[0111] In a possible implementation, the communication connection establishing unit 401 is further configured to receive a first acquisition request sent by the target virtual machine through the proxy client based on the communication connection;
[0112] Based on the first acquisition request, the connection status between the proxy client and the shared memory area is sent to the target virtual machine through the proxy client; the shared memory area is used to transmit data between the target virtual machine and the proxy client.
[0113] In a possible implementation, the communication connection establishing unit 401 is further used to access the shared memory management data based on the address stored in the proxy client, and determine whether the shared memory management data contains the data of the original shared memory area stored in the proxy client; the shared memory management data contains the attributes and data of the shared memory area; the original shared memory area is the data stored before the proxy client enters the deactivated state;
[0114] If included, taking the original shared memory area corresponding to the original shared memory area address stored in the shared memory management data as the target shared memory area;
[0115] If not, and the data stored in the shared memory management data has not been added to the process of any virtual machine, then the data in the original shared memory area is updated based on the data in the shared memory management data, and the original shared memory area is used as the target shared memory area;
[0116] A connection is established with the target shared memory area through the proxy client, and the connection status is obtained based on the established connection.
[0117] In a possible implementation, the virtual machine instance creation unit 402 is further configured to send a status detection request to the virtual machine instance corresponding to the target virtual machine, and determine the status of the virtual machine instance according to a status response returned by the virtual machine instance;
[0118] If the state of the virtual machine instance is running, receiving a message sent by the target virtual machine through the proxy client based on the communication connection, or sending a message to the target virtual machine through the proxy client based on the communication connection;
[0119] If the state of the virtual machine instance is response timeout, reading unread content in the virtual machine instance corresponding to the target virtual machine, and changing the state of the virtual machine instance to deactivated;
[0120] If the status of the virtual machine instance is disabled, the virtual machine instance is deleted.
[0121] In a possible implementation, the virtual machine instance creation unit 402 is further configured to receive a buffer queue sent by the target virtual machine through the proxy client based on the communication connection; the buffer queue stores a message sent by the target virtual machine to the proxy client in the deactivated state;
[0122] Parsing each message in the order stored in the buffer queue to obtain a parsing result of each message, and determining a target operation corresponding to each message based on the parsing result of each message;
[0123] The target operation corresponding to each message is executed, and each execution result is sent to the target virtual machine through the proxy client.
[0124] Based on the same inventive concept, Figure 5 A structural block diagram of a connection reestablishment device provided in an embodiment of the present application, the connection reestablishment device can be applied to a server, and the server runs at least one virtual machine, such as Figure 5 As shown, the connection reestablishment device 500 may include:
[0125] The connection establishment request sending unit 501 is used for disconnecting the communication connection between any one virtual machine and the proxy client if it is detected that the connection between any one virtual machine and the proxy client has timed out.
[0126] Sending a connection establishment request to the proxy client at set time intervals through any one of the virtual machines;
[0127] A communication connection establishing unit 502, configured to receive a connection establishment response sent by the proxy client in response to the connection establishment request, and to establish a communication connection between the any one virtual machine and the proxy client based on the connection establishment response;
[0128] The creation request sending unit 503 is used to send a creation request for creating a virtual machine instance corresponding to the target virtual machine to the proxy client.
[0129] In a possible implementation, the communication connection establishing unit 502 is further configured to send a buffer queue to the proxy client through the target virtual machine; the buffer queue stores a message sent by the target virtual machine to the proxy client in the deactivated state;
[0130] Receive each execution result sent by the proxy client after executing the corresponding target operation on each message in the buffer queue; the target operation corresponding to each message is determined by the parsing result of each message; the parsing result of each message is obtained by the proxy client parsing each message in the order stored in the buffer queue.
[0131] Based on the same inventive concept, the embodiment of the present application provides an electronic device, which can implement the function of the connection reestablishment method discussed above, please refer to Figure 6 The electronic device 600 includes a memory 601, a processor 602 and a bus 603.
[0132] The memory 601 is used to store computer programs executed by the processor 602. The memory 601 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and programs required for running the instant messaging function, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.
[0133] The memory 601 may be a volatile memory, such as a random-access memory (RAM); the memory 601 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), or the memory 601 may be any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 601 may be a combination of the above memories.
[0134] The processor 602 may include one or more central processing units (CPU) or a digital processing unit, etc. The processor 602 is configured to implement the connection reestablishment method in the above embodiment when calling the computer program stored in the memory 601 .
[0135] The specific connection medium between the memory 601 and the processor 602 is not limited in the embodiment of the present application. Figure 6 In the embodiment, the memory 601 and the processor 602 are connected via a bus 603. The bus 603 is connected to the processor 602 via a bus 603. Figure 6 The connections between other components are shown in bold lines, which are only for illustration and are not intended to be limiting. Bus 603 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0136] Based on the same inventive concept, the embodiment of the present application provides a server, which can implement the function of the connection reconstruction method discussed above, please refer to Figure 7 The server 700 includes a memory 701 , a processor 702 and a bus 703 .
[0137] The memory 701 is used to store computer programs executed by the processor 702. The memory 701 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and programs required for running the instant messaging function, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.
[0138] The memory 701 may be a volatile memory, such as a random-access memory (RAM); the memory 701 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), or the memory 701 may be any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 701 may be a combination of the above memories.
[0139] The processor 702 may include one or more central processing units (CPU) or a digital processing unit, etc. The processor 702 is configured to implement the connection reestablishment method in the above embodiment when calling the computer program stored in the memory 701 .
[0140] The specific connection medium between the memory 701 and the processor 702 is not limited in the embodiment of the present application. Figure 7 In the embodiment, the memory 701 and the processor 702 are connected via a bus 703. The bus 703 is connected to the processor 702 via a bus 703. Figure 7 The connections between other components are shown in bold lines, which are only for illustration and are not intended to be limiting. Bus 703 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 7 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0141] Based on the same inventive concept, an embodiment of the present application provides a computer-readable storage medium, and a computer program product includes: a computer program code, when the computer program code is executed on a computer, the computer executes any of the connection reestablishment methods discussed above. Since the principle of solving the problem by the above-mentioned computer-readable storage medium is similar to that of the connection reestablishment method, the implementation of the above-mentioned computer-readable storage medium can refer to the implementation of the method, and the repeated parts will not be repeated.
[0142] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0143] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0144] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0145] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0146] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A connection reestablishment method, characterized in that: Applied to a host machine; the host machine includes a proxy client; the method includes: After the target virtual machine disconnects the communication connection with the proxy client, waiting for the proxy client to exit the deactivated state; After the proxy client exits the deactivated state, receiving a connection establishment request sent by the target virtual machine through the proxy client, and sending a connection establishment response corresponding to the connection establishment request to the target virtual machine through the proxy client; the connection establishment response is used to indicate that a communication connection is established between the target virtual machine and the proxy client; A creation request sent by the target virtual machine is received through the proxy client based on the communication connection, and a virtual machine instance corresponding to the target virtual machine is created based on the creation request.
2. The method according to claim 1, characterized in that After creating the virtual machine instance corresponding to the target virtual machine based on the creation request, the method further includes: Receiving a first acquisition request sent by the target virtual machine through the proxy client based on the communication connection; Based on the first acquisition request, the connection status between the proxy client and the shared memory area is sent to the target virtual machine through the proxy client; the shared memory area is used to transmit data between the target virtual machine and the proxy client.
3. The method according to claim 2, characterized in that The connection status between the proxy client and the shared memory area is obtained in the following manner: Accessing shared memory management data based on the address stored in the proxy client to determine whether the shared memory management data contains data of the original shared memory area stored in the proxy client; the shared memory management data contains attributes and data of the shared memory area; the original shared memory area is for storing data before the proxy client enters the deactivated state; If included, taking the original shared memory area corresponding to the original shared memory area address stored in the shared memory management data as the target shared memory area; If not, and the data stored in the shared memory management data has not been added to the process of any virtual machine, then the data in the original shared memory area is updated based on the data in the shared memory management data, and the original shared memory area is used as the target shared memory area; A connection is established with the target shared memory area through the proxy client, and the connection status is obtained based on the established connection.
4. The method according to claim 1, characterized in that: After creating the virtual machine instance corresponding to the target virtual machine based on the creation request, the method further includes: Sending a status detection request to the virtual machine instance corresponding to the target virtual machine, and determining the status of the virtual machine instance according to a status response returned by the virtual machine instance; If the state of the virtual machine instance is running, receiving a message sent by the target virtual machine through the proxy client based on the communication connection, or sending a message to the target virtual machine through the proxy client based on the communication connection; If the state of the virtual machine instance is response timeout, reading unread content in the virtual machine instance corresponding to the target virtual machine, and changing the state of the virtual machine instance to deactivated; If the status of the virtual machine instance is disabled, the virtual machine instance is deleted.
5. The method according to any one of claims 1 to 4, characterized in that: After creating the virtual machine instance corresponding to the target virtual machine based on the creation request, the method further includes: A buffer queue is received through the proxy client based on the communication connection and sent by the target virtual machine; the buffer queue stores a message sent by the target virtual machine to the proxy client in the deactivated state; Parsing each message in the order stored in the buffer queue to obtain a parsing result of each message, and determining a target operation corresponding to each message based on the parsing result of each message; Execute the target operation corresponding to each message, and send each execution result to the target virtual machine through the proxy client.
6. A connection reestablishment method, characterized in that: Applied to servers; The server runs at least one virtual machine; the method comprises: For any virtual machine, if it is detected that the connection between the any virtual machine and the proxy client has timed out, disconnecting the communication connection between the any virtual machine and the proxy client; Sending a connection establishment request to the proxy client at set time intervals through any one of the virtual machines; receiving a connection establishment response sent by the proxy client in response to the connection establishment request, and establishing a communication connection between the any one virtual machine and the proxy client based on the connection establishment response; A creation request for creating a virtual machine instance corresponding to the target virtual machine is sent to the proxy client.
7. The method according to claim 6, characterized in that After sending a creation request for creating a virtual machine instance corresponding to the target virtual machine to the proxy client, the method further includes: Sending a buffer queue to the proxy client through the target virtual machine; the buffer queue stores a message sent by the target virtual machine to the proxy client in the deactivated state; Receive each execution result sent by the proxy client after executing the corresponding target operation on each message in the buffer queue; the target operation corresponding to each message is determined by the parsing result of each message; the parsing result of each message is obtained by the proxy client parsing each message in the order stored in the buffer queue.
8. An electronic device, characterized in that: include: A memory for storing program instructions; A processor is used to call the program instructions stored in the memory, and execute the steps included in any one of the methods of claims 1-5 according to the obtained program instructions.
9. A server, characterized in that: include: A memory for storing program instructions; A processor is used to call the program instructions stored in the memory, and execute the steps included in any one of claims 6-7 according to the obtained program instructions.
10. A computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 or any one of claims 6 to 7 is implemented.