this.activeMasterManager = new ActiveMasterManager(zooKeeper, this.serverName, this); } else { this.activeMasterManager = null;
LOG.warn("Failed create of " + backupZNode + " by " + serverName); this.activeMasterManager.setInfoPort(infoPort); int timeout = conf.getInt(HConstants.ZK_SESSION_TIMEOUT, HConstants.DEFAULT_ZK_SESSION_TIMEOUT); while (!activeMasterManager.hasActiveMaster()) { LOG.debug("Waiting for master address and cluster state znode to be written."); Threads.sleep(timeout); status.setDescription("Master startup"); try { if (activeMasterManager.blockUntilBecomingActiveMaster(timeout, status)) { finishActiveMasterInitialization(status);
void handle(final String path) { if (path.equals(watcher.getZNodePaths().masterAddressZNode) && !master.isStopped()) { handleMasterNodeChange(); } }
@Override public void run() { manager.blockUntilBecomingActiveMaster(100, Mockito.mock(MonitoredTask.class)); LOG.info("Second master has become the active master!"); isActiveMaster = true; } }
/** * Try becoming active master. * @param startupStatus * @return True if we could successfully become the active master. * @throws InterruptedException */ private boolean becomeActiveMaster(MonitoredTask startupStatus) throws InterruptedException { // TODO: This is wrong!!!! Should have new servername if we restart ourselves, // if we come back to life. this.activeMasterManager = new ActiveMasterManager(zooKeeper, this.serverName, this); this.zooKeeper.registerListener(activeMasterManager); stallIfBackupMaster(this.conf, this.activeMasterManager); // The ClusterStatusTracker is setup before the other // ZKBasedSystemTrackers because it's needed by the activeMasterManager // to check if the cluster should be shutdown. this.clusterStatusTracker = new ClusterStatusTracker(getZooKeeper(), this); this.clusterStatusTracker.start(); return this.activeMasterManager.blockUntilBecomingActiveMaster(startupStatus, this.clusterStatusTracker); }
while (!activeMasterManager.hasActiveMaster()) { LOG.debug("Waiting for master address ZNode to be written " + "(Also watching cluster state node)"); status.setDescription("Master startup"); try { if (activeMasterManager.blockUntilBecomingActiveMaster(timeout, status)) { finishActiveMasterInitialization(status);
@Override public void stop(String msg) { if (!isStopped()) { super.stop(msg); if (this.activeMasterManager != null) { this.activeMasterManager.stop(); } } }
@Override public void nodeCreated(String path) { handle(path); }
activeMasterManager.setInfoPort(infoPort);
clusterStatusTracker.setClusterUp(); activeMasterManager.blockUntilBecomingActiveMaster(100, status); assertTrue(activeMasterManager.clusterHasActiveMaster.get()); assertMaster(zk, master); secondDummyMaster.getActiveMasterManager(); assertFalse(secondActiveMasterManager.clusterHasActiveMaster.get()); activeMasterManager.blockUntilBecomingActiveMaster(100, status); assertTrue(activeMasterManager.clusterHasActiveMaster.get()); assertMaster(zk, master);
this.activeMasterManager.stop();
@Override public void nodeDeleted(String path) { // We need to keep track of the cluster's shutdown status while // we wait on the current master. We consider that, if the cluster // was already in a "shutdown" state when we started, that this master // is part of a new cluster that was started shortly after the old cluster // shut down, so that state is now irrelevant. This means that the shutdown // state must be set while we wait on the active master in order // to shutdown this master. See HBASE-8519. if(path.equals(watcher.getZNodePaths().clusterStateZNode) && !master.isStopped()) { clusterShutDown.set(true); } handle(path); }
ms1.getClusterStatusTracker(); clusterStatusTracker.setClusterUp(); activeMasterManager.blockUntilBecomingActiveMaster(100, Mockito.mock(MonitoredTask.class)); assertTrue(activeMasterManager.clusterHasActiveMaster.get());
public DummyMaster(ZKWatcher zk, ServerName master) { this.clusterStatusTracker = new ClusterStatusTracker(zk, this); clusterStatusTracker.start(); this.activeMasterManager = new ActiveMasterManager(zk, master, this); zk.registerListener(activeMasterManager); }
@Override public void nodeDeleted(String path) { if(path.equals(watcher.masterAddressZNode) && !master.isStopped()) { handleMasterNodeChange(); } }
if (this.activeMasterManager != null) this.activeMasterManager.stop(); if (this.catalogTracker != null) this.catalogTracker.stop(); if (this.serverManager != null) this.serverManager.stop();
@Override public void nodeCreated(String path) { handle(path); }
@Override public void run() { manager.blockUntilBecomingActiveMaster(100, Mockito.mock(MonitoredTask.class)); LOG.info("Second master has become the active master!"); isActiveMaster = true; } }
activeMasterManager = new ActiveMasterManager(zooKeeper, this.serverName, this); int infoPort = putUpJettyServer(); startActiveMasterManager(infoPort);
@Override public void nodeCreated(String path) { if(path.equals(watcher.masterAddressZNode) && !master.isStopped()) { handleMasterNodeChange(); } }