CN106712981B - Node change notification method and device - Google Patents

Node change notification method and device Download PDF

Info

Publication number
CN106712981B
CN106712981B CN201510438825.6A CN201510438825A CN106712981B CN 106712981 B CN106712981 B CN 106712981B CN 201510438825 A CN201510438825 A CN 201510438825A CN 106712981 B CN106712981 B CN 106712981B
Authority
CN
China
Prior art keywords
node
client
temporary
distributed lock
shared resource
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510438825.6A
Other languages
Chinese (zh)
Other versions
CN106712981A (en
Inventor
王俊翔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201510438825.6A priority Critical patent/CN106712981B/en
Publication of CN106712981A publication Critical patent/CN106712981A/en
Application granted granted Critical
Publication of CN106712981B publication Critical patent/CN106712981B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Computer And Data Communications (AREA)

Abstract

The application relates to the technical field of computers, in particular to a node change notification method and a node change notification device, which are used for solving the problem that a node change mode in an existing distributed system increases a lot of unnecessary system overhead. The node change notification method provided by the embodiment of the application comprises the following steps: when a client in the distributed system needs to access shared resources, a temporary node creation request is sent to a coordination server; the client judges whether the temporary node of the client meets the condition of acquiring the distributed lock or not according to the node information of a plurality of temporary nodes waiting to acquire the distributed lock of the shared resource at present; and if not, sending a registration request aiming at the node change event of the previous temporary node to the coordination server, and requesting the coordination server to notify the client after the previous temporary node is deleted.

Description

Node change notification method and device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for notifying a node change.
Background
In a distributed system, multiple application systems may access the same shared resource over a computer network. In order to make each application system operate correctly and effectively, concurrent access to the same shared resource by a plurality of application systems must be controlled to prevent different application systems from interfering with each other and destroying the consistency of resource data.
To control concurrent access to the same shared resource by multiple application systems, a distributed lock service provided by a distributed application coordination service (i.e., ZooKeeper) may be used. The specific implementation process mainly comprises the following steps: after a client requests a ZooKeeper server to establish a temporary node under a shared resource name to be accessed for the client, judging whether the temporary node of the client is the temporary node with the minimum node sequence number in all temporary nodes under the shared resource name to be accessed, if so, determining that the client acquires a distributed lock and can access resources, otherwise, entering a waiting state, and registering a node change event to the ZooKeeper server; when the node change event arrives, whether the temporary node is the temporary node with the minimum sequence number of the shared resource to be accessed corresponding to the current node is judged.
In the above flow, the node change event includes not only releasing the lock and deleting the corresponding temporary node by the client that obtains the distributed lock, but also passively deleting the corresponding temporary node by the other clients that do not obtain the distributed lock due to disconnection with the ZooKeeper server, which results in that the client receives a lot of node change events without end, and thus, the client performs the judgment of whether to obtain the distributed lock every time, and a lot of unnecessary system overhead is increased. Thus, in a large-scale cluster environment, the system performance will be greatly affected.
Disclosure of Invention
The embodiment of the application provides a node change notification method and a node change notification device, which are used for solving the problem that a node change mode in the existing distributed system increases a lot of unnecessary system overhead and greatly affects the system performance.
An embodiment of the present application provides a node change notification method, including:
when a client in the distributed system needs to access shared resources, sending a temporary node creation request to a coordination server, wherein the temporary node creation request is used for requesting the coordination server to create a temporary node waiting for acquiring a distributed lock of the shared resources for the client;
the client judges whether the temporary node of the client meets the condition of acquiring the distributed lock or not according to the node information of a plurality of temporary nodes waiting to acquire the distributed lock of the shared resource at present;
if not, sending a registration request aiming at the node change event of the previous temporary node to the coordination server, and requesting the coordination server to notify the client after the previous temporary node is deleted; the previous temporary node is the last temporary node capable of acquiring the distributed lock before the temporary node of the client in the plurality of temporary nodes waiting for acquiring the distributed lock of the shared resource.
Optionally, the meeting the condition of acquiring the distributed lock specifically includes:
and the node sequence number in the plurality of temporary nodes currently waiting for acquiring the distributed lock of the shared resource is the minimum.
Optionally, after determining that the temporary node of the client satisfies the condition for acquiring the distributed lock, the client includes:
and the client accesses the shared resource by using the acquired distributed lock, and requests the coordination server to delete the temporary node of the client after the access is finished.
Optionally, the determining, by the client, whether the temporary node of the client meets the condition of acquiring the distributed lock according to node information of a plurality of temporary nodes currently waiting to acquire the distributed lock of the shared resource includes:
the client acquires node information of a plurality of temporary nodes under a lock directory corresponding to the shared resource;
and the client judges whether the temporary node of the client meets the condition of acquiring the distributed lock or not based on the acquired node information of the temporary nodes in the lock directory.
Optionally, the determining, by the client, whether the temporary node of the client meets the condition of acquiring the distributed lock according to node information of a plurality of temporary nodes currently waiting to acquire the distributed lock of the shared resource includes:
the client receives node information of a temporary node which is sent by the coordination server and created for the client, and node information of other temporary nodes waiting for acquiring the distributed lock of the shared resource;
and the client judges whether the temporary node of the client meets the condition of acquiring the distributed lock or not based on the node information of the temporary node of the client, which is sent by the coordination server, and the node information of other temporary nodes waiting for acquiring the distributed lock of the shared resource.
Optionally, after the client sends a registration request for a node change event of a previous temporary node to the coordination server, the method further includes:
and after receiving the node change event, the client returns to the step of judging whether the temporary node of the client can acquire the distributed lock currently.
Another embodiment of the present application provides a node change notification method, including:
a coordination server in a distributed system receives a temporary node creation request sent by a client when the client needs to request a shared resource;
the coordination server creates a temporary node for the client to wait for acquiring the distributed lock of the shared resource;
the coordination server receives a registration request of a node change event aiming at a previous temporary node, which is sent by the client, wherein the registration request is used for requesting the coordination server to inform the client after the previous temporary node is deleted; the previous temporary node is the last temporary node which can obtain the distributed lock before the temporary node of the client in a plurality of temporary nodes waiting for obtaining the distributed lock of the shared resource;
and after determining that the previous temporary node is deleted, the coordination server sends a node change event to the client to indicate that the previous temporary node of the client is deleted.
Optionally, after the coordination server creates a temporary node for the client that waits for acquiring the distributed lock of the shared resource, the method further includes:
and the coordination server adds the node information of the temporary node created for the client to a lock directory corresponding to the shared resource.
Optionally, after the coordination server creates a temporary node for the client that waits for acquiring the distributed lock of the shared resource, the method further includes:
and the coordination server sends the node information of the temporary node created for the client and the node information of other temporary nodes waiting for acquiring the distributed lock of the shared resource to the client.
An embodiment of the present application provides a node change notification apparatus, including:
the system comprises a first sending module, a second sending module and a third sending module, wherein the first sending module is used for sending a temporary node creating request to a coordination server when a client needs to access a shared resource, and the temporary node creating request is used for requesting the coordination server to create a temporary node waiting for acquiring a distributed lock of the shared resource for the client;
the judging module is used for judging whether the temporary node of the client meets the condition of acquiring the distributed lock or not according to the node information of a plurality of temporary nodes waiting to acquire the distributed lock of the shared resource at present;
a second sending module, configured to send, to the coordination server, a registration request for a node change event of a previous temporary node after determining that the temporary node of the client does not satisfy the condition for acquiring the distributed lock, where the registration request is used to request the coordination server to notify the client after the previous temporary node is deleted; the previous temporary node is the last temporary node capable of acquiring the distributed lock before the temporary node of the client in the plurality of temporary nodes waiting for acquiring the distributed lock of the shared resource.
Another embodiment of the present application provides a node change notification apparatus, including:
the first receiving module is used for receiving a temporary node creation request sent by a client when a shared resource is required to be requested;
a creating module, configured to create, for the client, a temporary node waiting for acquisition of the distributed lock of the shared resource;
a second receiving module, configured to receive a registration request of a node change event for a previous temporary node, where the registration request is used to request a coordination server to notify the client after the previous temporary node is deleted; the previous temporary node is the last temporary node which can obtain the distributed lock before the temporary node of the client in a plurality of temporary nodes waiting for obtaining the distributed lock of the shared resource;
a sending module, configured to send a node change event to the client after determining that the previous temporary node is deleted, so as to indicate that the previous temporary node of the client has been deleted.
In the embodiment of the application, when a client in a distributed system needs to access shared resources, a temporary node creation request is sent to a coordination server; judging whether the temporary node of the client meets the condition of acquiring the distributed lock or not according to node information of a plurality of temporary nodes currently waiting for acquiring the distributed lock of the shared resource; and if not, sending a registration request aiming at the node change event of the previous temporary node to the coordination server, and requesting the coordination server to notify the client after the previous temporary node is deleted. By adopting the embodiment of the application, the client receives the node change event only after the previous temporary node is deleted, and the client can not be influenced to acquire the distributed lock in time, so that a plurality of unnecessary node change events can be avoided, the system overhead can be saved, and the system performance can be provided.
Drawings
Fig. 1 is a flowchart of a node change notification method according to a first embodiment of the present application;
fig. 2 is a flowchart of a node change notification method according to a second embodiment of the present application;
fig. 3 is a schematic structural diagram of a node change notification apparatus according to a third embodiment of the present application;
fig. 4 is a schematic structural diagram of a node change notification apparatus according to a fourth embodiment of the present application.
Detailed Description
In the embodiment of the application, when a client in a distributed system needs to access shared resources, a temporary node creation request is sent to a coordination server; judging whether the temporary node of the client meets the condition of acquiring the distributed lock or not according to node information of a plurality of temporary nodes currently waiting for acquiring the distributed lock of the shared resource; and if not, sending a registration request aiming at the node change event of the previous temporary node to the coordination server, and requesting the coordination server to notify the client after the previous temporary node is deleted. By adopting the embodiment of the application, the client receives the node change event only after the previous temporary node is deleted, and the client can not be influenced to acquire the distributed lock in time, so that a plurality of unnecessary node change events can be avoided, the system overhead can be saved, and the system performance can be provided.
The embodiments of the present application will be described in further detail with reference to the drawings attached hereto.
Example one
As shown in fig. 1, a flowchart of a node change notification method provided in an embodiment of the present application includes the following steps:
s101: when a client in the distributed system needs to access the shared resource, a temporary node creation request is sent to a coordination server, and the temporary node creation request is used for requesting the coordination server to create a temporary node waiting for acquiring the distributed lock of the shared resource for the client.
In this step, when a client needs to access a shared resource, a temporary node creation request is first sent to a coordinating server, such as a ZooKeeper server, where the temporary node creation request may include information of the shared resource that needs to be requested, so that the ZooKeeper server creates a temporary node under a corresponding shared resource name for the temporary node. The temporary node is used for sequencing and waiting for acquiring the distributed lock, so that the corresponding client side has the right to access the shared resource.
S102: the client judges whether the temporary node of the client meets the condition of acquiring the distributed lock or not according to the node information of a plurality of temporary nodes waiting to acquire the distributed lock of the shared resource at present, if so, the step S103 is entered, and if not, the step S104 is entered.
In specific implementation, the client first obtains node information of all temporary nodes waiting for obtaining the distributed lock of the shared resource, where the node information may include a node sequence number or a node value count, and determines whether the temporary nodes of the client can currently obtain the distributed lock according to the node information of the temporary nodes. In a specific implementation, the coordination server may sequentially allocate node serial numbers to each temporary node created successively according to a sequence from a small node serial number to a large node serial number, in this case, according to a principle that the node serial numbers are created first and acquired first, the client may determine whether the temporary node is a node with the smallest node serial number, and if so, determine that the distributed lock of the shared resource to be accessed may be acquired. That is, when the temporary node of the client is the node with the smallest node sequence number among the plurality of temporary nodes currently waiting for acquiring the distributed lock of the shared resource, it is considered that the condition for acquiring the distributed lock is satisfied. Correspondingly, if the coordination server allocates node serial numbers to the temporary nodes created successively according to the descending order of the node serial numbers, in this case, the client needs to judge whether the temporary node is the node with the largest node serial number, and if so, the client confirms that the distributed lock of the shared resource needing to be accessed can be acquired.
S103: and the client accesses the shared resource by using the acquired distributed lock, and requests the coordination server to delete the temporary node of the client after the access is finished.
Here, after confirming that the temporary node of the client is the node with the smallest node sequence number among all temporary nodes waiting for acquiring the distributed lock of the shared resource, the client accesses the shared resource by using the acquired distributed lock, and releases the distributed lock after the access is completed, that is, indicates to the coordination server to delete the temporary node of the client.
S104: the method comprises the steps that a client sends a registration request aiming at a node change event of a previous temporary node to a coordination server, and the registration request is used for requesting the coordination server to inform the client after the previous temporary node is deleted; the previous temporary node is the last temporary node capable of acquiring the distributed lock before the temporary node of the client in the plurality of temporary nodes waiting for acquiring the distributed lock of the shared resource.
Here, the client registers the node change event of the previous temporary node with the ZooKeeper server, receives the notification only when the previous temporary node is deleted, and then returns to S103 to execute the determining step, because the client has a chance to acquire the distributed lock only after the previous temporary node is deleted. Therefore, a plurality of unnecessary node change events can be avoided, and the system overhead can be saved. The previous temporary node is a last temporary node capable of acquiring the distributed lock before the temporary node of the client, for example, if the coordination server sequentially allocates node serial numbers to the created temporary nodes in a descending order of the node serial numbers, the previous temporary node is a node whose node serial number is 1 less than the node serial number of the temporary node of the client; for another example, if the coordination server sequentially assigns node numbers to the created temporary nodes in the descending order of the node numbers, the previous temporary node is a node whose node number is 1 greater than the node number of the temporary node of the client.
The idea of an embodiment of the present application is further illustrated by a specific embodiment.
Example two
As shown in fig. 2, a flowchart of a node change notification method provided in the second embodiment of the present application includes the following steps:
s201: when a client in the distributed system needs to access the shared resource, a temporary node creation request is sent to a coordination server, and the temporary node creation request is used for requesting the coordination server to create a temporary node waiting for acquiring the distributed lock of the shared resource for the client.
S202: the coordination server creates a temporary node for the client waiting for acquisition of the distributed lock for the shared resource.
Here, after creating the temporary node for the client, the coordination server may add node information of the temporary node under a lock directory (/ lock) of the corresponding shared resource.
S203: the client judges whether the temporary node of the client is the node with the minimum node sequence number in all the temporary nodes waiting for acquiring the distributed lock of the shared resource, if so, the S204 is entered, and if not, the S205 is entered.
Here, after sending the temporary node creation request to the coordination server, the client may actively access node information of a plurality of temporary nodes stored by the coordination server under the lock directory corresponding to the shared resource based on a predicted access path; that is, the client acquires node information of a plurality of temporary nodes under the lock directory corresponding to the shared resource; based on the acquired node information of the plurality of temporary nodes in the lock directory, determining whether the temporary node of the client satisfies the condition for acquiring the distributed lock, that is, in this embodiment, determining whether the temporary node of the client is the node with the smallest node sequence number among the plurality of temporary nodes; if so, determining that the temporary node of the client can acquire the distributed lock, otherwise, determining that the temporary node of the client cannot acquire the distributed lock.
Or after the client sends the temporary node creation request to the coordination server, the coordination server can directly send the temporary node created for the client and the node information of other temporary nodes under the name of the shared resource requested to be accessed by the client to the client together after the temporary node is created for the client. That is, after sending a temporary node creation request, the client receives node information of a temporary node created for the client and node information of other temporary nodes waiting for acquiring the distributed lock of the shared resource, which are sent by the coordination server; judging whether the temporary node of the client meets the condition of acquiring the distributed lock or not based on the node information of the temporary node of the client, which is sent by the coordination server, and the node information of other temporary nodes waiting for acquiring the distributed lock of the shared resource, wherein the judgment is also carried out to judge whether the temporary node of the client is the node with the minimum node sequence number in a plurality of temporary nodes waiting for acquiring the distributed lock of the shared resource; if so, determining that the temporary node of the client can acquire the distributed lock, otherwise, determining that the temporary node of the client cannot acquire the distributed lock.
S204: and the client accesses the shared resource by using the acquired distributed lock, and requests the coordination server to delete the temporary node of the client after the access is finished.
Here, after completing the resource access, the client may send a command to delete the temporary node to the ZooKeeper server to release the acquired distributed lock for use by other clients.
S205: and the client sends a registration request aiming at the node change event of the previous temporary node to the coordination server, and is used for requesting the coordination server to inform the client after the previous temporary node is deleted, wherein the previous temporary node is a node of which the node sequence number is 1 less than the node sequence number of the temporary node of the client in all temporary nodes waiting for acquiring the distributed lock of the shared resource.
In this step, when the temporary node of the client is not the temporary node with the minimum current node sequence number, the client waits, and registers a node change event of the previous temporary node to a coordinator server (ZooKeeper server), that is, instructs the ZooKeeper server to notify the client after the previous temporary node is deleted.
For example, the node number of the temporary node of the client is n, and the client registers the node change event of the temporary node with the node number n-1 with the ZooKeeper server, at this time, the client only receives the change event of the node n-1 regardless of whether other temporary nodes are changed.
S206: and after determining that the previous temporary node is deleted, the coordination server sends a node change event to the client to indicate that the previous temporary node of the client is deleted.
The node change event may include an event that the previous temporary node releases the distributed lock (i.e., deletes the previous temporary node) after completing the resource access, or may include an event that the previous temporary node is deleted after being disconnected from the coordination server.
S207: after receiving the node change event, the client returns to S203.
Based on the same inventive concept, the embodiment of the present application further provides a node change notification device corresponding to the node change notification method, and because the principle of solving the problem of the device is similar to that of the node change notification method in the embodiment of the present application, the implementation of the device may refer to the implementation of the method, and repeated details are not repeated.
EXAMPLE III
As shown in fig. 3, a schematic structural diagram of a node change notification apparatus according to a third embodiment of the present application includes:
a first sending module 31, configured to send a temporary node creation request to a coordination server when a client needs to access a shared resource, and to request the coordination server to create a temporary node for the client that waits for acquiring a distributed lock of the shared resource;
a determining module 32, configured to determine whether the temporary node of the client meets a condition for acquiring the distributed lock according to node information of multiple temporary nodes currently waiting to acquire the distributed lock of the shared resource;
a second sending module 33, configured to send, to the coordination server, a registration request for a node change event of a previous temporary node after determining that the temporary node of the client does not satisfy the condition for acquiring the distributed lock, where the registration request is used to request the coordination server to notify the client after the previous temporary node is deleted; the previous temporary node is the last temporary node capable of acquiring the distributed lock before the temporary node of the client in the plurality of temporary nodes waiting for acquiring the distributed lock of the shared resource.
Optionally, the meeting the condition of acquiring the distributed lock specifically includes:
and the node sequence number in the plurality of temporary nodes currently waiting for acquiring the distributed lock of the shared resource is the minimum.
Optionally, the apparatus further comprises:
an accessing module 34, configured to, after the determining module 32 determines that the temporary node of the client satisfies the condition of acquiring the distributed lock, access the shared resource using the acquired distributed lock, and after the access is completed, request the coordination server to delete the temporary node of the client.
Optionally, the determining module 32 is specifically configured to:
acquiring node information of a plurality of temporary nodes under a lock directory corresponding to the shared resource; and judging whether the temporary node of the client meets the condition of acquiring the distributed lock or not based on the acquired node information of the temporary nodes in the lock directory.
Optionally, the determining module 32 is specifically configured to:
receiving node information of temporary nodes created for the client and node information of other temporary nodes waiting for acquiring the distributed lock of the shared resource, which are sent by the coordination server; and judging whether the temporary node of the client meets the condition of acquiring the distributed lock or not based on the node information of the temporary node of the client, which is sent by the coordination server, and the node information of other temporary nodes waiting for acquiring the distributed lock of the shared resource.
Optionally, the determining module 32 is further configured to, after the second sending module 33 sends the registration request for the node change event of the previous temporary node to the coordination server, if the node change event is received, return to the step of determining whether the temporary node of the client can currently acquire the distributed lock.
Example four
As shown in fig. 4, a schematic structural diagram of a node change notification apparatus according to a fourth embodiment of the present application includes:
a first receiving module 41, configured to receive a temporary node creation request sent by a client when the client needs to request a shared resource;
a creating module 42, configured to create, for the client, a temporary node waiting for acquiring the distributed lock of the shared resource;
a second receiving module 43, configured to receive a registration request of a node change event for a previous temporary node, where the registration request is used to request the coordination server to notify the client after the previous temporary node is deleted; the previous temporary node is the last temporary node which can obtain the distributed lock before the temporary node of the client in a plurality of temporary nodes waiting for obtaining the distributed lock of the shared resource;
a sending module 44, configured to send a node change event to the client after determining that the previous temporary node is deleted, so as to indicate that the previous temporary node of the client has been deleted.
Optionally, the sending module 44 is further configured to:
and adding the node information of the temporary node created for the client by the creating module 42 into a lock directory corresponding to the shared resource.
Optionally, the sending module 44 is further configured to:
and sending the node information of the temporary node created for the client by the creating module 42 and the node information of other temporary nodes waiting for acquiring the distributed lock of the shared resource to the client.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While the preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all alterations and modifications as fall within the scope of the application.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.

Claims (18)

1. A method for notifying a change of a node, the method comprising:
when a client in the distributed system needs to access shared resources, sending a temporary node creation request to a coordination server, wherein the temporary node creation request is used for requesting the coordination server to create a temporary node waiting for acquiring a distributed lock of the shared resources for the client;
the client judges whether the temporary node of the client meets the condition of acquiring the distributed lock or not according to the node information of a plurality of temporary nodes waiting to acquire the distributed lock of the shared resource at present;
if not, sending a registration request aiming at the node change event of the previous temporary node to the coordination server, and requesting the coordination server to notify the client after the previous temporary node is deleted; the previous temporary node is the last temporary node which acquires the distributed lock before the temporary node of the client in the plurality of temporary nodes waiting for acquiring the distributed lock of the shared resource.
2. The method according to claim 1, wherein the satisfying the condition for acquiring the distributed lock specifically comprises:
and the node sequence number in the plurality of temporary nodes currently waiting for acquiring the distributed lock of the shared resource is the minimum.
3. The method of claim 1, wherein the client, after determining that the temporary node of the client satisfies the condition for acquiring the distributed lock, comprises:
and the client accesses the shared resource by using the acquired distributed lock, and requests the coordination server to delete the temporary node of the client after the access is finished.
4. The method according to any one of claims 1 to 3, wherein the determining, by the client, whether the temporary node of the client satisfies the condition for acquiring the distributed lock according to node information of a plurality of temporary nodes currently waiting to acquire the distributed lock of the shared resource, includes:
the client acquires node information of a plurality of temporary nodes under a lock directory corresponding to the shared resource;
and the client judges whether the temporary node of the client meets the condition of acquiring the distributed lock or not based on the acquired node information of the temporary nodes in the lock directory.
5. The method according to any one of claims 1 to 3, wherein the determining, by the client, whether the temporary node of the client satisfies the condition for acquiring the distributed lock according to node information of a plurality of temporary nodes currently waiting to acquire the distributed lock of the shared resource, includes:
the client receives node information of a temporary node which is sent by the coordination server and created for the client, and node information of other temporary nodes waiting for acquiring the distributed lock of the shared resource;
and the client judges whether the temporary node of the client meets the condition of acquiring the distributed lock or not based on the node information of the temporary node of the client, which is sent by the coordination server, and the node information of other temporary nodes waiting for acquiring the distributed lock of the shared resource.
6. The method according to any one of claims 1 to 3, wherein after the client sends a registration request for a node change event of a previous temporary node to the coordination server, the method further comprises:
and after receiving the node change event, the client returns to the step of judging whether the temporary node of the client can acquire the distributed lock currently.
7. A method for notifying a change of a node, the method comprising:
a coordination server in a distributed system receives a temporary node creation request sent by a client when the client needs to request a shared resource;
the coordination server creates a temporary node for the client to wait for acquiring the distributed lock of the shared resource;
the coordination server receives a registration request of a node change event aiming at a previous temporary node, which is sent by the client, wherein the registration request is used for requesting the coordination server to inform the client after the previous temporary node is deleted; the previous temporary node is the last temporary node which can obtain the distributed lock before the temporary node of the client in a plurality of temporary nodes waiting for obtaining the distributed lock of the shared resource;
and after determining that the previous temporary node is deleted, the coordination server sends a node change event to the client to indicate that the previous temporary node of the client is deleted.
8. The method of claim 7, wherein after the coordinating server creates a temporary node for the client that waits to acquire the distributed lock for the shared resource, further comprising:
and the coordination server adds the node information of the temporary node created for the client to a lock directory corresponding to the shared resource.
9. The method of claim 7, wherein after the coordinating server creates a temporary node for the client that waits to acquire the distributed lock for the shared resource, further comprising:
and the coordination server sends the node information of the temporary node created for the client and the node information of other temporary nodes waiting for acquiring the distributed lock of the shared resource to the client.
10. A node change notification apparatus, comprising:
the system comprises a first sending module, a second sending module and a third sending module, wherein the first sending module is used for sending a temporary node creating request to a coordination server when a client needs to access a shared resource, and the temporary node creating request is used for requesting the coordination server to create a temporary node waiting for acquiring a distributed lock of the shared resource for the client;
the judging module is used for judging whether the temporary node of the client meets the condition of acquiring the distributed lock or not according to the node information of a plurality of temporary nodes waiting to acquire the distributed lock of the shared resource at present;
a second sending module, configured to send, to the coordination server, a registration request for a node change event of a previous temporary node after determining that the temporary node of the client does not satisfy the condition for acquiring the distributed lock, where the registration request is used to request the coordination server to notify the client after the previous temporary node is deleted; the previous temporary node is the last temporary node capable of acquiring the distributed lock before the temporary node of the client in the plurality of temporary nodes waiting for acquiring the distributed lock of the shared resource.
11. The apparatus as claimed in claim 10, wherein said satisfying the condition for acquiring the distributed lock specifically comprises:
and the node sequence number in the plurality of temporary nodes currently waiting for acquiring the distributed lock of the shared resource is the minimum.
12. The apparatus of claim 10, wherein the apparatus further comprises:
and the access module is used for accessing the shared resource by using the acquired distributed lock after the judgment module determines that the temporary node of the client meets the condition of acquiring the distributed lock, and requesting the coordination server to delete the temporary node of the client after the access is finished.
13. The apparatus according to any one of claims 10 to 12, wherein the determining module is specifically configured to:
acquiring node information of a plurality of temporary nodes under a lock directory corresponding to the shared resource; and judging whether the temporary node of the client meets the condition of acquiring the distributed lock or not based on the acquired node information of the temporary nodes in the lock directory.
14. The apparatus according to any one of claims 10 to 12, wherein the determining module is specifically configured to:
receiving node information of temporary nodes created for the client and node information of other temporary nodes waiting for acquiring the distributed lock of the shared resource, which are sent by the coordination server; and judging whether the temporary node of the client meets the condition of acquiring the distributed lock or not based on the node information of the temporary node of the client, which is sent by the coordination server, and the node information of other temporary nodes waiting for acquiring the distributed lock of the shared resource.
15. The apparatus according to any one of claims 10 to 12, wherein the determining module is further configured to, after the second sending module sends the registration request for the node change event of the previous temporary node to the coordination server, return to the step of determining whether the temporary node of the client can currently acquire the distributed lock if the node change event is received.
16. A node change notification apparatus, comprising:
the first receiving module is used for receiving a temporary node creation request sent by a client when a shared resource is required to be requested;
a creating module, configured to create, for the client, a temporary node waiting for acquisition of the distributed lock of the shared resource;
a second receiving module, configured to receive a registration request of a node change event for a previous temporary node, where the registration request is used to request a coordination server to notify the client after the previous temporary node is deleted; the previous temporary node is the last temporary node which can obtain the distributed lock before the temporary node of the client in a plurality of temporary nodes waiting for obtaining the distributed lock of the shared resource;
a sending module, configured to send a node change event to the client after determining that the previous temporary node is deleted, so as to indicate that the previous temporary node of the client has been deleted.
17. The apparatus of claim 16, wherein the sending module is further configured to:
and adding the node information of the temporary node created by the creating module for the client under the lock directory corresponding to the shared resource.
18. The apparatus of claim 16, wherein the sending module is further configured to:
and sending the node information of the temporary node created for the client by the creating module and the node information of other temporary nodes waiting for acquiring the distributed lock of the shared resource to the client.
CN201510438825.6A 2015-07-23 2015-07-23 Node change notification method and device Active CN106712981B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510438825.6A CN106712981B (en) 2015-07-23 2015-07-23 Node change notification method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510438825.6A CN106712981B (en) 2015-07-23 2015-07-23 Node change notification method and device

Publications (2)

Publication Number Publication Date
CN106712981A CN106712981A (en) 2017-05-24
CN106712981B true CN106712981B (en) 2020-03-06

Family

ID=58894635

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510438825.6A Active CN106712981B (en) 2015-07-23 2015-07-23 Node change notification method and device

Country Status (1)

Country Link
CN (1) CN106712981B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107832159A (en) * 2017-11-10 2018-03-23 郑州云海信息技术有限公司 Manage the method and computer-readable recording medium of distributed lock
CN108038005A (en) * 2017-12-28 2018-05-15 广东蜂助手网络技术股份有限公司 Shared resource access method, client, server-side, system based on zookeeper
CN110661637A (en) 2018-06-30 2020-01-07 华为技术有限公司 Distributed system member changing method and distributed system
CN109753540A (en) * 2018-12-03 2019-05-14 新华三云计算技术有限公司 Shared resource access method, device and computer-readable storage medium
CN110166528B (en) * 2019-04-16 2022-03-18 平安科技(深圳)有限公司 Method and device for preventing node change notification from being lost and computer equipment
CN110266779A (en) * 2019-06-10 2019-09-20 南威软件股份有限公司 A kind of principal and subordinate local timed task processing method and system based on zookeeper
CN110677453A (en) * 2019-08-15 2020-01-10 平安普惠企业管理有限公司 ZooKeeper-based distributed lock service implementation method, device, equipment and storage medium
CN112099962B (en) * 2020-11-06 2021-02-19 成都新希望金融信息有限公司 Distributed lock implementation method and device and electronic equipment
CN112486695A (en) * 2020-12-07 2021-03-12 浪潮云信息技术股份公司 Distributed lock implementation method under high concurrency service
CN114661742A (en) * 2022-03-28 2022-06-24 浪潮卓数大数据产业发展有限公司 Zookeeper-based distributed lock acquisition method and system

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1945539A (en) * 2006-10-19 2007-04-11 华为技术有限公司 Method for distributing shared resource lock in computer cluster system and cluster system
CN103744724A (en) * 2014-02-19 2014-04-23 互联网域名系统北京市工程研究中心有限公司 Timed task clustering method and device thereof
CN104702655A (en) * 2014-03-21 2015-06-10 杭州海康威视系统技术有限公司 Cloud storage resource distribution method and system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1945539A (en) * 2006-10-19 2007-04-11 华为技术有限公司 Method for distributing shared resource lock in computer cluster system and cluster system
CN103744724A (en) * 2014-02-19 2014-04-23 互联网域名系统北京市工程研究中心有限公司 Timed task clustering method and device thereof
CN104702655A (en) * 2014-03-21 2015-06-10 杭州海康威视系统技术有限公司 Cloud storage resource distribution method and system

Also Published As

Publication number Publication date
CN106712981A (en) 2017-05-24

Similar Documents

Publication Publication Date Title
CN106712981B (en) Node change notification method and device
CN109213600B (en) GPU resource scheduling method and device based on AI cloud
CN108897628B (en) Method and device for realizing distributed lock and electronic equipment
CN107241281B (en) Data processing method and device
US20140195769A1 (en) Management of storage in a storage network
RU2749339C1 (en) Equipment control method, cluster system, electronic device and readable data media
CN110083651B (en) Data loading method and device
US9852050B2 (en) Selecting computing resources
CN105824810A (en) Hadoop cluster system and data processing method
CN105592110B (en) Resource scheduling method and device
CN109254913B (en) Device sharing method and device, electronic device and computer storage medium
CN107659450B (en) Method and device for allocating big data cluster resources and storage medium
CN105357045A (en) Cloud platform service establishment method and cloud platform service establishment device
CN111258726B (en) Task scheduling method and device
CN106598746B (en) Method and device for realizing global lock in distributed system
CN105791254A (en) Network request processing method, device and terminal
CN104537045A (en) Service distribution method and device based on distributive system
CN108111337B (en) Method and equipment for arbitrating main nodes in distributed system
CN113553178A (en) Task processing method and device and electronic equipment
CN111163140A (en) Method, apparatus and computer readable storage medium for resource acquisition and allocation
US11252121B2 (en) Message sending method and terminal device
CN113282580A (en) Method, storage medium and server for executing timed task
CN107045452B (en) Virtual machine scheduling method and device
CN102932389A (en) Request processing method and device, and server system
CN110609707B (en) Online data processing system generation method, device and equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20200922

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20200922

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee after: Advanced innovation technology Co.,Ltd.

Address before: Cayman Islands Grand Cayman capital building, a four storey No. 847 mailbox

Patentee before: Alibaba Group Holding Ltd.

TR01 Transfer of patent right