Lead your team forward
OCT 24 / 9AM ET Register nowMDM-Zookeeper Interaction
This topic provides detailed information on how MDM interacts with Zookeeper.
In this article, active mode/node = RW mode/node, passive mode/node = RO mode/node. |
The MDM Znode Structure on Zookeeper
Below is the description of znodes that mdm creates on the Zookeeper filesystem.
These are created in the location specified in the High Availability Component with the zookeeperPath
property.
/forceNewLeader
-
Contains the name of the node that has been manually set to be the leader and switch to the active mode.
-
All nodes are watching /forceNewLeader for changes.
-
Whenever there is a change, all nodes other than the manually selected (proposed) leader, reconnect to Zookeeper. As the result, the current active node loses leadership and starts switching to the passive mode.
/election
-
Used to select who will be the leader (uses the Curator implementation of Zookeeper’s "Leader Election" recipe).
-
After connecting to Zookeeper, all nodes writes their information here to participate in leader election.
-
All nodes are notified when something changes (any node connects or disconnects).
-
Any node can get a list of other nodes and the name of the current leader node.
/currentActive
-
Contains the name of the node in the active mode.
-
Whenever a new leader is elected, it starts watching /currentActive (it will contain previous leader’s name or nothing).
-
When the former leader finishes switching to the passive mode, it deletes its name from this node.
-
The new leader is notified about the deletion and starts switching to the active mode, after which it writes its name here.
Overview of Scenarios
A New MDM Node Connects to Zookeeper
Here is what happens when a new MDM node connects to Zookeeper.
-
MDM connects to Zookeeper in the RO mode.
-
MDM registers itself in
/election
. -
If it becomes a leader, it checks if there is another RW instance registered in the
/currentActive
znode.-
If there is, it waits at most for
maxActiveToPassiveSwitchingTime
, switches to the RW mode and registers itself to/currentActive
. -
If there is no previous RW instance registered (which usually means this is the first MDM instance registered), it will switches to the RW mode immediately.
-
A New Active MDM Node is Set Manually
Here is what happens when a user changes set a new active MDM manually (via a REST call).
Premise: only the client leader can become or is the active MDM.
-
The name of the upcoming new active node is written to
/forceNewLeader
. -
All other nodes are notified about the change in
/forceNewLeader
, after which they disconnect and reconnect to Zookeeper. This way the upcoming new active MDM node will be elected leader (first connected) -
Switching:
-
The active node starts switching from the active to passive mode.
-
The one who has been set as the new leader, waits until the old leader switches to passive at most
maxActivetoPassiveSwitchingTime
, after which step 6 happens.
-
-
When the upcoming new active MDM has been set leader, it starts listening to
/currentActive
, which is how it will find about what happens in the next step. -
After switching to the passive node, the old active MDM deletes itself from
/currentActive
. -
The new leader is notified about the change in
/currentActive
and starts switching to the Active mode.
Current Active MDM Node is Disconnected
Here is what happens when the active MDM loses connection with Zookeeper.
-
Zookeeper selects a new leader (the MDM node that has been connected to Zookeeper the longer).
-
The MDM node that has been set as the new leader waits until the old leader switches to the passive mode at most
maxActivetoPassiveSwitchingTime
. -
The old active MDM will switch to the passive mode at most after
revokeLeadershiponDisconnectTimeout
. If MDM is performing a write operation, which cannot be finished during the timeout, the operation is canceled, and the new active MDM will restart it.
Was this page useful?