@InterfaceAudience.Private public class ActiveMasterManager extends ZooKeeperListener
Listens and responds to ZooKeeper notifications on the master znode,
both nodeCreated
and nodeDeleted
.
Contains blocking methods which will hold up backup masters, waiting for the active master to fail.
This class is instantiated in the HMaster constructor and the method #blockUntilBecomingActiveMaster() is called to wait until becoming the active master of the cluster.
Modifier and Type | Field and Description |
---|---|
(package private) AtomicBoolean |
clusterHasActiveMaster |
(package private) AtomicBoolean |
clusterShutDown |
private int |
infoPort |
private static org.apache.commons.logging.Log |
LOG |
private Server |
master |
private ServerName |
sn |
watcher
Constructor and Description |
---|
ActiveMasterManager(ZooKeeperWatcher watcher,
ServerName sn,
Server master) |
Modifier and Type | Method and Description |
---|---|
(package private) boolean |
blockUntilBecomingActiveMaster(int checkInterval,
MonitoredTask startupStatus)
Block until becoming the active master.
|
(package private) void |
handle(String path) |
private void |
handleMasterNodeChange()
Handle a change in the master node.
|
(package private) boolean |
hasActiveMaster() |
void |
nodeCreated(String path)
Called when a new node has been created.
|
void |
nodeDeleted(String path)
Called when a node has been deleted
|
void |
setInfoPort(int infoPort) |
void |
stop() |
getWatcher, nodeChildrenChanged, nodeDataChanged
private static final org.apache.commons.logging.Log LOG
final AtomicBoolean clusterHasActiveMaster
final AtomicBoolean clusterShutDown
private final ServerName sn
private int infoPort
private final Server master
ActiveMasterManager(ZooKeeperWatcher watcher, ServerName sn, Server master)
watcher
- sn
- ServerNamemaster
- In an instance of a Master.public void setInfoPort(int infoPort)
public void nodeCreated(String path)
ZooKeeperListener
nodeCreated
in class ZooKeeperListener
path
- full path of the new nodepublic void nodeDeleted(String path)
ZooKeeperListener
nodeDeleted
in class ZooKeeperListener
path
- full path of the deleted nodevoid handle(String path)
private void handleMasterNodeChange()
Uses the watchAndCheckExists method which watches the master address node regardless of whether it exists or not. If it does exist (there is an active master), it returns true. Otherwise it returns false.
A watcher is set which guarantees that this method will get called again if there is another change in the master node.
boolean blockUntilBecomingActiveMaster(int checkInterval, MonitoredTask startupStatus)
checkInterval
- the interval to check if the master is stoppedstartupStatus
- the monitor status to track the progressboolean hasActiveMaster()
public void stop()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.