A cluster handover method, device, apparatus and storage medium
By acquiring and resolving domain name information, the system can determine the status of EJB cluster nodes and switch clusters, solving the problem of inconvenient and untimely EJB cluster switching and achieving efficient cluster switching and system availability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN KINGDEE MIDDLEWARE
- Filing Date
- 2023-04-06
- Publication Date
- 2026-06-12
AI Technical Summary
When existing EJB clusters become unavailable, the failover process is inconvenient and untimely, failing to meet high availability requirements.
By obtaining the domain name information, the corresponding resolution information is obtained, the current cluster structure information is obtained, and the node status is determined based on the node liveness detection method. If all nodes are unavailable, the cluster pointed to by the domain name is switched.
It simplifies the development process, improves the convenience of cluster switching and system availability, reduces switching time, and meets business needs.
Smart Images

Figure CN116471257B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a cluster switching method, apparatus, device, and storage medium. Background Technology
[0002] Compared to currently popular web applications, EJB (Enterprise JavaBeans) technology has less mature high-availability solutions. For example, if an entire EJB cluster becomes unavailable, immediately activating a backup cluster without interrupting business operations is a challenge. Currently, before calling an EJB, the EJB object must be obtained. Before obtaining the EJB object, the addresses of the JNDI (Java Naming and Directory Interface) naming service must be specified through a list, which contains all nodes in the cluster. Currently, cluster switching can only be performed according to the address list or manually controlled, lacking convenience and timeliness, and failing to meet current business requirements. Summary of the Invention
[0003] In view of this, the purpose of this invention is to provide a cluster switching method, apparatus, device, and storage medium that simplifies the development process and improves the convenience of cluster switching and system availability. The specific solution is as follows:
[0004] In a first aspect, this application discloses a cluster switching method, including:
[0005] Obtain domain name information and parse the domain name information to obtain the corresponding resolution information;
[0006] Based on the parsed information, obtain the cluster structure information corresponding to the current target cluster;
[0007] Based on the cluster structure information and the preset node liveness detection method, it is determined whether all nodes in the target cluster are unavailable;
[0008] If all nodes in the specified cluster are unavailable, then the specified cluster for the domain name information is switched.
[0009] Optionally, resolving the domain name information to obtain corresponding resolution information includes:
[0010] The domain name information is parsed to obtain a set of IP addresses; the IP addresses in the set of IP addresses are the IP addresses that point to the cluster.
[0011] Optionally, obtaining the cluster structure information corresponding to the current pointer cluster based on the parsed information includes:
[0012] Determine the target IP address from the set of IP addresses and obtain the corresponding port number;
[0013] Obtain the corresponding JNDI naming service based on the target IP address and the port number;
[0014] The target EJB object is obtained based on the JNDI naming service, and the cluster structure information corresponding to the target EJB object is obtained based on the target EJB object.
[0015] Optionally, obtaining the cluster structure information corresponding to the target EJB object includes:
[0016] Access the business method of the target EJB object to obtain the corresponding response information and the cluster structure information.
[0017] Optionally, determining whether all nodes in the target cluster are unavailable based on the cluster structure information and a preset node liveness detection method includes:
[0018] Based on the response information and the cluster structure information, it is determined whether all nodes in the target cluster are unavailable.
[0019] Optionally, if all the nodes in the target cluster are unavailable, after switching the target cluster of the domain name information, the method further includes:
[0020] The domain name information is re-parsed to obtain the latest resolution information corresponding to the latest pointing cluster; the latest pointing cluster is the cluster after the pointing cluster of the domain name information is switched.
[0021] Based on the latest parsed information, re-enter the step of obtaining the corresponding JNDI naming service based on the target IP address and the port number;
[0022] Alternatively, based on the latest parsed information, one can re-enter the step of obtaining the cluster structure information corresponding to the target EJB object.
[0023] Optionally, after determining whether all nodes in the target cluster are unavailable based on the cluster structure information and a preset node liveness detection method, the method further includes:
[0024] If there is an available node among all the nodes in the specified cluster, then the user's access request is allocated based on the preset load balancing rules.
[0025] Secondly, this application discloses a cluster switching device, comprising:
[0026] The domain name resolution module is used to obtain domain name information and parse the domain name information to obtain the corresponding resolution information;
[0027] The structure information acquisition module is used to acquire the cluster structure information corresponding to the current target cluster based on the parsed information;
[0028] The node determination module is used to determine whether all nodes in the target cluster are unavailable based on the cluster structure information and a preset node liveness determination method.
[0029] The cluster switching module is used to switch the cluster to which the domain name information points if all the nodes in the target cluster are unavailable.
[0030] Thirdly, this application discloses an electronic device, including:
[0031] Memory, used to store computer programs;
[0032] A processor is configured to execute the computer program to implement the steps of the cluster switching method disclosed above.
[0033] Fourthly, this application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the cluster switching method disclosed above.
[0034] Fifthly, this application discloses a computer program product, including a computer program, wherein when the computer program is executed by a processor, it implements the cluster switching method disclosed above.
[0035] As can be seen, this application provides a cluster switching method, including: obtaining domain name information and resolving the domain name information to obtain corresponding resolution information; obtaining cluster structure information corresponding to the current target cluster based on the resolution information; determining whether all nodes in the target cluster are unavailable based on the cluster structure information and a preset node liveness detection method; and switching the target cluster based on the domain name information if all nodes in the target cluster are unavailable. Therefore, this application controls the current target cluster through domain name information, and re-resolves the domain name information to switch clusters when all nodes are unavailable. This simplifies the development process, improves the convenience of cluster switching and system availability, significantly saves the switching time of available cluster nodes, and promptly meets business needs. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0037] Figure 1 This is a flowchart of a cluster switching method disclosed in this application;
[0038] Figure 2 This is a flowchart of a specific cluster switching method disclosed in this application;
[0039] Figure 3 This is a flowchart of a specific cluster switching method disclosed in this application;
[0040] Figure 4 This is a schematic diagram of the cluster switching device structure provided in this application;
[0041] Figure 5 This application provides a structural diagram of an electronic device. Detailed Implementation
[0042] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0043] This application provides a cluster switching method that simplifies the development process and improves the ease of switching clusters and the availability of the system.
[0044] This invention discloses a cluster handover method, see [link to relevant documentation]. Figure 1 As shown, the method includes:
[0045] Step S11: Obtain domain name information and parse the domain name information to obtain the corresponding resolution information.
[0046] In this embodiment, domain name information is obtained and parsed to obtain corresponding resolution information. Specifically, the domain name information is parsed to obtain a set of IP addresses; the IP addresses in the IP address set are the IP addresses corresponding to the cluster. It should be noted that the information in the IP address set is the IP addresses corresponding to one, some, or all of the cluster members in the cluster. It should be noted that multiple distributed computer nodes provide services to the outside world as a unified whole; this whole is called a cluster. A cluster can provide stronger service capabilities than a single node; for example, the cluster can be an EJB cluster. It is understood that in the prior art, an EJB object must be obtained before calling an EJB. According to the JNDI standard API, before obtaining the EJB object, the addresses of the JNDI naming service must be specified through a list. This address list contains all nodes in the cluster, for example:
[0047] env.put(Context.PROVIDER_URL,"iiop: / / S1:6888,S2:6888,S3:6888");
[0048] Context ctx=new InitialContext(env);
[0049] HelloHome helloHome=(HelloHome)ctx.lookup("ejb / hello");
[0050] Hello hello=helloHome.create();
[0051] The above "iiop: / / S1:6888,S2:6888,S3:6888" represents the information for all nodes in the cluster. In a dual-cluster scenario, assuming each cluster has two nodes, when retrieving an EJB object, all members from both clusters need to be placed in a list, with the following structure:
[0052] Cluster 1: {192.168.3.11:6888,192.168.3.12:6888}
[0053] Cluster 2: {192.168.4.21:6888,192.168.4.22:6888}
[0054] With a dual-cluster configuration and two nodes in each cluster, the address list is as follows:
[0055] env.put(Context.PROVIDER_URL,
[0056] "iiop: / / 192.168.3.11:6888,192.168.3.12:6888,192.168.4.21:6888,192.168.4.22:6888");
[0057] Existing technologies require specifying all nodes in two clusters during development, necessitating the maintenance of a list containing all node information, which is inconvenient. There are two ways to arrange the list members: 1. When all nodes from cluster 1 are listed first and all nodes from cluster 2 are listed last, if cluster 1 becomes unavailable, all nodes in cluster 1 need to be tried, and only if all fail will nodes in cluster 2 be tried. This increases cluster switching time, especially with large clusters. 2. When the nodes in the two clusters are arranged alternately, if the first node in cluster 1 becomes unavailable, the first node in cluster 2 can be tried immediately. This greatly shortens the cluster switching time. However, once switched to cluster 2, unless a node in cluster 2 fails again, it will not automatically switch back to cluster 1 and will continue running in cluster 2. To switch back to cluster 1, other methods must be actively used, such as using timers to periodically update EJB references, which requires additional programming overhead. Therefore, when specifying the JNDI naming service address in `new InitialContext(env)`, this application no longer specifies a list of all members of both clusters, but only a single domain name. Domain names are generally stable in business applications and are not easily changed. Furthermore, using a single domain name to represent the entire cluster or even both clusters is simple and easy to operate, reducing the burden on programmers. For example:
[0058] env.put(Context.PROVIDER_URL,"iiop: / / myserver.com:6888");
[0059] Context ctx=new InitialContext(env);
[0060] After receiving the domain name, the system will resolve it to obtain the corresponding DNS information. It's understandable that EJB technology is the server-side component architecture of Java Platform, Enterprise Edition (Java EE). EJB technology supports the rapid and simplified development of distributed, transactional, secure, and portable applications based on Java technology. Multiple distributed computer nodes provide services as a unified whole; this whole is called a cluster, and a cluster can provide stronger service capabilities than a single node. JNDI is an Application Programming Interface (API) that provides naming and directory functionality for applications written in the Java programming language, and is defined as independent of any specific directory service implementation.
[0061] Step S12: Obtain the cluster structure information corresponding to the current target cluster based on the parsed information.
[0062] In this embodiment, after obtaining the domain name information and parsing it to obtain the corresponding resolution information, the cluster structure information corresponding to the current target cluster is obtained based on the resolution information. It can be understood that the target EJB object can be obtained based on the resolution information. Then, by accessing the business methods of this EJB object, the current cluster structure information (the list of cluster members) is obtained, and this current cluster structure information is automatically transmitted between the server and the client, so that the client can access each member of the cluster in a load-balanced manner based on the current cluster structure information.
[0063] Step S13: Based on the cluster structure information and the preset node liveness detection method, determine whether all nodes in the target cluster are unavailable.
[0064] In this embodiment, after obtaining the cluster structure information corresponding to the current target cluster based on the parsed information, it is determined whether all nodes in the target cluster are unavailable based on the cluster structure information and a preset node liveness determination method. It is understood that if there are available nodes among all the nodes in the target cluster, the user's access request is allocated based on a preset load balancing rule. It should be noted that during the development (or program execution) liveness determination phase, no specific liveness determination operation needs to be performed. Instead, a certain node (let's say A) is assumed to be live, and access is allowed normally. When access is impossible due to connection failure, communication anomalies, or other reasons, the node (e.g., node A) is naturally considered unavailable. At this time, the client selects the next cluster member B from its own cluster member list according to the load balancing strategy to continue accessing. If this access is successful, a new cluster member list is returned to the client along with the response from B. The unavailable node is then removed from the original cluster member list to obtain the new cluster member list, meaning that node A is not included in the new cluster member list. Therefore, when the client accesses the target cluster again, it will not access node A.
[0065] Specifically, node liveness detection methods are divided into two scenarios: operation and maintenance (O&M) stage and development (or program execution) stage. During O&M stage detection, for example, if the entire data center hosting Cluster 1 experiences a power outage, O&M personnel can determine that Cluster 1 is unavailable, or that the intelligent DNS server is not receiving heartbeat information from all members of Cluster 1. During development stage detection, the most basic method is to consider Cluster 1 as unavailable if all members are inaccessible. Further, a list of live servers can be obtained from the intelligent DNS. It's understandable that during O&M, the intelligent DNS maintains close contact with each member of the cluster via heartbeats, readily accepting new members or removing unavailable ones to keep the cluster member list up-to-date. It should be noted that while the intelligent DNS possesses the latest cluster member list, when a client resolves a domain name, it may not necessarily return all member IPs, but only the IP of one member, typically ensuring that the member corresponding to that IP is available. The process of ensuring that the member corresponding to this IP is available has the following limitations: it is within the time frame of either intelligent DNS or ordinary DNS. The time frame refers to the fact that DNS binding of domain names to IPs is not completely real-time, but has a certain lag, although this lag is usually short and within an acceptable range for engineering purposes. The client only needs to obtain a live IP by resolving the domain name, and then access the EJB's business methods to ultimately obtain the entire cluster's member list (here referred to as A). This member list is the actual member list, maintained by the application server EJB cluster itself. Under normal circumstances, considering the time frame, the above-mentioned entire cluster's member list (here referred to as A) is basically the same as the cluster list maintained by DNS (here referred to as B), but the client uses cluster list A as the reference.
[0066] Step S14: If all the nodes in the target cluster are unavailable, then switch the target cluster of the domain name information.
[0067] In this embodiment, after determining whether all nodes in the target cluster are unavailable based on the cluster structure information and a preset node liveness detection method, if all nodes in the target cluster are unavailable, the target cluster of the domain name information is switched. It can be understood that when cluster 1 is entirely unavailable, the domain name can be switched (manually by maintenance personnel or automatically by a program) to the IP address of one or more members in cluster 2 (i.e., the IP address corresponding to cluster 2 can be one or more). When a user obtains or accesses EJB and finds that all nodes in cluster 1 are inaccessible, the domain name is automatically re-resolved to obtain a new IP address, and the process re-enters the step of obtaining the naming service or the step of forming the internal cluster structure of the system, based on the current execution progress, thereby switching to cluster 2. If the domain name is switched in time, the user will not be aware that the cluster has been switched, meaning the cluster switch has no impact on the user; if the switch is not timely enough, access may be unavailable or errors may occur for a short period, but everything will return to normal once the switch is complete.
[0068] As can be seen, this application provides a cluster switching method, including: obtaining domain name information and resolving the domain name information to obtain corresponding resolution information; obtaining cluster structure information corresponding to the current target cluster based on the resolution information; determining whether all nodes in the target cluster are unavailable based on the cluster structure information and a preset node liveness detection method; and switching the target cluster based on the domain name information if all nodes in the target cluster are unavailable. Therefore, this application controls the current target cluster through domain name information, and re-resolves the domain name information to switch clusters when all nodes are unavailable. This simplifies the development process, eliminates the need for developers to maintain a cluster member list, improves the convenience of cluster switching and system availability, significantly saves the switching time of available cluster nodes, and promptly meets business needs.
[0069] See Figure 2 As shown, this embodiment of the invention discloses a cluster switching method. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution.
[0070] Step S21: Obtain domain name information and parse the domain name information to obtain the corresponding resolution information.
[0071] Step S22: Determine the target IP address from the set of IP addresses and obtain the corresponding port number. Obtain the corresponding JNDI naming service based on the target IP address and the port number.
[0072] In this embodiment, the domain name information is parsed to obtain the set of IP addresses contained in the corresponding parsing information. Therefore, after obtaining the set of IP addresses, the target IP address is determined from the set of IP addresses, and the corresponding port number is obtained. Based on the target IP address and the port number, the corresponding JNDI naming service is obtained. It should be noted that resolving a domain name can only obtain the IP address, not the port number. The port number is specified during programming, and all members in the cluster use the same port number. It is understood that, as... Figure 3 As shown, after receiving the domain name, the system resolves the IP address behind it. If multiple IP addresses exist, the first one is generally selected as the target IP address. If the first IP address is unavailable, the next IP address is selected as the target IP address; alternatively, an IP address is randomly selected as the target IP address. If this IP address is unavailable, another IP address is randomly selected as the target IP address, and so on, until the target IP address is found in the set of IP addresses or all IP addresses are unavailable. When an available address exists in the set of IP addresses, and the target IP address is determined, the JNDI naming service corresponding to the target IP address is obtained based on the IP address and port number. The EJB object to be accessed is then retrieved (lookup) based on the JNDI naming service. The port number is specified during programming, and the port number information is obtained directly, for example, "6888". If no usable address exists in the IP address set, and the system is currently in maintenance mode, the domain name information will be redirected to the cluster. If the system is currently in development mode, and all addresses in the IP address set are inaccessible, the domain name will be re-resolved. If the re-resolved IP address list differs from the original list, the user will attempt to access the site again. If the re-resolved IP address list is the same as the original list, an error message will be generated and sent to the user, informing them that access is unavailable.
[0073] It should be noted that during development, only a single domain name and port number are specified for the JNDI naming service address; the actual cluster address is controlled by the domain name; the Context object generated based on the naming service address should store information about the domain name, and the EJB object looked up through the Context object should also store this domain name information; this way, when executing EJB business methods, if calls to any member of cluster 1 are unavailable, re-resolution based on the domain name is possible. It should also be noted that when looking up the EJB object through the Context object, the current domain name information is stored in the EJB object, meaning that when the client retrieves the EJB object, the corresponding domain name information is already stored in the EJB object.
[0074] Step S23: Obtain the target EJB object based on the JNDI naming service, and obtain the cluster structure information corresponding to the cluster based on the target EJB object.
[0075] In this embodiment, after obtaining the corresponding JNDI naming service based on the target IP address and the port number, the target EJB object is obtained based on the JNDI naming service, and the cluster structure information corresponding to the cluster is obtained based on the target EJB object. Specifically, the business method of the target EJB object is accessed to obtain the corresponding response information and the cluster structure information. It is understood that when accessing the business method of the target EJB object, the returned response information and the cluster structure information returned along with the response information will be obtained. It is understood that the corresponding cluster structure information is constructed on the server side, and then the constructed cluster structure information is sent to the client along with the response information returned when the business method is accessed; the structure information includes the servers included in the current cluster and their corresponding address information, as well as the load balancing strategy when the EJB participates in the cluster and the weight information of each node.
[0076] Step S24: Based on the cluster structure information and the preset node liveness detection method, determine whether all nodes in the target cluster are unavailable.
[0077] Step S25: If all the nodes in the target cluster are unavailable, then switch the target cluster of the domain name information.
[0078] In this embodiment, after determining whether all nodes in the pointing cluster are unavailable based on the cluster structure information and a preset node liveness detection method, if all nodes in the pointing cluster are unavailable, the pointing cluster of the domain name information is switched. It can be understood that if all nodes in the pointing cluster are unavailable and the system is currently in an operation and maintenance phase, the pointing cluster of the domain name information is switched; if the system is currently in a development phase, the domain name information is re-parsed to obtain the latest resolution information corresponding to the latest pointing cluster, i.e., the IP address information pointed to by the domain name information is obtained; the latest pointing cluster is the cluster after switching the pointing cluster of the domain name information; based on the latest resolution information, the step of obtaining the corresponding JNDI naming service based on the target IP address and the port number is re-entered; or based on the latest resolution information, the step of obtaining the cluster structure information corresponding to the pointing cluster based on the target EJB object is re-entered. It can be understood that after re-parseing the domain name information to obtain the latest resolution information corresponding to the latest pointing cluster, the operations that were not successfully executed before the resolution are re-executed. For example, it determines whether the step of obtaining the JNDI naming service corresponding to the target IP address has been successfully executed. If it has not been executed or failed, the process re-enters the step of obtaining the corresponding JNDI naming service based on the target IP address and port number. If it was successfully executed, the business method is re-executed, for example, re-entering the step of obtaining the cluster structure information corresponding to the target EJB object based on the latest resolution information. It is understandable that when the domain name is re-resolved, it indicates that cluster 1 is unavailable overall, usually meaning that the unavailability is only discovered after a failure, thus requiring the re-execution of operations that failed before resolution.
[0079] This application simplifies the development process, eliminating the need for developers to maintain a cluster member list; cluster switching is implemented by the operations and maintenance team, allowing for more flexible timing, easier and faster switching, and easier switching back; it provides a feasible dual-cluster solution for EJB through domain name switching; dual clusters can enhance system availability.
[0080] For details regarding steps S21 and S24, please refer to the corresponding content disclosed in the foregoing embodiments, which will not be repeated here.
[0081] As can be seen, this embodiment of the application obtains domain name information and parses the domain name information to obtain corresponding resolution information; determines the target IP address from the IP address set and obtains the corresponding port number; obtains the corresponding JNDI naming service based on the target IP address and the port number; obtains the target EJB object based on the JNDI naming service; obtains the cluster structure information corresponding to the target cluster based on the target EJB object; determines whether all nodes in the target cluster are unavailable based on the cluster structure information and a preset node liveness detection method; if all nodes in the target cluster are unavailable, the target cluster of the domain name information is switched, which simplifies the development process and improves the convenience of switching clusters and the availability of the system.
[0082] See Figure 4 As shown in the illustration, this application also discloses a cluster switching device, comprising:
[0083] Domain name resolution module 11 is used to obtain domain name information and parse the domain name information to obtain corresponding resolution information;
[0084] The structure information acquisition module 12 is used to acquire the cluster structure information corresponding to the current target cluster based on the parsed information;
[0085] The node determination module 13 is used to determine whether all nodes in the target cluster are unavailable based on the cluster structure information and a preset node liveness determination method.
[0086] The cluster switching module 14 is used to switch the cluster to which the domain name information points if all the nodes in the cluster are unavailable.
[0087] As can be seen, this application includes: obtaining domain name information and parsing the domain name information to obtain corresponding resolution information; obtaining cluster structure information corresponding to the current target cluster based on the resolution information; determining whether all nodes in the target cluster are unavailable based on the cluster structure information and a preset node liveness detection method; and switching the target cluster based on the domain name information if all nodes in the target cluster are unavailable. Therefore, this application controls the current target cluster through domain name information, and re-parses the domain name information to switch clusters when all nodes are unavailable. This simplifies the development process, improves the convenience of switching clusters and the availability of the system, significantly saves the switching time of available cluster nodes, and promptly meets the needs of business operations.
[0088] In some specific embodiments, the domain name resolution module 11 specifically includes:
[0089] The information acquisition unit is used to acquire domain name information;
[0090] A domain name information resolution unit is used to resolve the domain name information to obtain a set of IP addresses; the IP addresses in the set of IP addresses are the IP addresses corresponding to the cluster.
[0091] In some specific embodiments, the structural information acquisition module 12 specifically includes:
[0092] A target IP address determination unit is used to determine a target IP address from the set of IP addresses;
[0093] The port number acquisition unit is used to obtain the corresponding port number.
[0094] The JNDI naming service determination unit is used to obtain the corresponding JNDI naming service based on the target IP address and the port number.
[0095] The target EJB object acquisition unit is used to acquire the target EJB object based on the JNDI naming service.
[0096] The information acquisition unit is used to access the business methods of the target EJB object to obtain the corresponding response information and the cluster structure information.
[0097] In some specific embodiments, the node determination module 13 specifically includes:
[0098] A node determination unit is used to determine, based on the response information and the cluster structure information, whether all nodes in the target cluster are unavailable.
[0099] The request allocation unit is used to allocate user access requests based on preset load balancing rules if there is an available node among all the nodes in the target cluster.
[0100] In some specific embodiments, the cluster switching module 14 specifically includes:
[0101] A cluster switching unit is used to switch the cluster to which the domain name information points if all the nodes in the cluster are unavailable.
[0102] A domain name information re-resolution unit is used to re-resolution the domain name information to obtain the latest resolution information corresponding to the latest pointing cluster; the latest pointing cluster is the cluster after the pointing cluster of the domain name information is switched.
[0103] The first execution unit is used to re-enter the step of obtaining the corresponding JNDI naming service based on the target IP address and the port number based on the latest parsing information;
[0104] The second execution unit is used to re-enter the step of obtaining the cluster structure information corresponding to the target EJB object based on the latest parsed information.
[0105] Furthermore, embodiments of this application also provide an electronic device. Figure 5 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0106] Figure 5 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the cluster switching method disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0107] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0108] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0109] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the cluster switching method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include a computer program capable of performing other specific tasks.
[0110] Furthermore, this application also discloses a storage medium storing a computer program, which, when loaded and executed by a processor, implements the cluster switching method steps disclosed in any of the foregoing embodiments.
[0111] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0112] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0113] The above provides a detailed description of the cluster switching method, apparatus, device, and storage medium provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A cluster handover method, characterized by, include: Obtain domain name information and parse the domain name information to obtain the corresponding resolution information; The parsed information includes a set of IP addresses; Based on the parsed information, obtain the cluster structure information corresponding to the current target cluster; Based on the cluster structure information and the preset node liveness detection method, it is determined whether all nodes in the target cluster are unavailable; If all nodes in the specified cluster are unavailable, then the specified cluster for the domain name information is switched. The step of obtaining the cluster structure information corresponding to the current target cluster based on the parsed information includes: Determine the target IP address from the set of IP addresses and obtain the corresponding port number; Obtain the corresponding JNDI naming service based on the target IP address and the port number; The target EJB object is obtained based on the JNDI naming service, and the cluster structure information corresponding to the target EJB object is obtained based on the target EJB object.
2. The cluster handover method of claim 1, wherein, The process of resolving the domain name information to obtain the corresponding resolution information includes: The domain name information is parsed to obtain a set of IP addresses; the IP addresses in the set of IP addresses are the IP addresses that point to the cluster.
3. The cluster handover method of claim 1, wherein, The step of obtaining the cluster structure information corresponding to the target EJB object includes: Access the business method of the target EJB object to obtain the corresponding response information and the cluster structure information.
4. The cluster switching method according to claim 3, characterized in that, The step of determining whether all nodes in the target cluster are unavailable based on the cluster structure information and a preset node liveness detection method includes: Based on the response information and the cluster structure information, it is determined whether all nodes in the target cluster are unavailable.
5. The cluster switching method according to claim 1, characterized in that, If all nodes in the target cluster are unavailable, after switching the target cluster of the domain name information, the method further includes: The domain name information is re-parsed to obtain the latest resolution information corresponding to the latest pointing cluster; the latest pointing cluster is the cluster after the pointing cluster of the domain name information is switched. Based on the latest parsed information, re-enter the step of obtaining the corresponding JNDI naming service based on the target IP address and the port number; Alternatively, based on the latest parsed information, one can re-enter the step of obtaining the cluster structure information corresponding to the target EJB object.
6. The cluster handover method according to any one of claims 1, 3 to 5, characterized in that, After determining whether all nodes in the target cluster are unavailable based on the cluster structure information and a preset node liveness detection method, the method further includes: If there is an available node among all the nodes in the specified cluster, then the user's access request is allocated based on the preset load balancing rules.
7. A cluster switching device, characterized in that, include: The domain name resolution module is used to obtain domain name information and parse the domain name information to obtain the corresponding resolution information; The parsed information includes a set of IP addresses; The structure information acquisition module is used to acquire the cluster structure information corresponding to the current target cluster based on the parsed information; The node determination module is used to determine whether all nodes in the target cluster are unavailable based on the cluster structure information and a preset node liveness determination method. A cluster switching module is used to switch the cluster to which the domain name information points if all the nodes in the cluster are unavailable. The structural information acquisition module includes: A target IP address determination unit is used to determine a target IP address from the set of IP addresses; The port number acquisition unit is used to obtain the corresponding port number. The JNDI naming service determination unit is used to obtain the corresponding JNDI naming service based on the target IP address and the port number. The target EJB object acquisition unit is used to acquire the target EJB object based on the JNDI naming service. The information acquisition unit is used to access the business methods of the target EJB object to obtain the corresponding response information and the cluster structure information.
8. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the cluster switching method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, Used to store computer programs; wherein, when the computer programs are executed by a processor, they implement the cluster switching method as described in any one of claims 1 to 6.
10. A computer program product, characterized in that, Includes a computer program, wherein the computer program, when executed by a processor, implements the cluster switching method as described in any one of claims 1 to 6.