public DummyMaster(ZooKeeperWatcher zk, ServerName master) { this.clusterStatusTracker = new ClusterStatusTracker(zk, this); clusterStatusTracker.start(); this.activeMasterManager = new ActiveMasterManager(zk, master, this); zk.registerListener(activeMasterManager); }
/** * @return False if cluster shutdown in progress */ private boolean isClusterUp() { return this.clusterStatusTracker.isClusterUp(); }
/** * Sets the cluster as up. * * @throws org.apache.zookeeper.KeeperException * unexpected zk exception */ public void setClusterUp() throws KeeperException { byte[] upData = toByteArray(); try { ZKUtil.createAndWatch(watcher, watcher.clusterStateZNode, upData); } catch (KeeperException.NodeExistsException nee) { ZKUtil.setData(watcher, watcher.clusterStateZNode, upData); } }
boolean wasUp = this.clusterStatusTracker.isClusterUp(); if (!wasUp) this.clusterStatusTracker.setClusterUp();
clusterStatusTracker.setClusterUp(); activeMasterManager.blockUntilBecomingActiveMaster( Mockito.mock(MonitoredTask.class), clusterStatusTracker);
public void shutdown() throws IOException { if (mxBean != null) { MBeans.unregister(mxBean); mxBean = null; } if (this.assignmentManager != null) this.assignmentManager.shutdown(); if (this.serverManager != null) this.serverManager.shutdownCluster(); try { if (this.clusterStatusTracker != null) { this.clusterStatusTracker.setClusterDown(); } } catch (KeeperException e) { LOG.error("ZooKeeper exception trying to set cluster as down in ZK", e); } }
clusterStatusTracker.setClusterUp();
/** * 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 { 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); }
if (!clusterStatusTracker.isClusterUp()) { this.master .stop("Cluster went down before this master became active");
this.clusterStatusTracker = new ClusterStatusTracker(this.zooKeeper, this); this.clusterStatusTracker.start(); blockAndCheckIfStopped(this.clusterStatusTracker);