Node determination method and system, service processing method and system, and computing device
By setting up a two-node coordination end mechanism in the distributed system, we ensure the robustness and availability of the main selection process when the node coordination service is abnormal, and solve the data consistency and external service stability caused by the node coordination service abnormality, and realize the high availability of the distributed system.
Patent Information
- Application Number
- CN202410091393.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-22
- Publication Date
- 2025-07-22
AI Technical Summary
In distributed systems, when node coordination services are abnormal, multiple master nodes or no master nodes may be caused, affecting data consistency and stability of external services.
The two-node coordination end mechanism is adopted, and the first node coordination end and the second node coordination end are backups. When the first node coordination end is abnormal, the service processing node writes the node information to the second node coordination end, and determines the target service processing node based on the registered node list of the second node coordination end to ensure the robustness and availability of the main selection process.
Through the parallel master selection strategy, the distributed system can still effectively select the master node when the node coordinates service abnormally, maintain data consistency and stability of external services, and improve the system availability.
Smart Images

Figure CN120358133A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this specification relate to the field of computer technology, and particularly to a node determination method and system, a service processing method and system, and a computing device. Background Art
[0002] A distributed system may include multiple service processing nodes. During the process of providing services externally, the data in multiple service processing nodes needs to be consistent to ensure the data consistency of the distributed system and avoid the same task from being executed multiple times in multiple service processing nodes. Based on this, a consensus protocol is usually adopted to select a master node. That is to say, a master node is selected from multiple service processing nodes to execute service processing tasks and control other service processing nodes, thereby achieving the data consistency of the distributed system.
[0003] Currently, the master selection of a distributed system can usually be performed through a node coordination service. However, when the node coordination service is abnormal, it may lead to abnormal master selection, resulting in a situation where there are multiple master nodes or no master node in the distributed system, affecting the data consistency of the distributed system and further affecting the external services of the distributed system. Therefore, there is an urgent need for an effective technical solution to solve the above problems. Summary of the Invention
[0004] In view of this, the embodiments of this specification provide a node determination method. One or more embodiments of this specification simultaneously relate to a node determination system, two service processing methods, a service processing device, a service processing system, a computing device, a computer-readable storage medium, and a computer program product to solve the technical defects existing in the prior art.
[0005] According to a first aspect of the embodiments of this specification, a node determination method is provided, which is applied to a service processing system. The service processing system includes multiple service processing nodes, a first node coordination end, and a second node coordination end. The method includes:
[0006] The service processing node, in response to a node determination instruction, writes node information to the first node coordination end. In the case where it is determined that the writing of the node information to the first node coordination end fails, the node information is written to the second node coordination end;
[0007] The service processing node, in the case where it is determined that the number of node information included in the second registration node list is greater than a first preset quantity threshold, sends a node determination message to the second node coordination end, where the second registration node list includes the node information written to the second node coordination end;
[0008] The second node coordination end, in response to the node determination message, determines a target service processing node from the multiple service processing nodes according to the node information.
[0009] According to a second aspect of the embodiments of the present specification, there is provided a node determination system, including a plurality of service processing nodes, a first node coordination end, and a second node coordination end, where
[0010] The service processing node is configured to, in response to a node determination instruction, write node information into the first node coordination end, and in the case where it is determined that the writing of the node information into the first node coordination end fails, write the node information into the second node coordination end;
[0011] The service processing node is configured to, in the case where it is determined that the number of node information included in the second registration node list is greater than a first preset number threshold, send a node determination message to the second node coordination end, where the second registration node list includes the node information written into the second node coordination end;
[0012] The second node coordination end is configured to, in response to the node determination message, determine a target service processing node from the multiple service processing nodes according to the node information.
[0013] According to a third aspect of the embodiments of the present specification, there is provided a service processing method, applied to a client, including:
[0014] In response to a service processing request of a user, obtain first target node information of a first target service processing node from a first node coordination end;
[0015] In the case where it is determined that the obtaining of the first target node information fails, determine second target node information of a second target service processing node from a memory, where the first target service processing node and the second target service processing node are determined according to the node determination method provided in the first aspect of the embodiments of the present specification, and the second target node information is the node information of the target service processing node sent to the memory after determining the target service processing node according to the node determination method provided in the first aspect of the embodiments of the present specification;
[0016] According to the second target node information, send the service processing request to the second target service processing node, so that the second target service processing node processes the service processing request.
[0017] According to a fourth aspect of the embodiments of the present specification, there is provided a service processing device, applied to a client, including:
[0018] An acquisition module, configured to obtain first target node information of a first target service processing node from a first node coordination end in response to a service processing request of a user;
[0019] A determination module, configured to, when it is determined that the acquisition of the first target node information fails, determine second target node information of a second target service processing node from a memory, where the first target service processing node and the second target service processing node are determined according to a node determination method provided in the first aspect of the embodiments of the present specification, and the second target node information is the node information of the target service processing node sent to the memory after determining the target service processing node according to the node determination method provided in the first aspect of the embodiments of the present specification;
[0020] A sending module, configured to send the service processing request to the second target service processing node according to the second target node information, so that the second target service processing node processes the service processing request.
[0021] According to a fifth aspect of the embodiments of the present specification, a service processing method is provided, which is applied to a service processing system. The service processing system includes a target service processing node and a standby service processing node. The method includes:
[0022] When the standby service processing node receives a service processing request, send the service processing request to the target service processing node, where the target service processing node is determined according to the node determination method provided in the first aspect of the embodiments of the present specification;
[0023] The target service processing node processes the service processing request.
[0024] According to a sixth aspect of the embodiments of the present specification, a service processing system is provided. The service processing system includes a target service processing node and a standby service processing node, where
[0025] The standby service processing node is configured to, when receiving a service processing request, send the service processing request to the target service processing node, where the target service processing node is determined according to the node determination method provided in the first aspect of the embodiments of the present specification;
[0026] The target service processing node is configured to process the service processing request.
[0027] According to a seventh aspect of the embodiments of the present specification, a computing device is provided, including:
[0028] A memory and a processor;
[0029] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the above node determination method or service processing method are implemented.
[0030] According to the eighth aspect of the embodiments of the present specification, there is provided a computer-readable storage medium storing computer-executable instructions, and when the instructions are executed by a processor, the steps of the above node determination method or service processing method are implemented.
[0031] According to the ninth aspect of the embodiments of the present specification, there is provided a computer program product including a computer program / instructions, and when the computer program / instructions are executed by a processor, the steps of the above node determination method or service processing method are implemented.
[0032] An embodiment of the present specification provides a node determination method applied to a node determination system. The node determination system includes a plurality of service processing nodes, a first node coordinator, and a second node coordinator. The service processing node, in response to a node determination instruction, writes node information to the first node coordinator, and in the case where it is determined that the writing of the node information to the first node coordinator fails, writes the node information to the second node coordinator; the service processing node, in the case where it is determined that the number of node information included in the second registration node list is greater than a first preset quantity threshold, sends a node determination message to the second node coordinator, where the second registration node list includes the node information written to the second node coordinator; the second node coordinator, in response to the node determination message, determines a target service processing node from the plurality of service processing nodes according to the node information.
[0033] By setting two primary election media, namely the first node coordinator and the second node coordinator, in the above method, in the case where the service processing node cannot write node information to the first node coordinator, it indicates that the first node coordinator may be abnormal. At this time, the service processing node can write the node information to the second node coordinator, and according to the second registration node list in the second node coordinator, determine the number of node information written to the second node coordinator, so as to judge how many service processing nodes in the distributed system have written the node information to the second node coordinator. In the case where the quantity meets the preset quantity threshold, the service processing node can determine the second node coordinator as the primary election media, so as to perform primary election through the second node coordinator, ensuring that the selection of the primary node is not affected by the abnormality of the primary election media. By adopting a strategy of making the two primary election media backup each other and using a parallel scheme to implement primary election, the robustness and availability of primary election are ensured, and further the data consistency of the distributed system is ensured, and the availability of the services of the distributed system is further improved. Description of the Drawings
[0034] Figure 1 It is a schematic diagram of an application scenario of a node determination method provided by an embodiment of this specification;
[0035] Figure 2 It is a flowchart of a node determination method provided by an embodiment of this specification;
[0036] Figure 3 It is a schematic diagram of the connection relationship among a first node coordination end, a second node coordination end, and a service processing node in a node determination method provided by an embodiment of this specification;
[0037] Figure 4 It is a flowchart of the processing process of a node determination method provided by an embodiment of this specification;
[0038] Figure 5 It is a schematic diagram of the structure of a node determination system provided by an embodiment of this specification;
[0039] Figure 6 It is a flowchart of a service processing method provided by an embodiment of this specification;
[0040] Figure 7 It is a schematic diagram of the structure of a service processing device provided by an embodiment of this specification;
[0041] Figure 8 It is a flowchart of a service processing method provided by an embodiment of this specification;
[0042] Figure 9 It is a schematic diagram of a service processing method provided by an embodiment of this specification;
[0043] Figure 10 It is a schematic diagram of the structure of a service processing system provided by an embodiment of this specification;
[0044] Figure 11 It is a structural block diagram of a computing device provided by an embodiment of this specification. Detailed implementation manners
[0045] In the following description, many specific details are set forth in order to provide a thorough understanding of this specification. However, this specification can be implemented in many other ways different from those described herein, and those skilled in the art can make similar generalizations without departing from the connotation of this specification. Therefore, this specification is not limited by the specific implementations disclosed below.
[0046] The terms used in one or more embodiments of this specification are for the purpose of describing specific embodiments only and are not intended to limit one or more embodiments of this specification. The singular forms "a", "the", and "said" used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly dictates otherwise. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and encompasses any and all possible combinations of one or more of the associated listed items.
[0047] It should be understood that although the terms first, second, etc. may be used in one or more embodiments of this specification to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "when" or "while" or "in response to determining".
[0048] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data that have been authorized by the user or fully authorized by all parties, and the collection, use, and processing of the relevant data need to comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation entrances are provided for the user to choose to authorize or refuse.
[0049] First, the noun terms involved in one or more embodiments of this specification are explained.
[0050] DB: DataBase. A database is "a warehouse for organizing, storing, and managing data according to a data structure". It is a collection of a large amount of data that is stored in a computer for a long time, organized, shareable, and uniformly managed.
[0051] RDS: Relational Database Service, a relational database.
[0052] RM: RiverMaster, a storage available area level control component. The Master component bears the external control flow service of the entire system. In a distributed storage environment, many control services are stateful services, based on a one-master-multiple-backup mode with a single master election medium. If the single master election medium has a problem and there is no master node, and the client cannot discover the service, then the entire control flow will be affected.
[0053] Ocean: Store the region-level control component.
[0054] BlockMaster: Store the cluster-level control component.
[0055] TDC: Compute node IO component.
[0056] In this specification, a node determination method is provided. One or more embodiments of this specification simultaneously relate to a node determination system, two service processing methods, a service processing device, a service processing system, a computing device, and a computer-readable storage medium, which will be described in detail one by one in the following embodiments.
[0057] See Figure 1 , Figure 1 which shows a schematic diagram of an application scenario of a node determination method provided according to an embodiment of this specification.
[0058] Figure 1 It includes a client 102, a distributed system 104, a first node coordinator 106, and a second node coordinator 108 (i.e., DB). Among them, the distributed system 104 includes multiple service processing nodes.
[0059] Specifically in implementation, the user issues a service processing request through the client 102. The service processing request can be, for example, a cloud disk creation request, a cloud disk deletion request, a cloud disk activation request, etc. The client 102 sends the service processing request to the distributed system 104, and the distributed system 104 will select one of the multiple service processing nodes as the target service processing node (master node) to process the service processing request. Specifically, it can be according to Figure 1The master selection logic shown in the figure is used to select a master. Each service processing node in the distributed system 104, in response to the node determination instruction of the distributed system 104, writes its own node information to the first node coordinator 106. If the writing to the first node coordinator 106 is successful, it enters the master selection process of the first node coordinator 106, that is, selects a master through the first node coordinator 106, and the first node coordinator 106 determines the target service processing node from multiple service processing nodes. If the writing to the first node coordinator fails, the node information is written to the second node coordinator 108, and the second node coordinator 108 is polled to obtain the number of node information written to the second node coordinator 108. When this number is greater than the first preset quantity threshold, it enters the master selection process of the second node coordinator 108, that is, determines the target service processing node from the multiple service processing nodes corresponding to the multiple node information written to the second node coordinator 108 through the second node coordinator 108. When the number of node information written to the second node coordinator 108 is less than or equal to the first preset quantity threshold, the service processing node corresponding to the node information written to the second node coordinator 108 starts successfully and enters the standby state. Based on this, the finally determined target service processing node can process service processing requests. Thus, master selection is achieved through two master selection media, namely the first node coordinator and the second node coordinator, ensuring the robustness of master selection.
[0060] The client 102 can include a browser, an APP (Application), or a web application such as an H5 (Hyper Text Markup Language 5) application, or a light application (also known as a mini-program, a lightweight application program) or a cloud application, etc. The end-side device can be based on the software development kit (SDK, Software Development Kit) of the corresponding service provided by the server-side, such as developed based on the real-time communication (RTC) SDK. The end-side device can be deployed in an electronic device and needs to rely on the device or certain APPs in the device to run. The electronic device can have a display screen and support information browsing, etc., such as it can be a personal mobile terminal such as a mobile phone, a tablet computer, a personal computer, etc. Various other types of applications can usually be configured in the electronic device, such as human-computer dialogue applications, model training applications, text processing applications, web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0061] See Figure 2 , Figure 2The figure shows a flowchart of a node determination method provided according to an embodiment of this specification, which is applied to a node determination system. The node determination system includes multiple service processing nodes, a first node coordinator, and a second node coordinator. The specific steps are as follows.
[0062] Step 202: In response to a node determination instruction, the service processing node writes node information to the first node coordinator. In the case where it is determined that the writing of the node information to the first node coordinator fails, the node information is written to the second node coordinator.
[0063] Specifically, the node determination method provided in the embodiments of this specification can be used to elect a master among multiple service processing nodes included in a distributed system. Electing a master can be understood as selecting one from multiple service processing nodes as the master node, and the master node can be used to execute service processing requests.
[0064] Among them, the first node coordinator and the second node coordinator can be understood as master election services for electing a master. The first node coordinator and the second node coordinator are two different master election services. Node information can be understood as the node information of the service processing node, such as node address information, etc. Writing the node information to the first node coordinator can be understood as the process of registering the node information to the first node coordinator. The node determination instruction can be understood as a master election instruction for multiple service processing nodes included in the distributed system. When the service processing node receives this node determination instruction, it means that the service processing node needs to elect a master. In practical applications, the node determination instruction can be received at a preset time interval.
[0065] In practical applications, the first node coordinator can be a server for executing distributed lock and service discovery services. The second node coordinator can be a database, such as an RDS database. And when electing a master through the first node coordinator and the second node coordinator, the master election priorities of the first node coordinator and the second node coordinator are different. The priority of the first node coordinator can be higher than that of the second node coordinator, that is to say, the master node determined by the first node coordinator is taken as the standard. Or, the priority of the first node coordinator can also be lower than that of the second node coordinator. The embodiments of this specification do not make a limitation on this.
[0066] Based on this, for one of the multiple service processing nodes included in the distributed system, after receiving the master election instruction, it can write its own node information to the first node coordinator. In the case where it is determined that the writing of the node information to the first node coordinator fails, it means that the first node coordinator may be abnormal at this time. Then, the node information can be written to the second node coordinator. Correspondingly, for each service processing node, a similar process is performed.
[0067] For example, a distributed system may include service processing node 1, service processing node 2, and service processing node 3. In response to a node determination instruction, service processing node 1 writes the node information 1 of this service processing node 1 to the first node coordination end. In the case where it is determined that the writing of the node information 1 to the first node coordination end fails, the node information 1 is written to the second node coordination end. For service processing node 2 and service processing node 3, a similar process is also performed.
[0068] In specific implementation, when the service processing node successfully writes the node information to the first node coordination end, it indicates that the first node coordination end is operating normally. At this time, master selection can be performed through the first node coordination end, and the specific implementation method is as follows:
[0069] After the service processing node writes the node information to the first node coordination end in response to a node determination instruction, it further includes:
[0070] When the service processing node determines that the writing of the node information to the first node coordination end is completed, it sends a node determination message to the first node coordination end;
[0071] In response to the node determination message, the first node coordination end determines a target service processing node from the multiple service processing nodes according to the node information.
[0072] Among them, sending a node determination message to the first node coordination end can be used to indicate that the service processing node selects the first node coordination end for master selection. The target service processing node can be understood as the master node selected from multiple service processing nodes.
[0073] Based on this, for one of the multiple service processing nodes included in the distributed system, after receiving a master selection instruction, it writes its own node information to the first node coordination end. When it is determined that the writing of the node information to the first node coordination end is completed, it indicates that the first node coordination end is in a normal operating state at this time. Then, the service processing node can select the first node coordination end, and the first node coordination end performs master selection. That is to say, the service processing node can send a node determination message to the first node coordination end. The first node coordination end receives this node determination message, enters the master selection process, and determines a target service processing node from multiple service processing nodes according to the node information written to the first node coordination end.
[0074] Optionally, when the service processing node determines that the writing of the node information to the first node coordination end is completed, it can determine to perform master selection through the first node coordination end, that is, send a node determination message to the first node coordination end, when it is determined that the quantity of the node information written to the first node coordination end is greater than the first preset quantity threshold.
[0075] For example, a distributed system may include service processing node 1, service processing node 2, and service processing node 3. When service processing nodes 1, 2, and 3 all write their node information 1, 2, and 3 to the first node coordinator, service processing nodes 1, 2, and 3 can all send node determination messages to the first node coordinator. In response to the node determination message, the first node coordinator can select one of service processing nodes 1, 2, and 3 as the target service processing node according to the node information 1, 2, and 3 written to the first node coordinator.
[0076] In one embodiment of this specification, when the first node coordinator determines the target service processing node from multiple service processing nodes according to the node information, it can determine the service processing node corresponding to the node information written first as the target service processing node. Alternatively, the first node coordinator can also determine the target service processing node according to other methods. For example, it can determine the service processing node with the largest node ID included in the node information as the target service processing node. This specification does not limit the specific implementation manner of how the first node coordinator elects a master.
[0077] In summary, by selecting the first node coordinator to elect a master when the first node coordinator is in a normal operating state, the process of electing a master for multiple service processing nodes in the distributed system can be realized.
[0078] In practical applications, after the first node coordinator determines the target service processing node from the multiple service processing nodes according to the node information in response to the node determination message, it further includes:
[0079] The first node coordinator sends the target node information of the target service processing node to the client, so that the client saves the target node information to the memory.
[0080] Specifically, after the first node coordinator finishes electing a master and determines the target service processing node, in order to enable the client to obtain the target node information of the target service processing node when receiving a service processing request, so that the target service processing node executes the service processing request, the target node information of the target service processing node can be sent to the client, and the client can save the target node information to the memory. Then, after the client receives a service processing request, in the case where it cannot access the first node coordinator, it can obtain the target node information from the client's memory, thereby determining the target service processing node and sending the service processing request to the target service processing node.
[0081] In summary, through the client caching mechanism, it is ensured that the service processing request can be sent to the target service processing node (i.e., the primary node), so as to realize the normal execution of the service processing request, ensure the stability of the externally provided service, and further ensure the continuity of the service request, with relatively minor modification to the client.
[0082] Specifically, after the primary node coordination end completes the primary selection and determines the target service processing node, the target service processing node can perform a legality judgment on its own state to determine whether it is necessary to switch its node state to the standby state. The specific implementation method is as follows:
[0083] After the primary node coordination end determines the target service processing node from the multiple service processing nodes according to the node information in response to the node determination message, it further includes:
[0084] The target service processing node obtains the number of node information contained in the first registration node list from the primary node coordination end, where the first registration node list contains the node information written to the primary node coordination end;
[0085] In the case where the number of node information contained in the first registration node list is less than or equal to the second preset quantity threshold, the node state is switched to the standby state.
[0086] Among them, the first registration node list stores the node information written to the primary node coordination end. For example, if service processing node 1 writes node information 1 to the primary node coordination end, then the node information 1 is stored in the first registration node list. The second preset quantity threshold can be determined according to the number of service processing nodes. For example, the second preset quantity threshold can be one-half of the number of service processing nodes. For example, if there are 10 service processing nodes in the distributed system, then the second preset quantity threshold can be 5. Then, if the number of node information contained in the first registration node list is less than or equal to the second preset quantity threshold, it means that less than half of the service processing nodes in the distributed system have successfully written node information to the primary node coordination end. At this time, the primary node selected by the primary node coordination end is illegal, and the node state of the primary node selected by the primary node coordination end needs to be switched to the standby state.
[0087] Based on this, when the target service processing node performs a legality judgment on its own state, it can obtain the number of node information stored in the first registration node list from the primary node coordination end. In the case where the number is less than or equal to the second preset quantity threshold, the node state of the target service processing node is switched to the standby state, that is, at this time, the target service processing node is no longer the primary node but becomes a standby node.
[0088] For example, the number of node information included in the first registration node list obtained by the target service processing node from the first node coordinator is m, and the second preset quantity threshold is n. When m is less than or equal to n, it indicates that the primary node selected by the first node coordinator (i.e., the target service processing node) is illegal, and the node status of the target service processing node is switched to the standby state.
[0089] In addition, when it is determined that the number of node information included in the first registration node list is greater than the second preset quantity threshold, the status quo can be maintained, that is to say, the target service processing node can continue to be used as the primary node. Moreover, when it is determined that the target service processing node can access both the first node coordinator and the second node coordinator simultaneously, the node status of the target service processing node may not be switched, that is to say, the target service processing node can continue to be used as the primary node to ensure single-machine operation. In an embodiment of this specification, the node status of the target service processing node can be switched to the standby state when it is determined that the number of node information included in the first registration node list is less than or equal to the second preset quantity threshold and the target service processing node cannot access both the first node coordinator and the second node coordinator simultaneously.
[0090] In summary, according to the number of node information written into the first node coordinator and the second preset quantity threshold, the legality of the target service processing node selected by the first node coordinator can be determined, ensuring that the primary node selection can be recognized by most service processing nodes in the distributed system. This majority-based strategy can avoid the brain split problem.
[0091] In addition, after the first node coordinator determines the target service processing node from the multiple service processing nodes according to the node information in response to the node determination message, it further includes:
[0092] When the target service processing node fails to obtain the number of node information included in the first registration node list from the first node coordinator, its node status is switched to the standby state.
[0093] Specifically, when the target service processing node fails to obtain the number of node information included in the first registration node list from the first node coordinator, it indicates that the target service processing node cannot access the first node coordinator. At this time, it means that the first node coordinator may be in an abnormal state, or the target service processing node may be in a single-machine network island state (the lock is not released actively and expires after the first preset time period), that is, the target service processing node is alone in a network partition and cannot establish communication with other service processing nodes and the first node coordinator. To ensure the stability of the distributed system, the node status of the primary node (i.e., the target service processing node) determined by the first node coordinator for primary node selection is switched to the standby state.
[0094] In summary, by detecting the abnormal situation of the master selection medium in real time, when the master selection medium is abnormal and cannot be accessed or the master node is in a stand-alone network island, the node state of the selected master node is switched in time to ensure that only one master selection medium is effective at present.
[0095] Specifically, after the node state is switched to the standby state, it further includes:
[0096] The target service processing node sends a node information acquisition request to the first node coordinator within the first preset time period;
[0097] In the case that the node information returned by the first node coordinator is not received within the first preset time period, the step of writing the node information into the second node coordinator is continued.
[0098] Specifically, after the node state of the target service processing node is switched to the standby state, it can continuously send a node information acquisition request to the first node coordinator within the first preset time period, that is, continuously attempt to establish communication with the first node coordinator within the first preset time period. In the case that the node information returned by the first node coordinator is not received within the first preset time period, it indicates that the communication between the target service processing node and the first node coordinator fails, and there may still be problems with the first node coordinator being abnormal or the target service processing node being in a stand-alone network island. At this time, the step of writing the node information of the target service processing node into the second node coordinator is continued, and the second node coordinator continues to perform master selection.
[0099] In practical applications, within the first preset time period, the distributed lock of the first node coordinator is not actively released. After the first preset time period, the distributed lock fails and enters the master selection process of the second node coordinator.
[0100] In summary, by setting the first preset time period, the master selection medium is automatically switched in the case of detecting an abnormality, ensuring the timeliness of the master node selection.
[0101] Correspondingly, after the target service processing node sends a node information acquisition request to the first node coordinator within the first preset time period, it further includes:
[0102] When the target service processing node receives the node information returned by the first node coordinator within the first preset time period, it writes the node information into the first node coordinator;
[0103] The first node coordinator determines the next target service processing node from the multiple service processing nodes according to the node information.
[0104] Specifically, when the target service processing node receives the node information returned by the first node coordinator within the first preset time period, the first node coordinator can continue the master election process, that is, resume the master election of the first node coordinator. Specifically, the next target service processing node can be determined from multiple service processing nodes according to the node information written to the first node coordinator.
[0105] In summary, after the communication between the target service processing node and the first node coordinator is restored, the first node coordinator continues to perform the master election, ensuring the higher priority of the first node coordinator.
[0106] Step 204: When the service processing node determines that the number of node information included in the second registration node list is greater than the first preset quantity threshold, the service processing node sends a node determination message to the second node coordinator, where the second registration node list includes the node information written to the second node coordinator.
[0107] Specifically, when the service processing node cannot write the node information to the first node coordinator, after writing the node information to the second node coordinator, when it determines that the number of node information written to the second node coordinator is greater than the first preset quantity threshold, the second node coordinator can be used as the master election medium, and the second node coordinator performs the master election.
[0108] The first preset quantity threshold can be set in the same way as the above-mentioned second preset quantity threshold, or can be set to other values, which is not limited in this specification. Correspondingly, sending a node determination message to the second node coordinator can be understood as selecting the second node coordinator as the master election medium for master election.
[0109] For example, in a distributed system including multiple service processing nodes, some service processing nodes can write node information to the first node coordinator, while some service processing nodes cannot write node information to the first node coordinator, and will write the node information to the second node coordinator. Then, for any service processing node in the distributed system that writes node information to the second node coordinator, when it determines that the number a of node information written to the second node coordinator is greater than the first preset quantity threshold b, it means that most service processing nodes in the distributed system have written node information to the second node coordinator. Based on the majority strategy, the second node coordinator is determined as the master election medium, and the second node coordinator performs the master election.
[0110] In addition, when the service processing node determines that the number of node information included in the second registration node list is less than or equal to the first preset quantity threshold, it can determine that the service processing node has started successfully and enters the standby state.
[0111] Step 206: The second node coordinator, in response to the node determination message, determines a target service processing node from the multiple service processing nodes according to the node information.
[0112] Specifically, when the second node coordinator responds to the node determination message, it indicates that the second node coordinator is selected as the master selection medium. Then, the second node coordinator can determine a target service processing node from the multiple service processing nodes as the master node according to the node information written into the second node coordinator.
[0113] It can be understood that the method for the second node coordinator to select the master node can be the same as or different from the method for the first node coordinator to select the master node. This embodiment of the present specification does not make any limitations in this regard.
[0114] Specifically, after the master selection is completed through the second node coordinator and the target service processing node is determined, the target service processing node can perform a legality judgment on its own status to determine whether it is necessary to switch its node status to the standby state. After the second node coordinator determines the target service processing node from the multiple service processing nodes according to the node information in response to the node determination message, it further includes:
[0115] The target service processing node obtains the number of node information included in the second registration node list from the second node coordinator.
[0116] In the case where it is determined that the number of node information included in the second registration node list is less than or equal to the third preset quantity threshold, the node status is switched to the standby state.
[0117] Among them, the third preset quantity threshold can be the same as or different from the above-mentioned first preset quantity threshold and second preset quantity threshold.
[0118] It can be understood that the legality judgment process of the target service processing node determined by the second node coordinator is similar to the legality judgment process of the target service processing node determined by the first node coordinator above, and this specification will not repeat it here.
[0119] Specifically, after the second node coordinator determines the target service processing node from the multiple service processing nodes according to the node information in response to the node determination message, it further includes:
[0120] The target service processing node switches its node status to the standby state in the case where it fails to obtain the number of node information included in the second registration node list from the second node coordinator.
[0121] It is understandable that the process of judging the legitimacy of the target service processing node determined by the second node coordination end is similar to the process of judging the legitimacy of the target service processing node determined by the first node coordination end above, and this specification will not repeat it.
[0122] In addition, after the node status is switched to the standby state, the following steps are further included:
[0123] After a second preset time period, the target service processing node executes the step of writing the node information to the first node coordination end.
[0124] Specifically, after a second preset time period, the target service processing node re-enters the startup process, that is, it re-executes the step of writing the node information of the target service processing node to the first node coordination end and continues to select a master.
[0125] Moreover, after the target service processing node is determined as the master node, other service processing nodes in the distributed system can continue to enter the master selection process through the first node coordination end or the second node coordination end. The specific implementation method is as follows:
[0126] After determining the target service processing node from the multiple service processing nodes according to the node information, the following steps are further included:
[0127] The first service processing node writes the node information to the first node coordination end or the second node coordination end according to the preset access rule, where the first service processing node is a service processing node other than the target service processing node among the multiple service processing nodes.
[0128] Among them, the preset access rule can be understood as a rule for polling the first node coordination end or the second node coordination end.
[0129] Specifically, the first service processing node polls the first node coordination end, and can determine the number of node information written to the first node coordination end. When the number is greater than the first preset quantity threshold, the first node coordination end is selected as the master selection medium to perform the master selection process of the first node coordination end. Or, the first service processing node polls the second node coordination end, and can determine the number of node information written to the second node coordination end. When the number is greater than the second preset quantity threshold, the second node coordination end is selected as the master selection medium to perform the master selection process of the second node coordination end. It is understandable that the specific process is similar to the process of determining the target service processing node above and will not be repeated here.
[0130] The following combination with the attached Figure 3 , Figure 3The figure shows a schematic connection diagram among a first node coordinator, a second node coordinator, and a service processing node in a node determination method provided according to an embodiment of this specification. In Figure 3 it, the first node coordinator can be understood as a distributed lock and a service discovery service, DB is the second node coordinator, and RM is the service processing node.
[0131] In Figure 3 in (a), the first node coordinator, the second node coordinator, and service processing nodes 1, 2, and 3 are all in the same network partition. That is to say, service processing nodes 1, 2, and 3 can all access the first node coordinator and the second node coordinator. At this time, according to the rule that the priority of the first node coordinator is greater than that of the second node coordinator, the first node coordinator can be used to select a master (that is, select one service processing node from service processing nodes 1, 2, and 3 as the master node).
[0132] In Figure 3 in (b), the first node coordinator, the second node coordinator, and service processing nodes 1 and 2 are in one network partition, and service processing node 3 is in another network partition. At this time, service processing node 3 cannot establish connections with the first node coordinator, the second node coordinator, and service processing nodes 1 and 2, and service processing node 3 is in a single-machine failure state.
[0133] In Figure 3 in (c), the first node coordinator and service processing nodes 1 and 2 are in one network partition, and the second node coordinator and service processing node 3 are in another network partition. In this case, service processing nodes 1 and 2 can access the first node coordinator, and service processing node 3 can access the second node coordinator. That is to say, when selecting a master, service processing nodes 1 and 2 will write node information into the first node coordinator, while service processing node 3 will write node information into the second node coordinator. Then, based on the majority strategy, according to the node determination process described in the above node determination method, the number of pieces of node information written into the first node coordinator is 2, which is greater than the preset quantity threshold 3 / 2 (half of the number of service processing nodes). The first node coordinator will be used to select a master, and then the node state of service processing node 3 that writes node information into the second node coordinator will be switched to the standby state.
[0134] In Figure 3In (d), the first node coordination end and service processing node 1 are in one network partition, and the second node coordination end and service processing nodes 2 and 3 are in another network partition. When electing a master, service processing node 1 writes node information to the first node coordination end, and service processing nodes 2 and 3 write node information to the second node coordination end. Contrary to the above (c), the number of node information written to the second node coordination end is 2, which is greater than the preset quantity threshold of 3 / 2. Master election will be carried out through the second node coordination end. Then, the node state of service processing node 1 that writes node information to the first node coordination end will switch to the standby state. And at this time, there will be a preset time period. When service processing node 1 is elected as the master node, or in the CDS scenario, sacrificing some timeliness in abnormal situations, when it is judged that the number of node information written to the first node coordination end is greater than or equal to 3 / 2, master election is carried out through the first node coordination end.
[0135] In Figure 3 In (e), service processing node 1 and the first node coordination end are in one network partition, service processing node 2 is alone in one network partition, and service processing node 3 and the second node coordination end are in another network partition. In this case, service processing nodes 1, 2, and 3 are all unable to provide services externally. Specifically, when electing a master, service processing node 1 writes node information to the first node coordination end. However, since the number of node information written to the first node coordination end is 1, which is less than the preset quantity threshold of 3 / 2, this service processing node 1 will enter the standby state. Similarly, since service processing node 3 writes node information to the second node coordination end, but the number of node information written to the second node coordination end is also 1, which is less than the preset quantity threshold of 3 / 2, this service processing node 3 will also enter the standby state. And service processing node 2 fails to start because it cannot access the first node coordination end and the second node coordination end.
[0136] In Figure 3 In (f), service processing node 1, the first node coordination end, and the second node coordination end are in one network partition, and service processing nodes 2 and 3 are in another network partition. At this time, since service processing nodes 2 and 3 cannot access the first node coordination end and the second node coordination end, they enter the startup failure process after the second preset time period. Service processing node 1 starts successfully. And since service processing node 1 can access both the first node coordination end and the second node coordination end, then this service processing node 1 can be used as the master node to ensure single-machine operation.
[0137] Specifically, in the case from (a) to (b), service processing node 3 disconnects from the first node coordination end and the second node coordination end, resulting in a single-machine failure. At this time, it does not affect the determination of the master node, so the status quo is maintained.
[0138] In the case from (a) to (c), the service processing node 1 remains the primary node, and the service processing node 2 remains the standby node (i.e., in the standby state). However, since the service processing node 3, as a standby node, cannot access the first node coordinator, it will consider the first node coordinator abnormal and enter the check logic (i.e., in the case of being unable to access the first node coordinator, it will send a node information acquisition request to the first node coordinator within the first preset time period and attempt to establish a communication connection with the first node coordinator until the end of the first preset time period). If it still cannot access the first node coordinator after the check logic ends, it will write the node information to the second node coordinator and attempt to enter the primary node selection logic of the second node coordinator, that is, it will continuously obtain the number of node information written to the second node coordinator. However, in this case, since the service processing nodes 1 and 2 can always access the first node coordinator, they will not write their own node information to the second node coordinator, and the number of node information written to the second node coordinator is always 1, which does not meet the condition of being greater than the preset quantity threshold of 3 / 2. Therefore, the service processing node 3 will not enter the primary node selection logic. When the time for the service processing node 3 to consider the first node coordinator abnormal and enter the check logic is greater than the lock timeout time of the first node coordinator, it will then enter the polling logic of the second node coordinator. After the lock timeout, the service processing node 1 or 2 will re-enter the primary node selection logic of the first node coordinator. It can be understood that after the first node coordinator selects the primary node, it will lock the primary node, and after the lock timeout time, it will release the primary node.
[0139] In the case from (a) to (d), the service processing node 1, as the primary node, can access the first node coordinator, and the service processing nodes 2 and 3, as standby nodes, can access the second node coordinator. During the self-legitimacy judgment process of the service processing node 1 as the primary node, since the number of node information written to the first node coordinator is 1, which is less than the preset quantity threshold of 3 / 2, it considers itself in an illegal state and will switch its node state to the standby state (this time is before the primary node selection time of the second node coordinator). Subsequently, after the service processing nodes 2 and 3 fail to access the first node coordinator, they will enter the primary node selection logic of the second node coordinator.
[0140] In the case from any of the scenarios (a), (b), (c), (d) to (e), the node state of the service processing node 1 is switched to the standby state, the service processing node 2 fails to start, and the node state of the service processing node 3 is switched to the standby state.
[0141] In the case from (b) to (a), it is similar to the scenario of capacity expansion. In the case from (b) to (c), service processing nodes 1 and 2 continue to elect a primary through the first node coordination end. Service processing node 3, as a standby node, accesses the second node coordination end. However, since the number of node information written to the second node coordination end is less than the preset number threshold of 3 / 2, it will not enter the primary election process of the second node coordination end and will continuously poll to access the second node coordination end to obtain the number of node information written to the second node coordination end. In the case from (b) to (d), if service processing node 1 is the primary node, this service processing node 1 polls to access the first node coordination end and finds that the number of node information written to the first node coordination end has decreased. Then, after the first preset time period, it switches the node state to the standby state. If service processing node 2 is the primary node and this service processing node 2 cannot access the first node coordination end and considers the first node coordination end abnormal, it will back off and elect a primary through the second node coordination end after the lock time of the first node coordination end. Service processing node 3 can access the second node coordination end. After successful startup, it enters the polling stage, polls to access the second node coordination end, and the number of node information written to the second node coordination end obtained is 2, which is greater than the preset number threshold of 3 / 2, and enters the primary election process of the second node coordination end.
[0142] In the case from (c) to (a), service processing node 3 finds that it can access the first node coordination end and the node state of service processing node 3 is the standby state. At this time, service processing node 2 can elect a primary through the first node coordination end. In the case from (c) to (b), service processing node 3, as a standby node, finds that it cannot access the second node coordination end, that is, it considers the second node coordination end abnormal and enters the continuous restart process. In the case from (c) to (d), if service processing node 1 is the primary node, service processing node 1 polls to access the first node coordination end and the number of node information written to the first node coordination end obtained decreases (from 2 to 1), which is less than the preset number threshold of 3 / 2. Then, it switches the node state of service processing node 1 to the standby state. If service processing node 2 is the primary node and service processing node 2 cannot access the first node coordination end and considers the first node coordination end abnormal, then after the first preset time period (greater than the lock time of the first node coordination end), it enters the primary election process of the second node coordination end. In the polling stage of service processing node 3 accessing the second node coordination end, the number of node information written to the second node coordination end obtained changes from 1 to 2, which is greater than the preset number threshold of 3 / 2, and enters the primary election process of the second node coordination end.
[0143] In the case from (d) to (a), service processing node 3, as the primary node, finds that it can access the first node coordination end and considers the first node coordination end normal. Then, it releases the lock of the second node coordination end and enters the startup process (i.e., Figure 1The startup process shown), the service processing node 2, as a standby node, discovers that it can access the first node coordinator and enters the startup process. The service processing node 1, as a standby node, during the process of polling and accessing the first node coordinator, the number of node information written to the first node coordinator obtained changes from 1 to 3, which is greater than the preset quantity threshold of 3 / 2, and enters the master selection process of the first node coordinator. In the case from (d) to (b), the service processing node 2 can access the first node coordinator, and after the second preset time period (greater than the lock failure time of the second node coordinator), it enters the startup process. The service processing node 3 cannot access the first node coordinator and the second node coordinator, the startup fails, and it enters the startup failure process, and tries to access the first node coordinator or the second node coordinator again. The service processing node 1, during the process of polling the first node coordinator, the number of node information written to the first node coordinator obtained changes from 1 to 2, which is greater than the preset quantity threshold of 3 / 2, and enters the master selection process of the first node coordinator. In the case from (d) to (c), the service processing node 2 can access the first node coordinator but cannot access the first node coordinator, then it enters the check logic (continuously tries to communicate with the second node coordinator within the second preset time period), and after the second preset time period ends, it enters the startup process. If the service processing node 3 is the master node and polls the second node coordinator and discovers that the number of node information written to the second node coordinator decreases, it switches the node status to the standby state. The service processing node 1 polls the first node coordinator, and the number of node information written to the first node coordinator obtained changes from 1 to 2, and enters the master selection process of the first node coordinator (that is, selects the master through the first node coordinator). If the process is restarted within the second preset time period, there may be a situation where there is both a lock of the first node coordinator and a lock of the second node coordinator.
[0144] In the case from (e) to (a), during the process that the service processing node 1 polls the first node coordination end as a standby node, the number of node information written to the first node coordination end obtained ranges from 1 to 3, which is greater than the preset quantity threshold 3 / 2, and it enters the primary node election process of the first node coordination end. The service processing node 2 continuously restarts from the abnormal state, switches to the startup process and starts successfully. The service processing node 3 can access the first node coordination end as a standby node and enters the startup process. In the case from (e) to (b), during the process that the service processing node 1 polls the first node coordination end as a standby node, the number of node information written to the first node coordination end obtained ranges from 1 to 2, which is greater than the preset quantity threshold 3 / 2, and it enters the primary node election process of the first node coordination end. The service processing node 2 continuously restarts from the abnormal state and switches to the startup process, and starts successfully. The service processing node 3 as a standby node cannot access the second node coordination end, discovers that the second node coordination end is abnormal, and enters the startup failure process to retry establishing communication with the second node coordination end. In the case from (e) to (c), during the process that the service processing node 1 polls the first node coordination end as a standby node, the number of node information written to the first node coordination end obtained ranges from 1 to 2, which is greater than the preset quantity threshold 3 / 2, and it enters the primary node election process of the first node coordination end. The service processing node 2 continuously restarts from the abnormal state and switches to the startup process, and starts successfully. The state of the service processing node 3 remains unchanged. In the case from (e) to (d), the state of the service processing node 1 remains unchanged. The service processing node 2 continuously restarts from the abnormal state and switches to the startup process, starts successfully, and switches to the primary node election process of the second node coordination end. The service processing node 3 as a standby node, during the process of polling the second node coordination end, the number of node information written to the second node coordination end obtained ranges from 1 to 2, which is greater than the preset quantity threshold 3 / 2, and it enters the primary node election process of the second node coordination end (i.e., primary node election through the second node coordination end).
[0145] In summary, by setting the two primary node election media of the first node coordination end and the second node coordination end, in the case that the service processing node cannot write node information to the first node coordination end, it indicates that the first node coordination end may be abnormal. At this time, the service processing node can write node information to the second node coordination end, and determine the number of node information written to the second node coordination end according to the second registered node list in the second node coordination end, so as to judge how many service processing nodes in the distributed system have written node information to the second node coordination end. When the quantity meets the preset quantity threshold, the service processing node can determine the second node coordination end as the primary node election media, and thus perform primary node election through the second node coordination end, ensuring that the selection of the primary node is not affected by the abnormality of the primary node election media. By adopting the strategy of making the two primary node election media backup each other and using a parallel scheme to implement primary node election, the robustness and availability of primary node election are guaranteed, and further the data consistency of the distributed system is guaranteed, and the external services of the distributed system are further guaranteed.
[0146] The following, in conjunction with the attached Figure 4 , taking the application of the node determination method provided in this specification in a distributed system as an example, further illustrates the node determination method. Among them, Figure 4 FIG. shows a flowchart of the processing procedure of a node determination method provided by an embodiment of this specification. Specifically, the TDC sends an opening request to the node determination system (i.e., the RiverMaster adaptive mechanism redirection mechanism). Among them, the node determination system includes a first node coordination end and a second node coordination end (i.e., RDS). The node determination system determines a target service processing node from among multiple service processing nodes included in the distributed system. After determining the target service processing node, the node information of the target service processing node is sent to the client. The client can determine the node information of the target service processing node from the memory, and according to this node information, send the opening request to the target service processing node, and the target service processing node executes the opening request. As Figure 4 shown, the TDC, as a computing node IO component, sends an opening request to the RiverMaster adaptive mechanism redirection mechanism. The RiverMaster adaptive mechanism redirection mechanism registers the main MasterIP to the DB. Ocean obtains RiverMaster through the DB. The BlockMaster can execute the opening operation and store the result back to the cache.
[0147] Corresponding to the above method embodiment, this specification also provides an embodiment of a node determination system, Figure 5 FIG. shows a schematic structural diagram of a node determination system provided by an embodiment of this specification. As Figure 5 shown, the system includes: multiple service processing nodes 502, a first node coordination end 504, and a second node coordination end 506. Among them,
[0148] The service processing node 502 is configured to, in response to a node determination instruction, write node information to the first node coordination end. In the case where it is determined that the writing of the node information to the first node coordination end fails, write the node information to the second node coordination end;
[0149] The service processing node 502 is configured to, in the case where it is determined that the number of node information included in the second registration node list is greater than a first preset quantity threshold, send a node determination message to the second node coordination end, where the second registration node list includes the node information written to the second node coordination end;
[0150] The second node coordination end 506 is configured to, in response to the node determination message, determine a target service processing node from among the multiple service processing nodes according to the node information.
[0151] In an alternative embodiment,
[0152] The service processing node is configured to send a node determination message to the first node coordination end when it is determined that the writing of the node information to the first node coordination end is completed;
[0153] The first node coordination end is configured to determine a target service processing node from the multiple service processing nodes according to the node information in response to the node determination message.
[0154] In an alternative embodiment,
[0155] The first node coordination end sends the target node information of the target service processing node to the client, so that the client saves the target node information to the memory.
[0156] In an alternative embodiment,
[0157] The target service processing node obtains the number of pieces of node information included in the first registration node list from the first node coordination end, where the first registration node list includes the node information written to the first node coordination end;
[0158] When it is determined that the number of pieces of node information included in the first registration node list is less than or equal to a second preset quantity threshold, the node status is switched to the standby state.
[0159] In an alternative embodiment,
[0160] When the target service processing node fails to obtain the number of pieces of node information included in the first registration node list from the first node coordination end, the node status is switched to the standby state.
[0161] In an alternative embodiment,
[0162] The target service processing node sends a node information acquisition request to the first node coordination end within a first preset time period;
[0163] When the node information returned by the first node coordination end is not received within the first preset time period, the step of writing the node information to the second node coordination end is continued.
[0164] In an alternative embodiment,
[0165] When the target service processing node receives the node information returned by the first node coordination end within the first preset time period, the node information is written to the first node coordination end;
[0166] The first node coordination end determines the next target service processing node from the multiple service processing nodes according to the node information.
[0167] In an optional embodiment,
[0168] The target service processing node obtains the number of node information included in the second registration node list from the second node coordination end;
[0169] When it is determined that the number of node information included in the second registration node list is less than or equal to the third preset quantity threshold, the node status is switched to the standby state.
[0170] In an optional embodiment,
[0171] When the target service processing node fails to obtain the number of node information included in the second registration node list from the second node coordination end, the node status is switched to the standby state.
[0172] In an optional embodiment,
[0173] After a second preset time period, the target service processing node executes the step of writing the node information to the first node coordination end.
[0174] In an optional embodiment,
[0175] The first service processing node writes the node information to the first node coordination end or the second node coordination end according to the preset access rule, where the first service processing node is a service processing node among the multiple service processing nodes other than the target service processing node.
[0176] In summary, by setting two master election media, namely the first node coordination end and the second node coordination end, in the above system, when a service processing node fails to write node information to the first node coordination end, it indicates that the first node coordination end may be abnormal. At this time, the service processing node can write the node information to the second node coordination end, and determine the number of node information written to the second node coordination end according to the second registration node list in the second node coordination end, so as to judge how many service processing nodes in the distributed system have written the node information to the second node coordination end. When the quantity meets the preset quantity threshold, the service processing node can determine the second node coordination end as the master election medium, and thus perform master election through the second node coordination end, ensuring that the selection of the master node is not affected by the abnormality of the master election medium. By using the strategy of making the two master election media backup each other and implementing master election using a parallel scheme, the robustness and availability of master election are ensured, thereby ensuring the data consistency of the distributed system and further ensuring the external services of the distributed system.
[0177] The above is a schematic solution of a node determination system according to this embodiment. It should be noted that the technical solution of this node determination system and the technical solution of the above node determination method belong to the same concept. For the details not described in detail in the technical solution of the node determination system, reference can be made to the description of the technical solution of the above node determination method.
[0178] See Figure 6 , Figure 6 which shows a flowchart of a service processing method according to an embodiment of this specification, applied to a client, and the specific steps are as follows.
[0179] Step 602: In response to a service processing request from a user, obtain first target node information of a first target service processing node from a first node coordinator;
[0180] Step 604: In the case where it is determined that the acquisition of the first target node information fails, determine second target node information of a second target service processing node from the memory.
[0181] Wherein, the first target service processing node and the second target service processing node are determined according to the node determination method provided in the first aspect of the embodiments of this specification, and the second target node information is the node information of the target service processing node sent to the memory after determining the target service processing node according to the node determination method provided in the first aspect of the embodiments of this specification;
[0182] Step 606: According to the second target node information, send the service processing request to the second target service processing node so that the second target service processing node processes the service processing request.
[0183] In an optional embodiment, after obtaining the first target node information of the first target service processing node from the first node coordinator, it further includes:
[0184] In the case where it is determined that the acquisition of the first target node information is successful, according to the first target node information, send the service processing request to the first target service processing node so that the first target service processing node processes the service processing request.
[0185] In summary, the above method sets two master election media, namely the first node coordination end and the second node coordination end. When the service processing node fails to write node information to the first node coordination end, it indicates that the first node coordination end may be abnormal. At this time, the service processing node can write node information to the second node coordination end, and determine the number of node information written to the second node coordination end according to the second registered node list in the second node coordination end, so as to judge how many service processing nodes in the distributed system have written node information to the second node coordination end. When the quantity meets the preset quantity threshold, the service processing node can determine the second node coordination end as the master election medium, and then perform master election through the second node coordination end, ensuring that the selection of the master node is not affected by the abnormality of the master election medium. By using the strategy of mutual backup of the two master election media and implementing master election using a parallel scheme, the robustness and availability of master election are ensured, thereby ensuring the data consistency of the distributed system and further ensuring the external services of the distributed system.
[0186] The above is a schematic solution of a service processing method according to this embodiment. It should be noted that the technical solution of this service processing method and the technical solution of the above node determination method belong to the same concept. For the details not described in the technical solution of the service processing method, reference can be made to the description of the technical solution of the above node determination method.
[0187] Corresponding to the above method embodiment, this specification also provides an embodiment of a service processing device. Figure 7 The structure diagram of a service processing device provided by an embodiment of this specification is shown. As Figure 7 shown, the device includes:
[0188] An obtaining module 702, configured to obtain first target node information of a first target service processing node from a first node coordination end in response to a service processing request of a user;
[0189] A determining module 704, configured to determine second target node information of a second target service processing node from a memory when it is determined that the obtaining of the first target node information fails, where the first target service processing node and the second target service processing node are determined according to the node determination method provided in the first aspect of the embodiments of this specification, and the second target node information is the node information of the target service processing node sent to the memory after determining the target service processing node according to the node determination method provided in the first aspect of the embodiments of this specification;
[0190] A sending module 706, configured to send the service processing request to the second target service processing node according to the second target node information, so that the second target service processing node processes the service processing request.
[0191] In an alternative embodiment, the sending module 706 is further configured to, when it is determined that the acquisition of the first target node information is successful, send the service processing request to the first target service processing node according to the first target node information, so that the first target service processing node processes the service processing request.
[0192] In summary, by setting two master election media, namely the first node coordination end and the second node coordination end, in the above device, when the service processing node fails to write node information to the first node coordination end, it indicates that the first node coordination end may be abnormal. At this time, the service processing node can write node information to the second node coordination end, and determine the number of node information written to the second node coordination end according to the second registered node list in the second node coordination end, so as to judge how many service processing nodes in the distributed system have written node information to the second node coordination end. When the quantity meets the preset quantity threshold, the service processing node can determine the second node coordination end as the master election medium, and thus perform master election through the second node coordination end, ensuring that the selection of the master node is not affected by the abnormality of the master election medium. By using the strategy of making the two master election media backup each other and implementing master election using a parallel scheme, the robustness and availability of master election are guaranteed, thereby ensuring the data consistency of the distributed system and further ensuring the external services of the distributed system.
[0193] The above is a schematic solution of a service processing device according to this embodiment. It should be noted that the technical solution of this service processing device and the technical solution of the above service processing method belong to the same concept. For the details not described in the technical solution of the service processing device, reference can be made to the description of the technical solution of the above service processing method.
[0194] See Figure 8 , Figure 8 which shows a flowchart of a service processing method according to an embodiment of this specification, applied to a service processing system, where the service processing system includes a target service processing node and a standby service processing node, and the specific steps are as follows.
[0195] Step 802: When the standby service processing node receives a service processing request, send the service processing request to the target service processing node.
[0196] Among them, the target service processing node is determined according to the node determination method provided in the first aspect of the embodiment of this specification;
[0197] Step 804: The target service processing node processes the service processing request.
[0198] Specifically, see Figure 9 ,Figure 9 It shows a schematic diagram of a service processing method provided according to an embodiment of this specification. As Figure 9 shown, a redirection mechanism is set for the service processing node. When the service processing node serving as the primary node (target service processing node) receives a service processing request, it processes the service processing request. When the service processing node serving as the standby node (standby service processing node) receives a service processing request, the service processing node serving as the standby node forwards the service processing request to the service processing node serving as the primary node.
[0199] Corresponding to the above method embodiment, this specification also provides an embodiment of a service processing system, Figure 10 which shows a schematic structural diagram of a service processing system provided according to an embodiment of this specification. As Figure 10 shown, the system includes:
[0200] a target service processing node 1002 and a standby service processing node 1004, where
[0201] the standby service processing node 1004 is configured to, when receiving a service processing request, send the service processing request to the target service processing node, where the target service processing node is determined according to the node determination method provided in the first aspect of the embodiment of this specification;
[0202] the target service processing node 1002 is configured to process the service processing request.
[0203] In summary, by setting two master election media, namely the first node coordination end and the second node coordination end, in the above system, when the service processing node cannot write node information to the first node coordination end, it indicates that the first node coordination end may be abnormal. At this time, the service processing node can write node information to the second node coordination end, and determine the number of node information written to the second node coordination end according to the second registered node list in the second node coordination end, so as to judge how many service processing nodes in the distributed system have written node information to the second node coordination end. When the quantity meets the preset quantity threshold, the service processing node can determine the second node coordination end as the master election medium, and thus perform master election through the second node coordination end, ensuring that the selection of the primary node is not affected by the abnormality of the master election medium. By making the two master election media backup each other, a parallel scheme is used to implement master election, ensuring the robustness and availability of master election, and further ensuring the data consistency of the distributed system and the external services of the distributed system.
[0204] The above is a schematic solution of a service processing system according to this embodiment. It should be noted that the technical solution of this service processing system and the technical solution of the above service processing method belong to the same concept. For the details not described in the technical solution of the service processing system, reference can be made to the description of the technical solution of the above service processing method.
[0205] Figure 11 FIG. 4 shows a block diagram of a computing device 1100 according to an embodiment of the present specification. The components of the computing device 1100 include, but are not limited to, a memory 1110 and a processor 1120. The processor 1120 is connected to the memory 1110 through a bus 1130, and a database 1150 is used to store data.
[0206] The computing device 1100 further includes an access device 1140, which enables the computing device 1100 to communicate via one or more networks 1160. Examples of these networks include the Public Switched Telephone Network (PSTN), Local Area Network (LAN), Wide Area Network (WAN), Personal Area Network (PAN), or a combination of communication networks such as the Internet. The access device 1140 may include one or more of any type of wired or wireless network interface (e.g., a network interface card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) wireless interface, a Worldwide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.
[0207] In an embodiment of the present application, the above components of the computing device 1100 and Figure 11 other components not shown in FIG. 4 may also be connected to each other, for example, through a bus. It should be understood that Figure 11 the block diagram of the computing device shown in FIG. 4 is for illustrative purposes only and is not a limitation on the scope of the present application. Those skilled in the art can add or replace other components as needed.
[0208] The computing device 1100 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or personal computers (PCs). The computing device 1100 can also be a mobile or stationary server.
[0209] Wherein, the processor 1120 is configured to execute the following computer-executable instructions, and when the computer-executable instructions are executed by the processor, the steps of the above node determination method and service processing method are implemented.
[0210] The above is a schematic solution of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solutions of the above node determination method and service processing method belong to the same concept. For the details not described in detail in the technical solution of the computing device, reference can be made to the descriptions of the technical solutions of the above node determination method and service processing method.
[0211] An embodiment of this specification also provides a computer-readable storage medium, which stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the steps of the above node determination method and service processing method are implemented.
[0212] The above is a schematic solution of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium and the technical solutions of the above node determination method and service processing method belong to the same concept. For the details not described in detail in the technical solution of the storage medium, reference can be made to the descriptions of the technical solutions of the above node determination method and service processing method.
[0213] An embodiment of this specification also provides a computer program product, including a computer program / instructions, and when the computer program / instructions are executed by a processor, the steps of the above node determination method and service processing method are implemented.
[0214] The above is a schematic solution of a computer program product according to this embodiment. It should be noted that the technical solution of this computer program product and the technical solutions of the above node determination method and service processing method belong to the same concept. For the details not described in detail in the technical solution of the computer program product, reference can be made to the descriptions of the technical solutions of the above node determination method and service processing method.
[0215] The above describes specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the acts or steps recited in the claims may be performed in a different order than in the embodiments and still achieve the desired result. Additionally, the processes depicted in the figures do not necessarily require the particular order or sequential order shown to achieve the desired result. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0216] The computer instructions include computer program code, which may be in source code form, object code form, executable file, or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, removable hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium, etc. It should be noted that the content included in the computer-readable medium can be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.
[0217] It should be noted that for the foregoing method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the embodiments of this specification are not limited by the described order of actions, because according to the embodiments of this specification, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments of this specification.
[0218] In the above embodiments, the descriptions of the various embodiments each have their own focuses. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0219] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The alternative embodiments do not elaborate on all the details, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and variations can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments to better explain the principles and practical applications of the embodiments of this specification, so that those skilled in the art can understand and utilize this specification well. This specification is only limited by the claims and their full scope and equivalents.
Claims
1. A node determination method is applied to a node determination system, which includes multiple service processing nodes, a first node coordinator, and a second node coordinator. The method includes: The service processing node, in response to a node determination instruction, writes node information to the first node coordinator. In the case where it is determined that the writing of the node information to the first node coordinator fails, the node information is written to the second node coordinator; The service processing node, in the case where it is determined that the number of node information included in the second registration node list is greater than a first preset quantity threshold, sends a node determination message to the second node coordinator, where the second registration node list includes the node information written to the second node coordinator; The second node coordinator, in response to the node determination message, determines a target service processing node from the multiple service processing nodes according to the node information.
2. According to the node determination method described in claim 1, after the service processing node, in response to a node determination instruction, writes node information to the first node coordinator, it further includes: The service processing node, in the case where it is determined that the writing of the node information to the first node coordinator is completed, sends a node determination message to the first node coordinator; The first node coordinator, in response to the node determination message, determines a target service processing node from the multiple service processing nodes according to the node information.
3. According to the node determination method described in claim 2, after the first node coordinator, in response to the node determination message, determines a target service processing node from the multiple service processing nodes according to the node information, it further includes: The first node coordinator sends the target node information of the target service processing node to the client, so that the client saves the target node information to the memory.
4. According to the node determination method described in claim 2, after the first node coordinator, in response to the node determination message, determines a target service processing node from the multiple service processing nodes according to the node information, it further includes: The target service processing node obtains the number of node information included in the first registration node list from the first node coordinator, where the first registration node list includes the node information written to the first node coordinator; In the case where it is determined that the number of node information included in the first registration node list is less than or equal to a second preset quantity threshold, the node status is switched to the standby state.
5. According to the node determination method described in claim 4, after the first node coordinator, in response to the node determination message, determines a target service processing node from the multiple service processing nodes according to the node information, it further includes: The target service processing node, in the case where it fails to obtain the number of node information included in the first registration node list from the first node coordinator, switches the node status to the standby state.
6. According to the node determination method described in claim 4 or 5, after the node status is switched to the standby state, it further includes: The target service processing node sends a node information acquisition request to the first node coordinator within a first preset time period; In the case where the node information returned by the first node coordinator is not received within the first preset time period, the step of writing the node information into the second node coordinator is continued.
7. The node determination method according to claim 6, after the target service processing node sends a node information acquisition request to the first node coordinator within a first preset time period, further comprising: The target service processing node writes the node information into the first node coordinator in the case where the node information returned by the first node coordinator is received within the first preset time period; The first node coordinator determines the next target service processing node from the multiple service processing nodes according to the node information.
8. The node determination method according to claim 1, after the second node coordinator determines the target service processing node from the multiple service processing nodes according to the node information in response to the node determination message, further comprising: The target service processing node obtains the number of pieces of node information included in the second registration node list from the second node coordinator; In the case where it is determined that the number of pieces of node information included in the second registration node list is less than or equal to a third preset quantity threshold, the node status is switched to the standby state.
9. The node determination method according to claim 8, after the second node coordinator determines the target service processing node from the multiple service processing nodes according to the node information in response to the node determination message, further comprising: The target service processing node switches the node status to the standby state in the case where it fails to obtain the number of pieces of node information included in the second registration node list from the second node coordinator.
10. The node determination method according to claim 8 or 9, after switching the node status to the standby state, further comprising: The target service processing node executes the step of writing the node information into the first node coordinator after a second preset time period.
11. The node determination method according to claim 1, after determining the target service processing node from the multiple service processing nodes according to the node information, further comprising: The first service processing node writes the node information into the first node coordinator or the second node coordinator according to a preset access rule, where the first service processing node is a service processing node among the multiple service processing nodes other than the target service processing node.
12. A service processing method, applied to a client, comprising: In response to a service processing request of a user, obtaining first target node information of a first target service processing node from a first node coordinator; In the case where it is determined that the acquisition of the first target node information fails, determine the second target node information of the second target service processing node from the memory, where the first target service processing node and the second target service processing node are determined according to the node determination method described in any one of claims 1-11, and the second target node information is the node information of the target service processing node sent to the memory after determining the target service processing node according to the node determination method described in any one of claims 1-11; According to the second target node information, send the service processing request to the second target service processing node, so that the second target service processing node processes the service processing request.
13. The service processing method according to claim 12, after obtaining the first target node information of the first target service processing node from the first node coordinator, further comprising: In the case where it is determined that the acquisition of the first target node information is successful, according to the first target node information, send the service processing request to the first target service processing node, so that the first target service processing node processes the service processing request.
14. A service processing method applied to a service processing system, the service processing system including a target service processing node and a standby service processing node, the method comprising: When the standby service processing node receives a service processing request, send the service processing request to the target service processing node, where the target service processing node is determined according to the node determination method described in any one of claims 1-11; The target service processing node processes the service processing request.
15. A node determination system, including a plurality of service processing nodes, a first node coordinator and a second node coordinator, where The service processing node is configured to, in response to a node determination instruction, write node information into the first node coordinator, and in the case where it is determined that the writing of the node information into the first node coordinator fails, write the node information into the second node coordinator; The service processing node is configured to, in the case where it is determined that the number of node information included in the second registration node list is greater than a first preset quantity threshold, send a node determination message to the second node coordinator, where the second registration node list includes the node information written into the second node coordinator; The second node coordinator is configured to, in response to the node determination message, determine a target service processing node from the plurality of service processing nodes according to the node information.
16. A service processing system, the service processing system including a target service processing node and a standby service processing node, where The standby service processing node is configured to, when receiving a service processing request, send the service processing request to the target service processing node, where the target service processing node is determined according to the node determination method described in any one of claims 1-11; The target service processing node is configured to process the service processing request.
17. A computing device, comprising: a memory and a processor; the memory is configured to store computer-executable instructions, and the processor is configured to execute the computer-executable instructions, and when the computer-executable instructions are executed by the processor, the steps of the node determination method according to any one of claims 1 to 11 or the service processing method according to claim 12 or 13 or the service processing method according to claim 14 are implemented.
18. A computer-readable storage medium storing computer-executable instructions, and when the computer-executable instructions are executed by a processor, the steps of the node determination method according to any one of claims 1 to 11 or the service processing method according to claim 12 or 13 or the service processing method according to claim 14 are implemented.
19. A computer program product comprising computer programs / instructions, and when the computer programs / instructions are executed by a processor, the steps of the node determination method according to any one of claims 1 to 11 or the service processing method according to claim 12 or 13 or the service processing method according to claim 14 are implemented.