@InterfaceAudience.Private public class ActiveMasterManager extends ZKListener
Listens and responds to ZooKeeper notifications on the master znodes, 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) ServerName |
activeMasterServerName |
private org.apache.hbase.thirdparty.com.google.common.collect.ImmutableList<ServerName> |
backupMasters |
(package private) AtomicBoolean |
clusterHasActiveMaster |
(package private) AtomicBoolean |
clusterShutDown |
(package private) int |
infoPort |
private static org.slf4j.Logger |
LOG |
(package private) Server |
master |
(package private) ServerName |
sn |
watcher
Constructor and Description |
---|
ActiveMasterManager(ZKWatcher 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.
|
private void |
fetchAndSetActiveMasterServerName()
Fetches the active master's ServerName from zookeeper.
|
int |
getActiveMasterInfoPort() |
Optional<ServerName> |
getActiveMasterServerName() |
int |
getBackupMasterInfoPort(ServerName sn) |
List<ServerName> |
getBackupMasters()
Returns list of registered backup masters.
|
(package private) void |
handle(String path) |
private void |
handleMasterNodeChange()
Handle a change in the master node.
|
(package private) boolean |
hasActiveMaster()
Returns True if cluster has an active master.
|
void |
nodeChildrenChanged(String path)
Called when an existing node has a child node added or removed.
|
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() |
private void |
updateBackupMasters() |
getWatcher, nodeDataChanged
private static final org.slf4j.Logger LOG
final AtomicBoolean clusterHasActiveMaster
final AtomicBoolean clusterShutDown
int infoPort
final ServerName sn
volatile ServerName activeMasterServerName
private volatile org.apache.hbase.thirdparty.com.google.common.collect.ImmutableList<ServerName> backupMasters
ActiveMasterManager(ZKWatcher watcher, ServerName sn, Server master) throws InterruptedIOException
watcher
- ZK watchersn
- ServerNamemaster
- In an instance of a Master.InterruptedIOException
public void setInfoPort(int infoPort)
public void nodeCreated(String path)
ZKListener
nodeCreated
in class ZKListener
path
- full path of the new nodepublic void nodeChildrenChanged(String path)
ZKListener
nodeChildrenChanged
in class ZKListener
path
- full path of the node whose children have changedpublic void nodeDeleted(String path)
ZKListener
nodeDeleted
in class ZKListener
path
- full path of the deleted nodeprivate void updateBackupMasters() throws InterruptedIOException
InterruptedIOException
private void fetchAndSetActiveMasterServerName()
public Optional<ServerName> getActiveMasterServerName()
public int getActiveMasterInfoPort()
public int getBackupMasterInfoPort(ServerName sn)
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()
public List<ServerName> getBackupMasters()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.