Node management method and device, equipment and storage medium

By embedding management modules in distributed service nodes, internal detection and determination of master nodes, the additional burden caused by external components is solved, and service deployment efficiency and reliability in private cloud environments are improved.

CN118939408APending Publication Date: 2024-11-12TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310532357.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-11
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

In distributed service clusters, determining the master node through external components can put additional burden on service deployment, especially in private cloud environments.

Method used

Embed a distributed management module in the distributed service node, detect the first table through the management module, and determine the main node in the distributed service node, thereby realizing internal node management and avoiding additional burdens from external components.

Benefits of technology

Node management is realized through internal management modules, which reduces the burden on service deployment, especially in a private cloud environment, and more effectively avoids the privatization of external components, improving the efficiency and reliability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118939408A_ABST
    Figure CN118939408A_ABST
Patent Text Reader

Abstract

The invention provides a node management method and device, equipment and a storage medium, and relates to the cloud technology. The method is applied to an application server, the application server comprises distributed service nodes, a distributed management module is embedded in each distributed service node, and each service node in the distributed service nodes corresponds to each management module in the distributed management module in a one-to-one mode. A first table used for recording main node information of the distributed service nodes is stored in a target database corresponding to the application server; the method comprises the following steps: aiming at any management module in distributed management modules, the management module detects a first table to obtain a first detection result; and the management module determines a master node in the distributed service nodes based on the first detection result. Therefore, extra burden brought to service deployment can be avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a node management method, apparatus, device and storage medium. Background Art

[0002] At present, in the background service architecture corresponding to the application, in order to support high-concurrency user requests and provide high-performance service quality, the background service architecture adopts a distributed cluster deployment method. In other words, a service cluster corresponding to the application can include multiple service instances, that is, multiple service nodes. These service instances have a completely equal relationship and can provide non-differentiated services to the outside world. Among them, a load balancer can be deployed outside the service cluster, and all service instances are mounted on the load balancer. After the user's request passes through the load balancer, it can randomly access a service instance.

[0003] In some special scenarios, it is necessary to determine a master node in the service cluster, which can regularly count the data in the database and generate reports, etc. Currently, the master node is mainly determined by external components of the application server, but this method will bring additional burden to service deployment, especially when the above application is running on a private cloud, this additional burden will be even greater. Summary of the invention

[0004] The present application provides a node management method, apparatus, device and storage medium, thereby avoiding additional burden on service deployment.

[0005] In a first aspect, an embodiment of the present application provides a node management method, which is applied to an application server, wherein the application server includes a distributed service node, a distributed management module is embedded in the distributed service node, each service node in the distributed service node corresponds one-to-one to each management module in the distributed management module, and a first table for recording master node information of the distributed service node is stored in a target database corresponding to the application server; the method includes: for any management module in the distributed management module, the management module detects the first table to obtain a first detection result; the management module determines the master node in the distributed service node based on the first detection result.

[0006] In the second aspect, an embodiment of the present application provides an application server, the application server includes a distributed service node, a distributed management module is embedded in the distributed service node, each service node in the distributed service node corresponds one-to-one to each management module in the distributed management module, and a first table for recording the master node information of the distributed service node is stored in a target database corresponding to the application server; for any management module in the distributed management module, the management module is used to: detect the first table to obtain a first detection result; determine the master node in the distributed service node based on the first detection result.

[0007] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory, the memory being used to store a computer program, the processor being used to call and run the computer program stored in the memory, and executing the method in the first aspect or its various implementations.

[0008] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium for storing a computer program, wherein the computer program enables a computer to execute the method in the first aspect or its various implementations.

[0009] In a fifth aspect, an embodiment of the present application provides a computer program product, comprising computer program instructions, which enable a computer to execute a method as in the first aspect or its various implementations.

[0010] In a sixth aspect, an embodiment of the present application provides a computer program, which enables a computer to execute the method in the first aspect or its various implementations.

[0011] Through the technical solution provided by the embodiment of the present application, since the distributed management module is embedded in the distributed service node, the node management method can be understood as a node management method implemented inside the distributed service node, thereby avoiding the additional burden on service deployment. Especially when the application runs in a private cloud, the node management method provided by the embodiment of the present application can better avoid the privatization deployment of external components in the service. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Figure 1 A schematic diagram of a network system;

[0013] Figure 2 A schematic diagram of a backend service architecture provided for an embodiment of the present application;

[0014] Figure 3 A flowchart of a node management method provided in an embodiment of the present application;

[0015] Figure 4A schematic diagram of a first table and a second table for timing detection provided in an embodiment of the present application;

[0016] Figure 5 A schematic diagram of a registration callback (RegisterCallback) interface provided in an embodiment of the present application;

[0017] Figure 6 A schematic diagram of an application server 600 provided in an embodiment of the present application;

[0018] Figure 7 It is a schematic block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0019] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0020] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.

[0021] Before introducing the technical solution of the present application, the following first describes the relevant knowledge of the embodiments of the present application:

[0022] 1. Cloud technology refers to a hosting technology that unifies hardware, software, network and other resources within a wide area network or local area network to achieve data computing, storage, processing and sharing.

[0023] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool, which can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The backend services of the technical network system require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the rapid development and application of the Internet industry, in the future, each item may have its own identification mark, which needs to be transmitted to the backend system for logical processing. Data of different levels will be processed separately. All kinds of industry data need strong system backing support, which can only be achieved through cloud computing.

[0024] 2. Private Cloud is to create cloud infrastructure and software and hardware resources within the firewall so that departments within an organization or enterprise can share resources in the data center. In addition to hardware resources, creating a private cloud generally also requires cloud equipment (IaaS, Infrastructure as a Service) software.

[0025] Private cloud computing also includes three levels: cloud hardware, cloud platform, and cloud service. The difference is that cloud hardware is the user's own personal computer or server, not the cloud computing vendor's data center. The purpose of cloud computing vendors to build data centers is to provide public cloud services to millions of users, so they need to have tens of millions of servers. Private cloud computing only serves friends and relatives for individuals, and only serves employees, customers, and suppliers for enterprises. Therefore, an individual or enterprise's own personal computer or server is sufficient to provide cloud services.

[0026] 3. Software Development Kit (SDK) is generally a collection of development tools used by software engineers to build application software for specific software packages, software frameworks, hardware platforms, operating systems, etc. It can simply provide some files of application program interface for a certain programming language, but it may also include complex hardware that can communicate with some embedded systems.

[0027] 4. Distributed service architecture: While ensuring that the functions remain unchanged, the application is split into front-end website (web) applications and back-end services. The back-end services are further split into multiple sub-applications, that is, multiple service instances, according to different services. These service instances jointly provide services, and the web application interacts with users by calling these service instances.

[0028] V. Service Instances: In the embodiments of the present application, service instances may be service instances in a cloud server, but are not limited thereto. A service instance in a cloud server refers to an independent computing unit virtualized from cloud computing resources. A cloud server instance includes the most basic computing components such as a central processing unit (CPU), memory, operating system, network, and disk.

[0029] 6. Distributed lock, i.e., lock in a distributed system. In the embodiment of the present application, the distributed service nodes constitute a distributed system, and the distributed lock is applied to the target database corresponding to the application server, so that the target database can only be accessed by one service node at the same time.

[0030] The following is an explanation of the technical problems to be solved by the technical solution of this application, the inventive concept and the backend service architecture:

[0031] Figure 1 A schematic diagram of a network system is shown in FIG. Figure 1 As shown, in the background service architecture corresponding to the application, in order to support high-concurrency user requests and provide high-performance service quality, the background service architecture adopts a distributed cluster deployment method. In other words, a service cluster corresponding to the application can include multiple service instances, that is, multiple service nodes. These service instances have a completely equal relationship and can provide undifferentiated services to the outside world. Among them, a load balancer can be deployed outside the service cluster, and all service instances are mounted on the load balancer. After the user's request passes through the load balancer, it can randomly access a service instance.

[0032] In some special scenarios, it is necessary to determine a master node in the service cluster, which can regularly count the data in the database and generate reports, etc. At present, the master node is mainly determined by the external components of the application server, but this method will bring additional burden to the service deployment. For example, zookeeper is an external component of the application server. After each service instance in the service cluster, that is, each service node, is started at the same time, a keyword (key) can be generated and sent to the zookeeper component. The zookeeper component uses the service node corresponding to the first key received as the master node. Among them, the zookeeper login page needs to be provided on each service node in the service cluster so that the user can call the zookeeper login page through the web application. When the user successfully logs in on the login page, zookeeper can determine the master node in the service cluster. It can be seen that this node management method performed by external components will bring additional burden to service deployment. Especially when the above application is running on a private cloud, this additional burden will be even greater. For example, assuming that node management is implemented through the zookeeper component, the zookeeper login page also needs to be privatized.

[0033] In order to solve the above technical problems, the embodiments of the present application propose that management modules can be embedded in the service cluster, that is, each service node in the distributed service node, and node management can be realized through these management modules. This method can be understood as a node management method implemented within the service cluster, thereby avoiding the additional burden on service deployment.

[0034] For example, Figure 2 A schematic diagram of a backend service architecture provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the background service architecture is applied to an application server, and the application server may be an application server corresponding to a certain application program. The background service architecture includes a distributed service node, in which a distributed management module is embedded, and each service node 21 in the distributed service node corresponds to each management module 22 in the distributed management module, and each management module 22 is connected to a target database 23 corresponding to the application server. Among them, the target database 23 may store a first table for recording the master node information of the distributed service node.

[0035] In some implementations, the target database 23 may also store a second table for recording each node information of the distributed service node.

[0036] In some implementations, the target database 23 may be a MySQL database, but is not limited thereto.

[0037] It should be understood that the MySQL database is a relational database management system. The Structured Query Language (SQL) used by MySQL is the most commonly used standardized language for accessing databases. Due to its small size, fast speed, and open source, the development of general small and medium-sized websites chooses MySQL as the website database.

[0038] It should be understood that a distributed service node is also referred to as a service cluster, a service node cluster, etc., but is not limited thereto.

[0039] It should be understood that in the embodiment of the present application, the service node 21 is also referred to as a service instance, but is not limited thereto.

[0040] It should be understood that the distributed management module is also referred to as a management module cluster, but is not limited thereto.

[0041] In some implementations, the management module 22 may be a SDK, but is not limited thereto.

[0042] In some possible implementations, the application server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), as well as big data and artificial intelligence platforms.

[0043] It should be noted that Figure 2 The background service architecture shown includes three service nodes and three management modules, but the background service architecture is only used as an example. In fact, the background service architecture applicable to the embodiment of the present application may include N service nodes and N management modules, where N can be any positive integer greater than or equal to 2.

[0044] The technical solutions of the embodiments of the present application are described in detail below through some embodiments. Among them, the solutions provided by the embodiments of the present application may involve cloud technology, but are not limited to this. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.

[0045] Figure 3A flowchart of a node management method provided in an embodiment of the present application, the method is applied to an application server, the application server includes a distributed service node, a distributed management module is embedded in the distributed service node, each service node in the distributed service node corresponds to each management module in the distributed management module, and a first table for recording the master node information of the distributed service node is stored in the target database corresponding to the application server; for any management module in the distributed management module, that is, for each management module in the distributed management module, the following node management method is executed. Among them, the method may include:

[0046] S31: The management module detects the first table to obtain a first detection result;

[0047] The first table may be established in the following manner, but is not limited thereto:

[0048] In some possible implementations, the developer may manually create the first table in the target database.

[0049] In some implementations, any management module in the distributed management modules may create a first table in the target database.

[0050] In some implementations, the developer or any one of the distributed management modules can create the first table when the distributed service node is started. It should be understood that the embodiment of the present application does not limit the timing of creating the first table.

[0051] The first table initially created may have the following two situations, but is not limited thereto:

[0052] Case 1: the master node information in the first table is empty;

[0053] Case 2: the master node information in the first table is not empty.

[0054] In the embodiment of the present application, in case one and case two, the management module may determine the master node once or multiple times. For example, the management module may determine the master node periodically or multiple times when triggered by a specific trigger event.

[0055] In some possible implementations, the first detection result includes the following two situations:

[0056] Case 1: the master node information in the first table is empty;

[0057] Case 2: the master node information in the first table is not empty, and the specific content of the master node information when the master node information is not empty.

[0058] In some implementations, the first table includes: a master node identification item, and accordingly, the master node information in the first table includes: a master node identification (IDentity, ID). For example, as shown in Table 1, the master node information in the first table includes a service node identification: 1.

[0059] Table 1

[0060] Masternode ID 1

[0061] In some implementations, the first table includes: a master node identification item and a latest recorded time item, and accordingly, the master node information in the first table includes: a master node ID and the latest recorded time of the master node ID. For example, as shown in Table 2, the master node information in the first table includes: a service node identification: 1 and a latest recorded time: 2023-05-09-13:30.

[0062] Table 2

[0063] Masternode ID Latest record time 1 2023-05-09-13:30:59

[0064] In some implementations, if the management module determines the master node multiple times, for example, assuming that the management module periodically determines the master node, in this case, the master node information in the first table may include the latest recorded time. For example, assuming that the management module detects the first table once every 30 seconds, if the master node determined in the previous cycle of the current cycle is service node 1, the first table includes the latest recorded time corresponding to the service node 1 is 2023-05-09-13:30:29, if the master node determined in the current cycle is still service node 1, then the master node ID in the first table remains unchanged, and is still service node 1, but the latest recorded time of the service node 1 is the current recorded time, for example, 2023-05-09-13:30:59.

[0065] S32: The management module determines a master node among the distributed service nodes based on the first detection result.

[0066] The management module may determine the master node in the distributed service nodes in any of the following achievable ways, but is not limited thereto:

[0067] In a first implementation mode, S32 may include:

[0068] S32-1A: The management module determines the first service node corresponding to the master node information in the first table as the master node.

[0069] In some implementations, implementation method 1 may be performed in the following situation, but is not limited thereto: the first table initially established is not empty, and the management module determines a primary node.

[0070] For example, assuming that the first table initially established includes: identification 1 of service node 1, the management module may determine service node 1 as a master node among the distributed service nodes.

[0071] In a second implementation mode, S32 may include:

[0072] S32-1B: If the first detection result indicates that the master node information in the first table is empty, the management module adds a distributed lock to the target database, detects the first table, obtains a second detection result, determines the master node in the distributed service node based on the second detection result, and releases the distributed lock;

[0073] S32-2B: If the first detection result indicates that the master node information in the first table is not empty, the management module detects the state of the first service node corresponding to the master node information in the first table, and determines the master node in the distributed service nodes based on the state of the first service node.

[0074] In some possible implementations, the second implementation may be performed in the following cases, but is not limited thereto:

[0075] In case 1, the first table initially established is empty, and the management module determines a master node once.

[0076] In case 2, the first table initially established is empty, and the management module determines the master node multiple times.

[0077] Case 3: the first table initially established is not empty, and the management module determines the master node multiple times.

[0078] The following is a detailed description of S32-1B:

[0079] In some implementations, determining a master node in the distributed service nodes based on the second detection result includes, but is not limited to:

[0080] S32-1B-1A: If the second detection result indicates that the master node information in the first table is still empty, the management module determines the second service node corresponding to the management module as the master node, and writes the node information of the second service node into the first table;

[0081] S32-1B-2A: If the second detection result indicates that the master node information in the first table is not empty, the management module determines the first service node as the master node.

[0082] It should be understood that the second service node is the service node corresponding to the management module currently executing the node management method. For example, assuming that management module 1 in service node 1 executes the node management method, the second service node refers to service node 1.

[0083] It should be understood that the first service node is the service node corresponding to the current master node information in the first table. Since the master node information in the first table may change, the service node corresponding to the master node information in the first table may also change. For example, the third service node to be mentioned below is also the service node corresponding to the master node information in the first table.

[0084] The following is an example to illustrate:

[0085] For example, assume that the distributed management module includes: management module 1 and management module 2. Assume that after the first table is initially established, for each management module in the distributed management module, each management module detects that the master node information in the first table is empty. At this time, each management module can add a distributed lock to the first table. If management module 1 first successfully locks the first table, and detects that the first table is still empty, it means that the remaining management modules in the distributed management module except management module 1 have not written the master node information in the first table. At this time, management module 1 can write the node information of its corresponding service node 1 into the first table, and management module 1 determines that service node 1 is the master node, and management module 1 releases the distributed lock. Then assume that management module 2 successfully locks the first table, but management module 2 detects that the first table is not empty. At this time, management module 2 can determine service node 1 corresponding to the master node information in the first table as the master node and release the distributed lock.

[0086] In some other possible implementations, determining a master node in the distributed service nodes based on the second detection result includes, but is not limited to:

[0087] S32-1B-1B: If the second detection result indicates that the master node information in the first table is still empty, the management module determines the second service node corresponding to the management module as the master node, and writes the node information of the second service node into the first table;

[0088] S32-1B-2B: If the second detection result indicates that the master node information in the first table is not empty, the management module detects the state of the first service node corresponding to the master node information in the first table, and determines the master node in the distributed service nodes based on the state of the first service node.

[0089] Among them, S32-1B-2B can be implemented in the following achievable ways, but is not limited to these:

[0090] In some implementations, S32-1B-2B may include:

[0091] S32-1B-2B-1A: If the first service node is in a normal state, the management module determines the first service node as a master node;

[0092] S32-1B-2B-2A: If the first service node is in an abnormal state, the management module determines the second service node corresponding to the management module as the master node, and writes the node information of the second service node into the first table.

[0093] For example, it is assumed that the distributed management module includes: management module 1 and management module 2. It is assumed that after the first table is initially established, for each management module in the distributed management module, each management module detects that the master node information in the first table is empty. At this time, each management module can add a distributed lock to the first table. If management module 1 first successfully locks the first table and detects that the first table is still empty, it means that the remaining management modules in the distributed management module except management module 1 have not written the master node information in the first table. At this time, management module 1 can write the node information of its corresponding service node 1 into the first table, and management module 1 determines that service node 1 is the master node, and management module 1 releases the distributed lock. Then assume that management module 2 successfully locks the first table, but management module 2 detects that the first table is not empty. At this time, management module 2 can detect the status of service node 1 corresponding to the master node information in the first table. If the status of service node 1 is normal, management module 2 determines that service node 1 is the master node and releases the distributed lock.

[0094] For example, it is assumed that the distributed management module includes: management module 1 and management module 2. It is assumed that after the first table is initially established, for each management module in the distributed management module, each management module detects that the master node information in the first table is empty. At this time, each management module can add a distributed lock to the first table. If management module 1 first successfully locks the first table and detects that the first table is still empty, it means that the other management modules in the distributed management module except management module 1 have not written the master node information in the first table. At this time, management module 1 can write the node information of its corresponding service node 1 into the first table, and management module 1 determines that service node 1 is the master node, and management module 1 releases the distributed lock. Then it is assumed that management module 2 successfully locks the first table, but management module 2 detects that the first table is not empty. At this time, management module 2 can detect the status of service node 1 corresponding to the master node information in the first table. If the status of service node 1 is abnormal, management module 2 determines its corresponding service node 2 as the master node and writes the node information of service node 2 into the first table, or management module 2 updates the master node information in the first table to the node information of service node 2.

[0095] In the embodiment of the present application, for any management module, it can determine the status of the service node corresponding to the master node information in the first table in any of the following implementable ways, but is not limited thereto:

[0096] The first implementation method is that the master node information includes: the master node identifier and the latest recorded time corresponding to the master node identifier. Based on this, for any management module, the management module can calculate the time difference between the current time and the latest recorded time. If the time difference is less than a first preset threshold, it is determined that the status of the service node corresponding to the master node information is normal. If the time difference is greater than or equal to the first preset threshold, it is determined that the status of the service node corresponding to the master node information is abnormal.

[0097] In some implementations, in the manner of periodically detecting the first table, the value of the first preset threshold may be greater than the duration of one detection cycle for the first table and less than the duration of two detection cycles, but is not limited thereto. For example, assuming that the detection cycle of the management module for the first table is 30 seconds, that is, a first table is detected every 30 seconds, then the value of the first preset threshold may be 45 seconds.

[0098] It should be understood that the reason why the status of the service node corresponding to the master node information is determined by comparing the time difference with the first preset threshold is that if the first table is periodically detected to periodically determine the master node, the latest record time in the first table usually does not exceed the first preset threshold. If it exceeds the first preset threshold, it means that the service node corresponding to the master node information may be down.

[0099] For example, assume that the master node information in the first table includes: master node identifier 1 and the latest recorded time corresponding to the master node identifier 1 is 2023-05-09-10:29:59, assume that the time when the management module 1 determines the status of the service node 1 is 2023-05-09-10:30:00, and assume that the first preset threshold is 45 seconds. Since the management module 1 calculates that the time difference between the current time 2023-05-09-10:30:00 and the latest recorded time 2023-05-09-10:29:59 is 1 second, which is less than the first preset threshold 45 seconds, the management module 1 determines that the service node 1 is in a normal state.

[0100] For example, assume that the master node information in the first table includes: master node identifier 1 and the latest recorded time corresponding to the master node identifier 1 is 2023-05-09-10:20:00, assume that the time when the management module 1 determines the status of the service node 1 is 2023-05-09-10:21:00, and assume that the first preset threshold is 45 seconds. Since the management module 1 calculates that the time difference between the current time 2023-05-09-10:21:00 and the latest recorded time 2023-05-09-10:20:00 is 1 minute, which is greater than the first preset threshold 45 seconds, the management module 1 determines that the service node 1 is in an abnormal state.

[0101] A second implementation method is that a second table is also stored in the target database corresponding to the application server, and the second table includes: the ID and the latest recorded time of each service node in the distributed service node; or, the second table includes: the ID, the latest recorded time and the status identifier of each service node in the distributed service node. Based on this, for any management module, the management module can calculate the time difference between the current time and the latest recorded time of the service node corresponding to the master node information in the first table in the second table. If the time difference is less than the second preset threshold, it is determined that the status of the service node corresponding to the master node information is normal. If the time difference is greater than or equal to the second preset threshold, it is determined that the status of the service node corresponding to the master node information is abnormal.

[0102] For example, the second table shown in Table 3 includes: the ID and the latest record time of each service node in the distributed service nodes.

[0103] Table 3

[0104] Node ID Latest record time 1 2023-05-09-13:30:59 2 2023-05-09-13:31:00 …… …… M 2023-05-09-13:3200

[0105] For example, the second table shown in Table 4 includes: the ID of each service node in the distributed service nodes, the latest record time, and the status identifier of each service node.

[0106] Table 4

[0107] Node ID Latest record time Status indicator 1 2023-05-09-13:30:59 1 2 2023-05-09-13:31:00 1 …… …… …… M 2023-05-09-13:3200 0

[0108] Among them, the state flag 0 indicates that the node is in an abnormal state, and the state flag 1 indicates that the node is in a normal state.

[0109] In some implementations, in the manner of periodically detecting the second table, the value of the second preset threshold may be greater than the duration of one detection cycle for the second table and less than the duration of two detection cycles, but is not limited thereto. For example, assuming that the detection cycle of the management module for the second table is 5 seconds, that is, a second table is detected every 5 seconds, then the value of the second preset threshold may be 8 seconds.

[0110] It should be understood that the reason why the status of the service node corresponding to the master node information is determined by comparing the time difference with the second preset threshold is that if the second table is checked periodically, the latest record time in the second table usually does not exceed the second preset threshold. If it exceeds the second preset threshold, it means that the service node corresponding to the master node information may be down.

[0111] For example, assuming that the master node information in the first table includes: master node identification 1, and the second table includes: the latest recorded time corresponding to the master node identification 1 is 2023-05-09-10:29:59, assuming that the time when the management module 1 determines the status of the service node 1 is 2023-05-09-10:30:00, and assuming that the second preset threshold is 8 seconds, since the management module 1 calculates that the time difference between the current time 2023-05-09-10:30:00 and the latest recorded time 2023-05-09-10:29:59 in the second table is 1 second, which is less than the preset threshold 8 seconds, therefore, the management module 1 determines that the service node 1 is in a normal state.

[0112] For example, assume that the master node information in the first table includes: master node identification 1, and the second table includes: the latest recorded time corresponding to the master node identification 1 is 2023-05-09-10:20:00, assume that the time when the management module 1 determines the status of the service node 1 is 2023-05-09-10:21:00, and assume that the preset threshold is 8 seconds, because the management module 1 calculates that the time difference between the current time 2023-05-09-10:21:00 and the latest recorded time 2023-05-09-10:20:00 is 1 minute, which is greater than the preset threshold 8 seconds. Therefore, the management module 1 determines that the service node 1 is in an abnormal state.

[0113] It should be understood that the above-mentioned implementation method 1 can be performed when the first table is periodically detected to write the master node information, and the above-mentioned implementation method 2 can be performed when the second table is periodically detected to write the information of each service node. Based on this, Figure 4As shown, two timers can be set in the distributed management module, so that each management module can regularly detect the master node information in the first table based on the timer corresponding to the first table, and regularly detect the node information in the second table based on the timer corresponding to the second table.

[0114] In a third implementation method, a second table is also stored in the target database corresponding to the application server, and the second table includes: the ID of each service node in the distributed service node and the status identifier of each service node; or the second table includes: the ID of each service node in the distributed service node, the latest record time and the status identifier of each service node. Based on this, for any management module, the management module can directly determine the status of the service node corresponding to the master node information in the second table as the status of the service node.

[0115] For example, the second table shown in Table 5 includes: the ID of each service node in the distributed service nodes and the status identifier of each service node.

[0116] Table 5

[0117] Node ID Status indicator 1 1 2 1 …… …… M 0

[0118] Among them, the state flag 0 indicates that the node is in an abnormal state, and the state flag 1 indicates that the node is in a normal state.

[0119] For example, assuming that the master node information in the first table includes: master node identifier 1, and the second table includes: the status identifier corresponding to the master node identifier 1, such as flag1, indicating that the node is in a normal state, then the management module can determine that service node 1 is in a normal state through the second table.

[0120] In some other possible implementations, S32-1B-2B may include:

[0121] S32-1B-2B-1B: If the first service node is in a normal state, the management module determines the first service node as a master node;

[0122] S32-1B-2B-2B: If the first service node is in an abnormal state, the management module determines the next node of the current master node as a new master node. If the new master node is the same as the second service node, the node information of the second service node is written into the first table.

[0123] It should be understood that the method for determining the service node status can be referred to above, and the embodiments of the present application will not be described in detail.

[0124] For example, it is assumed that the distributed management module includes: management module 1 and management module 2. It is assumed that after the first table is initially established, for each management module in the distributed management module, each management module detects that the master node information in the first table is empty. At this time, each management module can add a distributed lock to the first table. If management module 1 first successfully locks the first table and detects that the first table is still empty, it means that the remaining management modules except management module 1 in the distributed management module have not written the master node information in the first table. At this time, management module 1 can write the node information of its corresponding service node 1 into the first table, and management module 1 determines that service node 1 is the master node, and management module 1 releases the distributed lock. Then it is assumed that management module 2 successfully locks the first table, but management module 2 detects that the first table is not empty. At this time, management module 2 can detect the status of service node 1 corresponding to the master node information in the first table. If the status of service node 1 is abnormal, management module 2 determines the next service node of service node 1, that is, service node 2, as the new master node, and writes the node information of service node 2 into the first table, or management module 2 updates the master node information in the first table to the node information of service node 2.

[0125] The following is a detailed description of S32-2B:

[0126] In some implementations, determining a master node in the distributed service nodes based on the state of the first service node includes, but is not limited to:

[0127] S32-2B-1A: If the first service node is in a normal state, the management module determines the first service node as a master node;

[0128] S32-2B-2A: If the first service node is in an abnormal state, the management module defaults the next node of the current master node to be the new master node. If the new master node is the same as the second service node, the node information of the second service node is written into the first table.

[0129] It should be understood that the method for determining the service node status can be referred to above, and the embodiments of the present application will not be described in detail.

[0130] For example, it is assumed that the distributed management module includes: management module 1 and management module 2. It is assumed that in the non-first cycle detection process for the first table, for each management module in the distributed management module, each management module detects that the master node information in the first table is non-empty. At this time, each management module can detect the state of the first service node. It is assumed that the management module 1 detects that the state of the first service node is normal, then the management module 1 determines the first service node as the master node. Similarly, it is assumed that the management module 2 also detects that the state of the first service node is normal, then the management module 2 also determines the first service node as the master node.

[0131] For example, assume that the distributed management module includes: management module 1 and management module 2. Assume that in the non-first cycle detection process for the first table, for each management module in the distributed management module, each management module detects that the master node information in the first table is non-empty. At this time, each management module can detect the state of the first service node. Assume that the first service node is service node 1, and assume that management module 1 detects that the state of service node 1 is abnormal, then management module 1 determines the next service node 2 of service node 1 as the master node. Similarly, assume that management module 2 also detects that the state of service node 1 is abnormal, then management module 2 also determines the next service node 2 of service node 1 as the master node, and writes the node information of service node 2 into the first table, or in other words, updates the node information in the first table to the node information of service node 2.

[0132] In some possible implementations, if the master node information includes: the master node identifier and the latest recorded time of the master node identifier; the node management method also includes: if the first service node is in a normal state, and the first service node is the same as the second service node corresponding to the management module, the management module updates the latest recorded time of the master node identifier.

[0133] For example, assume that the distributed management module includes: management module 1 and management module 2. Assume that in the first periodic detection process for the first table, the master node information in the first table includes: identification 1 of service node 1, and the latest recorded time is 2023-05-09-10:30:00, and in the second periodic detection process for the first table, for each management module in the distributed management module, each management module detects that the master node information in the first table is non-empty. At this time, each management module can detect the status of service node 1. Assuming that management module 1 detects that the status of service node 1 is normal, management module 1 determines service node 1 as the master node, and can update the latest recorded time to the current time, for example, 2023-05-09-10:30:15. Similarly, assuming that management module 2 also detects that the status of service node 1 is normal, management module 2 also determines service node 1 as the master node.

[0134] In some other implementations, determining a master node in the distributed service nodes based on the state of the first service node includes, but is not limited to:

[0135] S32-2B-1B: If the first service node is in a normal state, the management module determines the first service node as a master node;

[0136] S32-2B-2B: If the first service node is in an abnormal state, the management module adds a distributed lock to the target database, and continues to detect the status of the third service node corresponding to the master node information in the first table, and determines the master node in the distributed service nodes based on the status of the third service node, and releases the distributed lock.

[0137] It should be understood that the method for determining the service node status can be referred to above, and the embodiments of the present application will not be described in detail.

[0138] In some possible implementations, if the master node information includes: the master node identifier and the latest recorded time of the master node identifier; the node management method also includes: if the first service node is in a normal state, and the first service node is the same as the second service node corresponding to the management module, the management module updates the latest recorded time of the master node identifier.

[0139] It should be understood that examples of this achievable method can be found above, and the embodiments of the present application will not be described in detail.

[0140] Wherein, determining the master node in the distributed service node based on the state of the third service node and releasing the distributed lock include, but are not limited to:

[0141] S32-2B-2B-1: If the third service node is in a normal state, the management module determines the third service node as a master node;

[0142] S32-2B-2B-2: If the third service node is in an abnormal state, the management module determines the second service node corresponding to the management module as the main node, and writes the node information of the second service node into the first table.

[0143] For example, it is assumed that the distributed management module includes: management module 1 and management module 2. In the non-first cycle detection process for the first table, for each management module in the distributed management module, each management module detects that the master node information in the first table is not empty, and detects that the service node 1 corresponding to the master node information in the first table is in an abnormal state. At this time, each management module can add a distributed lock to the first table. If the management module 2 first successfully locks the first table, and still detects that the service node 1 corresponding to the master node information in the first table is in an abnormal state, then the management module 2 can write the node information of the corresponding service node 2 into the first table, and the management module 2 determines that the service node 2 is the master node, and the management module 2 releases the distributed lock. Next, it is assumed that the management module 1 successfully locks the first table, and the management module 1 detects that the first table is not empty. At this time, the management module 1 detects that the service node 2 corresponding to the master node information in the first table is in a normal state, then the management module 1 determines that the service node 2 is the master node, and releases the distributed lock.

[0144] In some possible implementations, if the master node information includes: the master node identifier and the latest recorded time of the master node identifier; then the above-mentioned node management method also includes: if the third service node is in a normal state, and the third service node is the same as the second service node corresponding to the management module, then the management module updates the latest recorded time of the master node identifier.

[0145] It should be understood that examples of this achievable method can be found above, and the embodiments of the present application will not be described in detail.

[0146] The following is an example of the node management method being described by taking the case where the first table is empty when the distributed service node is started and periodic detection is performed on the first table. It should be understood that the node management method provided in the embodiment of the present application is not limited to this example.

[0147] For example, it is assumed that the distributed management module includes: management module 1 and management module 2. Assume that in the first cycle detection process for the first table, for each management module in the distributed management module, each management module detects that the master node information in the first table is empty. Assume that management module 1 first successfully locks the first table. At this time, management module 1 determines that the first table is still empty, then management module 1 can write the node information of service node 1 into the first table and release the distributed lock. Then management module 2 successfully locks the first table again. At this time, management module 2 determines that the first table is not empty. At this time, management module 2 can directly use service node 1 as the master node and release the distributed lock. In the second cycle detection process for the first table, each management module detects that the master node information in the first table is not empty, and detects the status of service node 1. If service node 1 is in a normal state, each management module uses service node 1 as the master node, and if the master node information includes: the latest record time of the master node, then service node 1 can update the latest record time to the current time. If service node 1 is in an abnormal state, each management module adds a distributed lock to the first table. If service node 2 successfully locks the first table first, service node 2 continues to detect the status of service node 1. If the status of service node 1 is still abnormal, management module 2 determines service node 2 as the master node, writes the node information of service node 2 into the first table, and releases the distributed lock. If service node 1 returns to normal, it successfully locks the first table. Service node 1 continues to detect the status of service node 2. If the status of service node 2 is normal, management module 1 determines service node 2 as the master node and releases the distributed lock. The subsequent periodic detection process for the first table is the same as the second periodic detection process for the first table, which will not be repeated.

[0148] The embodiment of the present application provides a node management method, which includes: for each management module in the distributed management module, the management module detects the first table to obtain a first detection result; and determines the master node in the distributed service node based on the first detection result. Since the distributed management module is embedded in the distributed service node, the node management method can be understood as a node management method implemented inside the distributed service node, thereby avoiding the additional burden on the service deployment. In particular, when the application runs in a private cloud, the node management method provided by the embodiment of the present application can better avoid the privatized deployment of external components in the service.

[0149] Furthermore, the embodiments of the present application may be applicable to situations where the master node is periodically determined, so that abnormal master nodes can be discovered and updated in a timely manner to ensure that specific tasks that require the master node to be implemented are executed in a timely manner.

[0150] It should be understood that the master node usually needs to implement specific tasks, for example, it needs to regularly count the data in the database and generate reports, etc. Therefore, after the management module determines the master node, the following implementation methods can also be used, but are not limited to these:

[0151] In some possible implementations, for any management module in the distributed management modules, after the management module determines the second service node corresponding to the management module as the master node, the management module also sends a first notification message to the second service node; wherein the first notification message is used to notify the second service node that it is the master node in the distributed service nodes.

[0152] For example, assuming that management module 1 determines that service node 1 to which it belongs is a master node, management module 1 may send a first notification message to service node 1 to notify service node 1 that service node 1 is a master node in the distributed service nodes.

[0153] In some implementations, after receiving the first notification message, the second service node may perform a specific task, for example, start a timer, start counting data in a database, and generate a report.

[0154] It should be understood that usually the master node needs to detect the status of the slave node. Therefore, after the management module determines the master node, the following implementation methods may also be used, but are not limited thereto:

[0155] In some possible implementations, the target database corresponding to the application server also stores a second table for recording each node information of the distributed service nodes; accordingly, for any management module in the distributed management module, after the management module determines the second service node corresponding to the management module as the master node, the management module detects the second table to obtain the status of at least one slave node in the second table; the management module reports the status of at least one slave node to the second service node.

[0156] In some implementations, the management module may periodically detect the second table.

[0157] In some possible implementations, the management module can calculate the time difference between the latest recorded time of a node stored in the second table and the current time. When the time difference is less than a third preset threshold, the state of the node is determined to be a normal state; when the time difference is greater than or equal to the third preset threshold, the state of the node is determined to be an abnormal state.

[0158] In some implementations, the value of the third preset threshold may be greater than the duration of one detection cycle for the second table and less than two detection cycles, but is not limited thereto. For example, assuming that the detection cycle of the management module for the second table is 5 seconds, that is, a second table is detected every 5 seconds, then the value of the third preset threshold may be 8 seconds.

[0159] In some implementations, the management module may detect a status identifier of a node and determine the status of the node based on the status identifier. For example, assuming that the status identifier of service node 1 is 1, the management module may determine that service node 1 is in a normal state. Assuming that the status identifier of service node 2 is 0, the management module may determine that service node 2 is in an abnormal state.

[0160] In some implementations, the at least one slave node includes at least one of the following: an offline slave node and a newly online slave node. In other words, the management module may report the ID and corresponding status of the offline slave node to the second service node: offline, or may report the ID and corresponding status of the newly online slave node to the second service node: online. Alternatively, the ID and corresponding status of the offline slave node may be reported to the second service node: offline, and the ID and corresponding status of the newly online slave node may be reported to the second service node: online.

[0161] For example, assuming that management module 1 determines that service node 1 to which it belongs is the master node, management module 1 can periodically query the second table. Assuming that the management module detects that service node 2 has an abnormality in the current period, and service node 3 is newly added to the second table, management module 1 can report the following information to service node 1: service node 2, status: offline; service node 3, status: online.

[0162] It should be understood that the master node usually needs to implement specific tasks, for example, it needs to regularly count the data in the database and generate reports, etc. Therefore, after the second service node corresponding to the management module loses the master node, the following implementation methods can also be adopted, but are not limited to these:

[0163] In some possible implementations, for any management module in the distributed management modules, if the second service node corresponding to the management module was the master node among the distributed service nodes in the previous cycle, but is not the master node among the distributed service nodes in the current cycle, the management module sends a second notification message to the second service node; wherein the second notification message is used to notify the second service node that it was the master node among the distributed service nodes in the previous cycle, but is not the master node among the distributed service nodes in the current cycle.

[0164] For example, assuming that the service node 1 to which the management module 1 belongs was the master node in the previous cycle but is not the master node in the current cycle, the management module 1 can send a second notification message to the service node 1 to notify the service node 1 that the service node 1 was the master node among the distributed service nodes in the previous cycle but is not the master node among the distributed service nodes in the current cycle.

[0165] In some possible implementations, after receiving the second notification message, the second service node cannot execute the specific task that is to be performed by the main node. In this case, the second service node needs to perform certain operations, such as stopping a timer, where the timer is a timer used by the second service node to store data in a statistical database and generate reports.

[0166] It should be understood that usually the slave node needs to report its own information to the master node regularly, for example, reporting the load of the slave node itself, so that the master node can subsequently perform task scheduling based on the load of the slave node, etc. Based on this. The embodiment of the present application also proposes the following implementation methods, but is not limited to this:

[0167] In some possible implementations, for any management module in the distributed management module, if the second service node corresponding to the management module is a slave node in the distributed service node in the current cycle, and the master node of the distributed service node in the current cycle is different from the master node in the previous cycle, then the management module sends a third notification message to the second service node; wherein the third notification message is used to notify the master node of the distributed service node in the current cycle.

[0168] For example, assuming that service node 3 to which management module 3 belongs is a slave node in the current cycle, and service node 1 to which management module 1 belongs is a master node in the previous cycle, and service node 2 to which management module 2 belongs is the master node in the current cycle, then management module 3 can send a third notification message to service node 3 to inform service node 3 that service node 2 is the master node in the current cycle.

[0169] It should be understood that if the event of reporting the first notification message, the second notification message, the third notification message and the state of at least one slave node is called a notification cluster event, then in the embodiment of the present application, the notification cluster event can be implemented in the following implementable manners, but is not limited thereto:

[0170] In some implementations, the distributed service node, or the application, provides a RegisterCallback interface to notify cluster events. Figure 5A schematic diagram of a RegisterCallback interface provided in an embodiment of the present application, wherein after the application is started, the application can call the RegisterCallback interface and pass the Figure 5 The function interface shown includes: a first function (), a second function (), a third function (master node ID), and a fourth function (node ​​ID, status). The first function is used to report a first notification message. The second function is used to report a third notification message. The fourth function is used to report the status of at least one slave node. Each management module in the distributed management module can call any function interface in the register callback (RegisterCallback) interface, and achieve the purpose of notifying cluster events by calling any function interface.

[0171] In an embodiment of the present application, the management module may notify the second service node corresponding to the management module of the cluster event, so that the second service node may be informed of the cluster event in a timely manner and perform the corresponding specific task.

[0172] The preferred embodiments of the present application are described in detail above in conjunction with the accompanying drawings. However, the present application is not limited to the specific details in the above embodiments. Within the technical concept of the present application, the technical solution of the present application can be subjected to a variety of simple modifications, and these simple modifications all belong to the protection scope of the present application. For example, the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present application will not further explain various possible combinations. For another example, the various different embodiments of the present application can also be arbitrarily combined, as long as they do not violate the ideas of the present application, they should also be regarded as the contents disclosed in the present application.

[0173] It should also be understood that in the various method embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0174] The method provided in the embodiment of the present application is described above, and the device provided in the embodiment of the present application is described below.

[0175] Figure 6 A schematic diagram of an application server 600 provided in an embodiment of the present application is shown as follows: Figure 6As shown, the application server 600 includes a distributed service node, in which a distributed management module is embedded, each service node 610 in the distributed service node corresponds one-to-one to each management module 620 in the distributed management module, and a first table for recording the master node information of the distributed service node is stored in the target database corresponding to the application server; for any management module 620 in the distributed management module, the management module 620 is used to: detect the first table to obtain a first detection result; determine the master node in the distributed service node based on the first detection result.

[0176] In some possible implementations, the management module 620 is specifically used to: if the first detection result indicates that the master node information in the first table is empty, then add a distributed lock to the target database, and detect the first table to obtain a second detection result, determine the master node in the distributed service nodes based on the second detection result, and release the distributed lock; if the first detection result indicates that the master node information in the first table is not empty, then detect the status of the first service node corresponding to the master node information in the first table, and determine the master node in the distributed service nodes based on the status of the first service node.

[0177] In some implementable embodiments, the management module 620 is specifically used to: if the second detection result indicates that the master node information in the first table is still empty, then the second service node corresponding to the management module 620 is determined as the master node, and the node information of the second service node is written into the first table; if the second detection result indicates that the master node information in the first table is not empty, then the first service node is determined as the master node.

[0178] In some possible implementations, the management module 620 is specifically used to: if the first service node is in a normal state, determine the first service node as the master node; if the first service node is in an abnormal state, add a distributed lock to the target database, and continue to detect the state of the third service node corresponding to the master node information in the first table, and determine the master node in the distributed service nodes based on the state of the third service node, and release the distributed lock.

[0179] In some possible implementations, the master node information includes: the master node identifier and the latest recorded time of the master node identifier; the management module 620 is also used to: if the first service node is in a normal state, and the first service node is the same as the second service node corresponding to the management module 620, then update the latest recorded time of the master node identifier.

[0180] In some possible implementations, the management module 620 is specifically used to: if the third service node is in a normal state, determine the third service node as the main node; if the third service node is in an abnormal state, determine the second service node corresponding to the management module 620 as the main node, and write the node information of the second service node into the first table.

[0181] In some possible implementations, the master node information includes: the master node identifier and the latest recorded time of the master node identifier; the management module 620 is also used to: if the third service node is in a normal state, and the third service node is the same as the second service node corresponding to the management module 620, then update the latest recorded time of the master node identifier.

[0182] In some implementations, the management module 620 is also used to: after determining the second service node corresponding to the management module 620 as the master node, send a first notification message to the second service node; wherein the first notification message is used to notify the second service node that it is the master node in the distributed service nodes.

[0183] In some possible implementations, the target database corresponding to the application server also stores a second table for recording each node information of the distributed service nodes; the management module 620 is also used to: after determining the second service node corresponding to the management module 620 as the master node, detect the second table to obtain the status of at least one slave node in the second table; and report the status of at least one slave node to the second service node.

[0184] In some implementations, the at least one slave node includes at least one of the following: an offline slave node and a newly online slave node.

[0185] In some possible implementations, the management module 620 is also used to: if the second service node corresponding to the management module 620 is the master node among the distributed service nodes in the previous cycle, but is not the master node among the distributed service nodes in the current cycle, then send a second notification message to the second service node; wherein the second notification message is used to notify the second service node that it was the master node among the distributed service nodes in the previous cycle, but is not the master node among the distributed service nodes in the current cycle.

[0186] In some possible implementations, the management module 620 is also used to: if the second service node corresponding to the management module 620 is a slave node in the distributed service node in the current cycle, and the master node of the distributed service node in the current cycle is different from the master node in the previous cycle, then send a third notification message to the second service node; wherein the third notification message is used to notify the master node of the distributed service node in the current cycle.

[0187] It should be understood that the device embodiment and the method embodiment may correspond to each other, and similar descriptions may refer to the method embodiment. To avoid repetition, they will not be described here. Specifically, Figure 6 The application server 600 shown may execute Figure 3 The corresponding method embodiments, and the aforementioned and other operations and / or functions of each module in the application server 600 are respectively to implement Figure 3 For the sake of brevity, the corresponding processes in each method are not repeated here.

[0188] The application server 600 of the embodiment of the present application is described above from the perspective of the functional module in conjunction with the accompanying drawings. It should be understood that the functional module can be implemented in hardware form, can be implemented by instructions in software form, and can also be implemented by a combination of hardware and software modules. Specifically, the steps of the method embodiment in the embodiment of the present application can be completed by the hardware integrated logic circuit and / or software form instructions in the processor, and the steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or a combination of hardware and software modules in the decoding processor to perform. Optionally, the software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory, and completes the steps in the above method embodiment in conjunction with its hardware.

[0189] Figure 7 It is a schematic block diagram of an electronic device provided in an embodiment of the present application.

[0190] like Figure 7 As shown, the electronic device may include:

[0191] The memory 710 and the processor 720, the memory 710 is used to store the computer program and transmit the program code to the processor 720. In other words, the processor 720 can call and run the computer program from the memory 710 to implement the method in the embodiment of the present application.

[0192] For example, the processor 720 may be configured to execute the above method embodiments according to instructions in the computer program.

[0193] In some embodiments of the present application, the processor 720 may include but is not limited to:

[0194] General-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc.

[0195] In some embodiments of the present application, the memory 710 includes but is not limited to:

[0196] Volatile memory and / or non-volatile memory. Among them, the non-volatile memory can be read-only memory (ROM), programmable ROM (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM) or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DR RAM).

[0197] In some embodiments of the present application, the computer program may be divided into one or more modules, which are stored in the memory 710 and executed by the processor 720 to complete the method provided by the present application. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program in the electronic device.

[0198] like Figure 7 As shown, the electronic device may also include:

[0199] The transceiver 730 may be connected to the processor 720 or the memory 710 .

[0200] The processor 720 may control the transceiver 730 to communicate with other devices, specifically, to send information or data to other devices, or to receive information or data sent by other devices. The transceiver 730 may include a transmitter and a receiver. The transceiver 730 may further include an antenna, and the number of antennas may be one or more.

[0201] It should be understood that the various components in the electronic device are connected via a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus and a status signal bus.

[0202] The present application also provides a computer storage medium on which a computer program is stored, and when the computer program is executed by a computer, the computer can perform the method of the above method embodiment. In other words, the present application embodiment also provides a computer program product containing instructions, and when the instructions are executed by a computer, the computer can perform the method of the above method embodiment.

[0203] When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integration. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital video disc (digital video disc, DVD)), or a semiconductor medium (e.g., a solid state drive (solid state disk, SSD)), etc.

[0204] Those of ordinary skill in the art will appreciate that the modules and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0205] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the module is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.

[0206] The modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. For example, each functional module in each embodiment of the present application may be integrated into a processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.

[0207] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A node management method, It is characterized in that The method is applied to an application server, the application server includes a distributed service node, a distributed management module is embedded in the distributed service node, each service node in the distributed service node corresponds to each management module in the distributed management module, and a first table for recording master node information of the distributed service node is stored in a target database corresponding to the application server; the method includes: For any one of the distributed management modules, the management module detects the first table to obtain a first detection result; The management module determines a master node among the distributed service nodes based on the first detection result.

2. The method according to claim 1, It is characterized in that The management module determines a master node among the distributed service nodes based on the first detection result, including: If the first detection result indicates that the master node information in the first table is empty, the management module adds a distributed lock to the target database, detects the first table, obtains a second detection result, determines the master node in the distributed service node based on the second detection result, and releases the distributed lock; If the first detection result indicates that the master node information in the first table is not empty, the management module detects the state of the first service node corresponding to the master node information in the first table, and determines the master node in the distributed service nodes based on the state of the first service node.

3. The method according to claim 2, It is characterized in that The determining the master node among the distributed service nodes based on the second detection result includes: If the second detection result indicates that the master node information in the first table is still empty, the management module determines the second service node corresponding to the management module as the master node, and writes the node information of the second service node into the first table; If the second detection result indicates that the master node information in the first table is not empty, the management module determines the first service node as the master node.

4. The method according to claim 2, It is characterized in that The determining the master node in the distributed service nodes based on the state of the first service node includes: If the first service node is in a normal state, the management module determines the first service node as a master node; If the first service node is in an abnormal state, the management module adds a distributed lock to the target database, continues to detect the state of the third service node corresponding to the master node information in the first table, determines the master node in the distributed service nodes based on the state of the third service node, and releases the distributed lock.

5. The method according to claim 4, It is characterized in that The master node information includes: a master node identifier and the latest record time of the master node identifier; the method further includes: If the first service node is in a normal state, and the first service node is the same as the second service node corresponding to the management module, the management module updates the latest recorded time of the master node identifier.

6. The method according to claim 4, It is characterized in that The determining the master node in the distributed service nodes based on the state of the third service node includes: If the third service node is in a normal state, the management module determines the third service node as a master node; If the third service node is in an abnormal state, the management module determines the second service node corresponding to the management module as a master node, and writes the node information of the second service node into the first table.

7. The method according to claim 6, It is characterized in that The master node information includes: a master node identifier and the latest record time of the master node identifier; the method further includes: If the third service node is in a normal state, and the third service node is the same as the second service node corresponding to the management module, the management module updates the latest recorded time of the master node identifier.

8. The method according to claim 3 or 6, It is characterized in that After the management module determines the second service node corresponding to the management module as the main node, the method further includes: The management module sends a first notification message to the second service node; The first notification message is used to notify that the second service node is a master node among the distributed service nodes.

9. The method according to claim 3 or 6, It is characterized in that The target database corresponding to the application server also stores a second table for recording each node information of the distributed service node; After the management module determines the second service node corresponding to the management module as the main node, the method further includes: The management module detects the second table to obtain a status of at least one slave node in the second table; The management module reports the status of the at least one slave node to the second service node.

10. The method according to claim 9, It is characterized in that The at least one slave node includes at least one of the following: an offline slave node and a newly online slave node.

11. The method according to any one of claims 1 to 7, It is characterized in that Also includes: If the second service node corresponding to the management module was a master node among the distributed service nodes in the previous cycle, but is not a master node among the distributed service nodes in the current cycle, the management module sends a second notification message to the second service node; The second notification message is used to notify that the second service node was a master node among the distributed service nodes in the previous cycle, but is not a master node among the distributed service nodes in the current cycle.

12. The method according to any one of claims 1 to 7, It is characterized in that Also includes: If the second service node corresponding to the management module is a slave node in the distributed service node in the current cycle, and the master node of the distributed service node in the current cycle is different from the master node in the previous cycle, the management module sends a third notification message to the second service node; The third notification message is used to notify the master node of the distributed service node in the current cycle.

13. An application server, It is characterized in that The application server includes a distributed service node, in which a distributed management module is embedded, each service node in the distributed service node corresponds to each management module in the distributed management module one by one, and a first table for recording master node information of the distributed service node is stored in a target database corresponding to the application server; for any one management module in the distributed management module, the management module is used to: Testing the first table to obtain a first test result; A master node among the distributed service nodes is determined based on the first detection result.

14. An electronic device, It is characterized in that include: A processor and a memory, the memory being used to store a computer program, and the processor being used to call and run the computer program stored in the memory to execute the method according to any one of claims 1 to 12.

15. A computer-readable storage medium, It is characterized in that Used to store a computer program, which, when executed on a computer, causes the computer to execute the method according to any one of claims 1 to 12.