Communication method, device, server and storage medium
By obtaining and updating the network connection status information of each server, it ensures that the network can be quickly switched to a normal network when a network failure occurs in a multi-server system, solving the problem of data transmission interruption caused by network failure in multi-server communication, and improving the stability and stability of the system. reliability.
Patent Information
- Application Number
- CN202111677714.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-31
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2041-12-31
AI Technical Summary
In systems with complex functional requirements, communication between multiple servers is difficult to switch quickly when a network failure occurs, affecting the real-time and reliability of data transmission.
By obtaining the connection status information between each server and the network, the normally connected network is determined, and the network is switched to the network for information exchange to ensure that the message exchange between servers is not interrupted. Specific implementation includes obtaining network status information, updating local cluster status information, notifying other servers to restart or delete abnormal message queue servers, and ensuring the normal status of the message queue server cluster.
It enables multiple servers to switch to another normal network at the same time in the event of a network failure, ensuring the reliability and real-time nature of information interaction between servers, and improving the stability of the system and the security of data transmission.
Smart Images

Figure CN114422335B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer communication technology, and in particular, relates to a communication method, device, server and storage medium. Background Art
[0002] With the development of computer technology, more and more management problems are developing towards intelligence, thus a large number of management systems have emerged, such as substation monitoring systems, train control systems, and securities trading systems.
[0003] For systems with complex functional requirements, they generally require the support of multiple servers, and multiple servers interact with each other through the platform bus. In order to ensure the robustness of the system network, the system also needs to use multiple networks for communication without affecting each other; during the operation of the system, when one of the networks fails, the data communication between the servers will switch to another network; similarly, when one of the networks fails, the platform bus also needs to be able to respond quickly and switch to another network for message interaction.
[0004] A stable and reliable platform bus is an important technical support for the system (such as the substation monitoring system). The rationality of the platform bus's communication architecture and network switching method determines the real-time and reliability of the system's data acquisition and transmission. Therefore, it is necessary to analyze the system's communication technology and design a suitable communication solution based on the system's operating requirements. Summary of the invention
[0005] The embodiments of the present application provide a communication method, system, server and storage medium, which ensure information interaction between multiple servers while ensuring network connection of multiple services.
[0006] In a first aspect, an embodiment of the present application provides a communication method, including:
[0007] The first server acquires network status information, the network status information including connection status information between a plurality of servers and a plurality of networks respectively, the plurality of servers including the first server;
[0008] The first server determines, according to the network status information, a first network among the multiple networks that is normally connected to the multiple servers;
[0009] The first server exchanges information with other servers among the multiple servers through the first network.
[0010] In the above embodiment, when a network for information exchange fails, the communication method can switch multiple servers to another normal network at the same time, ensuring the normal server network connection. Moreover, since multiple servers can be switched to the same network at the same time, the interaction of messages between servers is guaranteed.
[0011] In a possible implementation manner of the first aspect, the connection status information between the multiple servers and the multiple networks respectively includes first connection status information between the first server and the multiple networks respectively, and second connection status information between other servers and the multiple networks respectively; the first server obtains the network status information specifically including:
[0012] The first server obtains the first connection status information;
[0013] The first server publishes the first connection status information in a server cluster corresponding to a second network, so that the other servers obtain the first connection status information, the second network is a network normally connected to the first server, and the server cluster corresponding to the second network includes a plurality of message queue servers respectively deployed on a plurality of servers;
[0014] The first server receives the subscribed second connection status information from the service-side clusters corresponding to the multiple networks respectively.
[0015] In a possible implementation manner of the first aspect, the communication method further includes:
[0016] The first server obtains local cluster status information, where the local cluster status information includes status information of multiple first server clusters, where the multiple first server clusters are server clusters where multiple message queue servers corresponding to the multiple networks in the first server are located respectively;
[0017] If the local cluster state information does not contain abnormal state information, the first server sends the local cluster state information to the other servers, and the local cluster state information is first normal cluster state information.
[0018] In a possible implementation manner of the first aspect, the communication method further includes:
[0019] If the local cluster state information contains abnormal state information, the first server updates the local cluster state information according to the abnormal state information to obtain first normal cluster state information, and sends the obtained first normal cluster state information to other servers.
[0020] In a possible implementation manner of the first aspect, updating the local cluster state information according to the abnormal state information to obtain first normal cluster state information specifically includes:
[0021] If the abnormal status information includes first abnormal information, the first server notifies the other servers to restart the message queue server belonging to the first server cluster, and obtains the first normal cluster status information; the first abnormal information indicates that there is a message queue server that does not work normally in the first server cluster;
[0022] If the abnormal status information includes second abnormal information, and the second abnormal information indicates that the first message queue server stops working, the first server deletes the first message queue server from the first server cluster and obtains the first normal cluster status information.
[0023] In a possible implementation manner of the first aspect, the method further includes:
[0024] The first server receives the second normal cluster state information sent by the other servers;
[0025] The plurality of first server clusters are updated according to the first normal cluster state information and the second normal cluster state information.
[0026] In a possible implementation manner of the first aspect, the first server interacts with other servers among the multiple servers through the first network, specifically including:
[0027] The first server obtains a first subscription message corresponding to the first message topic from the server cluster corresponding to the first network, where the first message topic is a message topic to which the first server subscribes respectively from all server clusters corresponding to multiple networks, and the subscription message is published by other servers among the multiple servers;
[0028] The first server publishes a backed-up second subscription message to the server set corresponding to the first network, where the second subscription message is a subscription message corresponding to a second message topic subscribed by the other servers.
[0029] In a second aspect, an embodiment of the present application provides a server, wherein the server is configured to execute the communication method described in any implementation of the first aspect above.
[0030] In a third 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 communication method as described in any implementation of the first aspect above is implemented.
[0031] In a fourth aspect, an embodiment of the present application provides a communication system, comprising multiple servers as described in the second aspect, wherein the multiple servers are respectively connected to multiple networks, each network corresponds to a server cluster, and the server cluster includes multiple message queue servers deployed on multiple servers.
[0032] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a server, enables the server to execute any communication method described in the first aspect.
[0033] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art 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 any creative work.
[0035] Figure 1 This is a schematic diagram of an application scenario of a communication method provided by an embodiment of the present application;
[0036] Figure 2 is a flow chart of a communication method provided by an embodiment of the present application;
[0037] Figure 3 is a flow chart of a cluster state maintenance method in a communication method provided in an embodiment of the present application;
[0038] Figure 4 It is a schematic diagram of the module structure of a communication device provided in an embodiment of the present application;
[0039] Figure 5 It is a schematic diagram of the internal structure of a server provided in one embodiment of the present application. DETAILED DESCRIPTION
[0040] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0041] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0042] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0043] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0044] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0045] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0046] The present application provides a communication method, which is applied to a multi-server system, wherein the multiple servers are connected to multiple networks through multiple switches, and the clients on the servers communicate with each other through the same network. When the connected network fails, all servers switch to a network in any network state among the multiple networks for communication.
[0047] There is a message queue server running on each network connected to each server, and all message queue servers running on the same network form a server cluster corresponding to the network. There is a client running on each server, and the client connects to the corresponding server cluster through the message queue server. All clients publish messages to one of the server clusters and obtain subscribed messages from all server clusters.
[0048] Figure 1 FIG. 1 is an application scenario diagram of a communication method in an embodiment of the present application, which takes four servers and two networks as an example. Figure 1 As shown, each server is connected to the A network through switch A and connected to the B network through switch B. A corresponding message queue server A runs on the A network of each server, and a corresponding message queue server B runs on the B network. All message queue servers A form a server cluster A, and all message queue servers B form a server cluster B, where server cluster A is the first bus between servers, which is connected to the A network, and server cluster B is the second bus between servers, which is connected to the B network.
[0049] Optionally, a cluster daemon process runs on each server, which monitors the local network status through MII (Media Independent Interface), updates the local network status to the local cache, and sends the local network status to the server cluster A and the server cluster B. In addition, the cluster daemon process checks the local cluster status information respectively and manages according to the cluster status information.
[0050] The server also runs clients for implementing specific functions. Each client establishes connections with server cluster A and server cluster B respectively. All clients publish messages through the same server cluster and subscribe to messages from all server clusters.
[0051] Optionally, each client creates two client objects, client1 and client2, for connecting to server cluster A and server cluster B respectively; client1 and client2 start node management threads for managing connections with message queue servers in server cluster A and server cluster B respectively.
[0052] The communication method in the embodiment of the present application can be applied to the communication between multiple servers in the substation monitoring system. Specifically, the host of the substation monitoring system includes one main and one standby integrated monitoring host in the safety zone I and one main and one standby comprehensive application host in the safety zone II. Each host carries four major functions, including station control system operation monitoring, operation control, intelligent application and main station support services, and provides remote service support for the main station through a real-time gateway machine and a service gateway machine. Among them, the main and standby integrated monitoring hosts in the safety zone I are two servers, and the main and standby comprehensive application hosts in the safety zone II are two servers, so there are a total of four servers. In this system, a dual network is generally set up. Using this communication method, two message queue service terminals corresponding to the network are set on each of the four servers to form two server clusters. The four servers realize information interaction according to the communication method in the embodiment of the present application. For specific contents, please refer to the discussion of other parts of the communication method of the present application, which will not be repeated here.
[0053] The following is an exemplary description of a communication method provided by the present application in conjunction with a specific embodiment. Exemplarily, a test software may be installed on the mobile terminal, and the test software is used to execute the steps executed by the mobile terminal in the Bluetooth connection test method.
[0054] Figure 2 A method flow chart of a communication method provided in an embodiment of the present application is shown. The first service is any one of a plurality of servers. The present application is described with reference to the first server, and other servers in the plurality of servers perform the same steps. As an example and not a limitation, the communication method includes the following steps:
[0055] Step S201: A first server obtains network status information, where the network status information includes connection status information between a plurality of servers and a plurality of networks respectively, and the plurality of servers include the first server.
[0056] In an embodiment, the first server is any one of a plurality of servers, and the network status information represents the connection status between the corresponding server and the network as available or unavailable. The connection between the server and the network may become unavailable when the server is disconnected from the network, the switch is abnormal, the network is abnormal, etc.
[0057] In one embodiment, the connection status information between multiple servers and multiple networks respectively includes first connection status information between the first server and the multiple networks respectively, and second connection status information between other servers and the multiple networks respectively; wherein step S201 specifically includes the following steps: the first server obtains the first connection status information; the first server publishes the first connection status information in the server cluster corresponding to the second network, so that other servers obtain the first connection status information, the second network is a network normally connected to the first server, and the server cluster corresponding to the second network includes multiple message queue servers respectively deployed on multiple servers; the first server receives subscribed second connection status information in the server clusters corresponding to the multiple networks respectively.
[0058] Specifically, taking the case where there are only networks A and B as an example, if an abnormality occurs in network A on the first server and network B is normal, the first server switches to network B, and sends a message to the server cluster corresponding to network B. Due to the existence of a multi-subscription mechanism, other servers can also subscribe to messages from the server cluster corresponding to network B. Therefore, other servers will receive the message of the abnormality of network A on the first server, and thus other servers will also switch to network B.
[0059] In one example, the second network may be a network currently used for information exchange, such as network A. Before receiving the subscription message, the first server may determine the connection status of network A. If the connection status of network A is normal, network A will continue to be used. In another example, the second network may also be a switched network. For example, if the network connection of the currently used network A is abnormal, network B will be switched to and messages will be exchanged through network B.
[0060] In the embodiment, all servers publish messages through only one server cluster, but subscribe to messages from all server clusters. That is, for the same message topic that needs to be subscribed, the client subscribes to multiple server clusters respectively; for the message that needs to be sent, the client selects a server cluster with normal network status among multiple networks to send the message, thereby ensuring the reliability of message interaction.
[0061] Step S202: The first server determines, according to the network status information, a first network among the multiple networks that is normally connected to the multiple servers.
[0062] In the embodiment, the client in the first server establishes a connection with the server cluster corresponding to multiple networks, and the client subscribes to messages of network status information from all server groups, so as to obtain network connection status information of the local server and other servers. In order to ensure the interaction between different clients, all clients must judge the network status corresponding to all servers. Only when a certain network is normally connected to multiple servers can it be determined that the network is the first network, and only when it is determined to be the first network can it be used as a network for server information interaction.
[0063] For ease of understanding, the following different numbers of networks are used to illustrate the “first network” in the embodiment of the present application:
[0064] Assume that there are four servers, and the four servers are connected to network A and network B respectively. If the connection status between the four servers and network A is normal, then network A is the first network; if the connection status between one server and network A is abnormal, then network A is not the first network. The first network can be the network currently used for information exchange, or it can be an unused network.
[0065] Step S203: The first server exchanges information with other servers among the multiple servers through the first network.
[0066] In the embodiment, the information interaction between the servers includes the information interaction between the clients running on the servers. The clients are connected to the corresponding server cluster through the message queue server.
[0067] The following describes the network switching of the client using the situation of two networks.
[0068] The first client runs on the first server, which is connected to both network A and network B. The message queue server A1 corresponding to network A and the cluster where message queue server A1 is located are server cluster A1; the message queue server B1 corresponding to network B1 and the cluster where message queue server B1 is located are server cluster B1; the first client creates two client objects, client-A1 and client-B1, which are used to connect to message queue server A1 and message queue server B1 respectively. At this moment, the first client sends a message to server cluster A1 through message queue server A1. The first client subscribes to message topics from both server cluster A1 and server cluster B1, and backs up all subscribed message topics:
[0069] If the first client determines that the A networks on the first server and other servers are normal according to the network status information, it continues to send messages to the server cluster A1 through the message queue server A1;
[0070] If the first client determines that the network A on the first server or other servers is abnormal according to the network status information, the first client chooses to send a message to the server cluster B1 through the message queue server B1.
[0071] Optionally, after switching the network and establishing a connection with the new server cluster, the first client re-subscribes to the message topics to which the first client had subscribed before re-establishing the connection (backing up all subscribed message topics), and re-subscribes to the network status information message topic, thereby receiving the network connection status of other servers and multiple networks.
[0072] The following describes the selection of the client's message queue server using two network scenarios.
[0073] The first client runs on the first server, which has two networks, A and B. The message queue server A1 corresponds to the A network, and the cluster where the message queue server A1 is located is the server cluster A1; the message queue server B1 corresponds to the B1 network, and the cluster where the message queue server B1 is located is the server cluster B1; the first client creates two client objects, client-A1 and client-B1, which are used to connect to the message queue server A1 and the message queue server B1 respectively. At this moment, the first client sends a message to the server cluster A1 through the message queue server A1. The first client subscribes to the message topic from both the server cluster A1 and the server cluster B1, and backs up all subscribed message topics:
[0074] If the first client determines based on the network status information that network A and network B on the first server and other servers are normal, and determines that the connection between the first client and the message queue server A1 is normal, the first client continues to send messages (such as backup messages in the local cache) to the server cluster A1.
[0075] If the first client determines based on the network status information that network A and network B on the first server and other servers are normal, and determines that the connection between the first client and the message queue server A1 is abnormal, the first client disconnects from the message queue server A1 and selects other message queue servers located on other servers in the server cluster A1 for connection.
[0076] Optionally, when the first client selects another message queue server on network A for connection, if the connection is unsuccessful, the first client will select the next message queue server on network A for connection.
[0077] In the embodiment, the first client preferentially selects the message queue server of the local server for connection. If the server network is normal, but the message queue server itself is abnormal, the message queue server of other servers on the same network as the local message queue server is sequentially traversed for connection. In this case, only the message queue server is switched, and the network is not switched.
[0078] In the embodiment, a server cluster is a cluster composed of message queue servers, which plays the role of a message bus, connects all clients in the same server cluster, and can interact with other clients by sending messages to the server cluster and receiving subscription messages. The message interaction is carried out through the server cluster method, and since the message queue server is set on each service, the load balancing of the message can be guaranteed.
[0079] In one embodiment, step S203 specifically includes:
[0080] The first server obtains a first subscription message corresponding to the first message topic from the server cluster corresponding to the first network, where the first message topic is a message topic to which the first server subscribes respectively from all server clusters corresponding to multiple networks, and the subscription message is published by other servers among the multiple servers;
[0081] The first server publishes a backed-up second subscription message to the server set corresponding to the first network, where the second subscription message is a subscription message corresponding to a second message topic subscribed by the other servers.
[0082] In the embodiment, the first subscription message is obtained by the first server from the server cluster by subscription, and the second subscription message is a message sent by the first server to other servers. By backing up the published message (the second subscription message), the loss of the message is prevented. For example, when the network is switched, the backed-up message can be resent, thereby preventing the loss of the message during the network switching process and ensuring the security and integrity of the message.
[0083] In an embodiment, the backing up of the second subscription message by the first server specifically backs up a preset number of second subscription messages within a preset time period.
[0084] Specifically, the preset time period is preferably the time period closest to the current time, which can be determined according to needs. Optionally, the more preset numbers, the higher the security, which can be determined by those skilled in the art according to actual needs. In an optional embodiment, the preset number is 2000.
[0085] In one embodiment, the communication method includes a process for maintaining the cluster state, such as Figure 3 The flowchart of the cluster state maintenance method is shown as follows: Figure 3 As shown, the cluster state maintenance method includes:
[0086] Step S301: The first server obtains local cluster status information, where the local cluster status information includes status information of multiple first server clusters, where the multiple first server clusters are server clusters where multiple message queue servers corresponding to multiple networks in the first server are located.
[0087] In the embodiment, the first server cluster is any one of all server clusters, each first server cluster includes a plurality of message queue servers, and each server cluster corresponds to a network.
[0088] It is understandable that the cluster status information includes the name and status of the message queue server included in the cluster. The local cluster status information is the result obtained by the first server from the local message queue server. Specifically, the cluster daemon queries the local message queue server for the cluster status information of the corresponding server cluster.
[0089] Step S302: If there is no abnormal state information in the local cluster state information, the first server sends the local cluster state information to other servers, and the local cluster state information is the first normal cluster state information.
[0090] In the embodiment, the cluster state information has no abnormality, which mainly means that the cluster state information includes the names of all message queue servers and the states of all message queue servers are normal. In this case, the normal local cluster state information is sent to other servers.
[0091] In one embodiment, Figure 3 As shown, the cluster state maintenance method also includes:
[0092] Step S303: If there is abnormal state information in the local cluster state information, the first server updates the local cluster state information according to the abnormal state information, obtains first normal cluster state information, and sends the obtained first normal cluster state information to other servers.
[0093] In the embodiment, if there is an abnormality in the cluster status information, the first server manages the abnormal server cluster so that the corresponding cluster status returns to normal.
[0094] In one embodiment, updating the local cluster state information according to the abnormal state information to obtain the first normal cluster state information in step S303 specifically includes:
[0095] If the abnormal status information includes the first abnormal information, the first server notifies other servers to restart the message queue server belonging to the first server cluster, and obtains the first normal cluster status information; the first abnormal information indicates that there is a message queue server that does not work normally in the first server cluster;
[0096] If the abnormal status information includes second abnormal information, the second abnormal information indicates that there is a first message queue server that has stopped working, the first server deletes the first message queue server from the first server cluster and obtains the first normal cluster status information.
[0097] In the embodiment, the first server cluster is a server cluster whose abnormal state information is the first abnormal information. To facilitate understanding, different abnormal situations are described below.
[0098] In an embodiment, the recovery of the abnormal situation of the first abnormal information can be achieved by restarting the server. In an example, the situation where the message queue does not work properly may be that the message queue cannot be self-started after being closed, the message queue cannot join the cluster, etc. In the first abnormal situation, the message queue server in the first server cluster can be restarted, and the message queue server with the abnormality can also be selectively restarted.
[0099] For example, "the message queue cannot be restarted after being shut down" can be manifested as the status information after the message queue server name appears in the cluster status information is "not responding" and the status lasts for 20 seconds. "The message queue cannot join the cluster" can be specifically manifested as the status information after the message queue server name appears in the cluster status information is "Exit" and has not been restored for 60 seconds.
[0100] In another abnormal situation in the embodiment, the second abnormal information cannot be recovered by restarting the message queue server, so the corresponding message queue server is kicked out of the cluster, and only the normal message queue server is used to form a new server cluster. If the server cluster is a cluster for client data interaction, the client originally connected to the kicked message queue server can switch the message queue server in the updated cluster.
[0101] Optionally, the message queue server stops working as shown in the cluster status information, followed by the name of the message queue server, and the status information is "stopping_nodes". During the specific recovery operation, the message queue server corresponding to "stopping_nodes" is kicked out from the cluster.
[0102] Optionally, after the first server deletes the first message queue server from the first server cluster, the method further includes:
[0103] The first server reacquires local cluster status information, and if the local cluster status information shows that the first message queue server has recovered to normal, the first server re-adds the first message queue server to the corresponding server cluster.
[0104] Specifically, a cluster daemon is set in each server, and the cluster daemon is responsible for kicking out a stopped message queue server from the server cluster, and rejoining a message queue server that has been kicked out of the cluster and has recovered to normal to the cluster.
[0105] Optionally, if server 1 is connected to network A and network B, message queue server A corresponds to network A, and message queue server B corresponds to network B; when network A fails, message queue server A fails and cannot work, so the cluster daemon on other servers kicks the message queue server out of the cluster. When network A returns to normal, message queue server A returns to normal, and the cluster daemon on server 1 adds message queue server A to the cluster.
[0106] In an embodiment, the normal cluster state information may be sent through a network in the form of a UDP (User Datagram Protocol) message. Optionally, the normal cluster state information may be sent through a network corresponding to the cluster.
[0107] In one embodiment, Figure 3 As shown, the cluster state maintenance method also includes:
[0108] Step S304: The first server receives second normal cluster status information sent by other servers.
[0109] In the embodiment, the servers send and receive normal cluster status information to each other.
[0110] Step S305: The first server updates multiple first server clusters according to the first normal cluster state information and the second normal cluster state information.
[0111] In the embodiment, multiple first server clusters are updated according to the first normal cluster status information and the second normal cluster status information, mainly for coping with the cluster brain split situation, where the cluster brain split refers to the same cluster being split into multiple clusters. Since different servers obtain the cluster status information of the corresponding server cluster through their respective message queue server queries, if a cluster brain split occurs, the cluster status information detected by different servers will be different. In order to ensure the cluster status information, different clusters need to be restored to the same cluster.
[0112] In one embodiment, the cluster status information includes the name of each contained message queue server, and the step S305 specifically includes:
[0113] Compare the names in the first normal cluster state information and the second normal cluster state information to obtain a comparison result;
[0114] Determining whether the first normal cluster state information and the second normal cluster state information are the same according to the comparison result;
[0115] If yes, return to step S301;
[0116] If not, the first normal cluster state information and the second normal cluster state information are restored to the same cluster state information.
[0117] For example, it is assumed that the number of names in the first normal cluster state information is N1, and the number of names in the second normal cluster state information is N2. According to different comparison results, the method of restoring the cluster state information is different and is specifically described as follows:
[0118] If N1>N2, the first server receives the names in the second normal cluster state information, adds them to the first normal cluster state information, and deletes the duplicate names.
[0119] If N1<N2, the first server adds the names in the first normal cluster state information to the first normal cluster state information, and deletes the duplicate names.
[0120] If N1=N2>1, compare the first IP address corresponding to the first server with the second IP addresses corresponding to the other servers: if the first IP address is greater than the second IP address, the first server adds the name in the first normal cluster status information to the first normal cluster status information and deletes the duplicate name; if the first IP address is less than the second IP address, the first server receives the name in the second normal cluster status information, adds it to the first normal cluster status information, and deletes the duplicate name.
[0121] If N1=N2=1, the first IP address corresponding to the first server is compared with the third IP address of the smallest IP address among all IP addresses corresponding to other servers received by the first server within 5 seconds. If the first IP address is greater than the third IP address, the first server adds the name in the first normal cluster status information to the first normal cluster status information and deletes the duplicate name; if the first IP address is greater than the third IP address, the first server receives the name in the second normal cluster status information, adds it to the first normal cluster status information, and deletes the duplicate name.
[0122] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0123] Corresponding to the communication method described in the above embodiment, Figure 4 A structural block diagram of a communication device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0124] Reference Figure 4 , the communication device 40 comprises:
[0125] A first acquisition unit 41 is used to acquire network status information, where the network status information includes connection status information between a plurality of servers and a plurality of networks respectively, where the plurality of servers include the first server;
[0126] A determining unit 42, configured to determine, according to the network status information, a first network among the multiple networks that is normally connected to the multiple servers;
[0127] The information interaction unit 43 is configured to interact with other servers in the plurality of servers through the first network.
[0128] Optionally, the connection status information between the multiple servers and the multiple networks respectively includes first connection status information between the first server and the multiple networks respectively, and second connection status information between other servers and the multiple networks respectively; when the first acquisition unit 41 is used to obtain network status information, it is specifically used to: obtain the first connection status information; publish the first connection status information in a server cluster corresponding to the second network, so that the other servers obtain the first connection status information, the second network is a network normally connected to the first server, and the server cluster corresponding to the second network includes multiple message queue servers respectively deployed on multiple servers; the server clusters corresponding to the multiple networks receive the subscribed second connection status information.
[0129] Optionally, the communication device 40 also includes a second acquisition unit and a first sending unit: the second acquisition unit is used to acquire local cluster status information, the local cluster status information includes status information of multiple first server clusters, and the multiple first server clusters are server clusters in the first server where multiple message queue servers corresponding to the multiple networks are located respectively; the first sending unit is used to send the local cluster status information to the other servers if there is no abnormal status information in the local cluster status information, and the local cluster status information is the first normal cluster status information.
[0130] Optionally, the communication device 40 further includes a first updating unit, which is configured to update the local cluster state information according to the abnormal state information if there is abnormal state information in the local cluster state information, obtain first normal cluster state information, and send the obtained first normal cluster state information to other servers.
[0131] Optionally, when the first update unit is used to update the local cluster status information according to the abnormal status information to obtain the first normal cluster status information: if the abnormal status information includes first abnormal information, the update unit notifies the other servers to restart the message queue server belonging to the first server cluster, and obtains the first normal cluster status information; the first abnormal information indicates that there is a message queue server that is not working normally in the first server cluster; if the abnormal status information includes second abnormal information, the second abnormal information indicates that the first message queue server has stopped working, the update unit deletes the first message queue server from the first server cluster, and obtains the first normal cluster status information.
[0132] Optionally, the communication device 40 further includes a receiving unit and a second updating unit: the receiving unit is used to receive the second normal cluster state information sent by the other servers; the second updating unit is used to update multiple first server clusters according to the first normal cluster state information and the second normal cluster state information.
[0133] Optionally, when the information interaction unit 43 is used to interact information with other servers among the multiple servers through the first network, it is specifically used to: when subscribing to a target message topic, back up all messages corresponding to the target message topic; publish messages to the server cluster corresponding to the first network; and back up a preset number of messages published within a preset time period.
[0134] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0135] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0136] Based on the same inventive concept, an embodiment of the present application also provides a server. Figure 5 As shown, the server 500 of this embodiment includes: a processor 501, a memory 502, and a computer program 504 stored in the memory 502 and executable on the processor 501. The computer program 504 can be executed by the processor 501 to generate instructions 503, and the processor 501 can implement the steps in the above-mentioned various image color optimization method embodiments according to the instructions 503. Alternatively, when the processor 501 executes the computer program 504, the functions of the modules / units in the above-mentioned various device embodiments are implemented, such as Figure 4 The functions of the first acquisition unit 41 to the information interaction unit 43 are shown.
[0137] Exemplarily, the computer program 504 may be divided into one or more modules / units, one or more modules / units are stored in the memory 502, and are executed by the processor 501 to complete the present application. One or more modules / units may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program 504 in the server 500.
[0138] The processor 501 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
[0139] The memory 502 may be an internal storage unit of the server 500, such as a hard disk or memory of the server 500. The memory 502 may also be an external storage device of the server 500, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the server 500. Further, the memory 502 may also include both an internal storage unit of the server 500 and an external storage device. The memory 502 is used to store computer programs and other programs and data required by the server 500. The memory 502 may also be used to temporarily store data that has been output or is to be output.
[0140] An embodiment of the present application further 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 steps performed by the first server in the above-mentioned various method embodiments are implemented.
[0141] An embodiment of the present application provides a computer program product. When the computer program product runs on a server, the server can implement the steps performed by the first server in the above-mentioned various method embodiments when executing the computer program product.
[0142] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the device / server, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0143] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0144] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0145] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / server embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0146] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0147] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A communication method, characterized in that: include: The first server acquires network status information, the network status information including connection status information between a plurality of servers and a plurality of networks respectively, the plurality of servers including the first server; The first server determines, according to the network status information, a first network among the multiple networks that is normally connected to the multiple servers; The first server exchanges information with other servers among the multiple servers through the first network; The connection status information between the multiple servers and the multiple networks respectively includes first connection status information between the first server and the multiple networks respectively, and second connection status information between other servers and the multiple networks respectively; The first server obtains the network status information, specifically including: The first server obtains the first connection status information; The first server publishes the first connection status information in a server cluster corresponding to a second network, so that the other servers obtain the first connection status information, the second network is a network normally connected to the first server, and the server cluster corresponding to the second network includes a plurality of message queue servers respectively deployed on a plurality of servers; The first server receives the subscribed second connection state information from the service-side clusters corresponding to the multiple networks respectively.
2. The communication method according to claim 1, characterized in that: The communication method further comprises: The first server obtains local cluster status information, where the local cluster status information includes status information of multiple first server clusters, where the multiple first server clusters are server clusters where multiple message queue servers corresponding to the multiple networks in the first server are located respectively; If the local cluster state information does not contain abnormal state information, the first server sends the local cluster state information to the other servers, and the local cluster state information is first normal cluster state information.
3. The communication method according to claim 2, characterized in that: Also includes: If the local cluster state information contains abnormal state information, the first server updates the local cluster state information according to the abnormal state information to obtain first normal cluster state information, and sends the obtained first normal cluster state information to other servers.
4. The communication method according to claim 3, characterized in that: The updating of the local cluster state information according to the abnormal state information to obtain the first normal cluster state information specifically includes: If the abnormal status information includes first abnormal information, the first server notifies the other servers to restart the message queue server belonging to the first server cluster, and obtains the first normal cluster status information; the first abnormal information indicates that there is a message queue server that does not work normally in the first server cluster; If the abnormal status information includes second abnormal information, and the second abnormal information indicates that the first message queue server stops working, the first server deletes the first message queue server from the first server cluster and obtains the first normal cluster status information.
5. The communication method according to claim 3 or 4, characterized in that: Also includes: The first server receives the second normal cluster state information sent by the other servers; The first server updates a plurality of first service-end clusters according to the first normal cluster state information and the second normal cluster state information.
6. The communication method according to claim 1, characterized in that: The first server interacts with other servers in the plurality of servers through the first network, specifically including: The first server obtains a first subscription message corresponding to a first message topic from a server cluster corresponding to the first network, where the first message topic is a message topic to which the first server subscribes respectively from all server clusters corresponding to multiple networks, and the subscription message is published by other servers among the multiple servers; The first server publishes a backed-up second subscription message to the server set corresponding to the first network, where the second subscription message is a subscription message corresponding to a second message topic subscribed by the other servers.
7. A server comprising a processor, a memory and a computer program stored in the memory, characterized in that: When the computer program is executed by a processor, the communication method according to any one of claims 1 to 6 is implemented.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the communication method according to any one of claims 1 to 6 is implemented.
9. A communication system, characterized in that: It comprises a plurality of servers as claimed in claim 7, wherein the plurality of servers are respectively connected to a plurality of networks, each network corresponds to a server cluster, and the server cluster comprises a plurality of message queue servers respectively deployed on the plurality of servers.
