public DummyMaster(ZKWatcher zk, ServerName master) { this.clusterStatusTracker = new ClusterStatusTracker(zk, this); clusterStatusTracker.start(); this.activeMasterManager = new ActiveMasterManager(zk, master, this); zk.registerListener(activeMasterManager); }
/** * @return True if the cluster is up. */ @Override public boolean isClusterUp() { return this.masterless || (this.clusterStatusTracker != null && this.clusterStatusTracker.isClusterUp()); }
this.clusterStatusTracker.setClusterDown(); } catch (KeeperException e) { LOG.error("ZooKeeper exception trying to set cluster as down in ZK", e);
boolean wasUp = this.clusterStatusTracker.isClusterUp(); if (!wasUp) this.clusterStatusTracker.setClusterUp();
clusterStatusTracker.setClusterUp();
/** * Sets the cluster as up. * @throws KeeperException unexpected zk exception */ public void setClusterUp() throws KeeperException { byte [] upData = toByteArray(); try { ZKUtil.createAndWatch(watcher, watcher.getZNodePaths().clusterStateZNode, upData); } catch(KeeperException.NodeExistsException nee) { ZKUtil.setData(watcher, watcher.getZNodePaths().clusterStateZNode, upData); } }
/** * Initialize all ZK based system trackers. * @throws IOException * @throws InterruptedException */ private void initializeZKBasedSystemTrackers() throws IOException, InterruptedException, KeeperException { this.catalogTracker = new CatalogTracker(this.zooKeeper, this.conf, this); this.catalogTracker.start(); this.balancer = LoadBalancerFactory.getLoadBalancer(conf); this.assignmentManager = new AssignmentManager(this, serverManager, this.catalogTracker, this.balancer, this.executorService); zooKeeper.registerListenerFirst(assignmentManager); this.regionServerTracker = new RegionServerTracker(zooKeeper, this, this.serverManager); this.regionServerTracker.start(); this.drainingServerTracker = new DrainingServerTracker(zooKeeper, this, this.serverManager); this.drainingServerTracker.start(); // Set the cluster as up. If new RSs, they'll be waiting on this before // going ahead with their startup. boolean wasUp = this.clusterStatusTracker.isClusterUp(); if (!wasUp) this.clusterStatusTracker.setClusterUp(); LOG.info("Server active/primary master; " + this.serverName + ", sessionid=0x" + Long.toHexString(this.zooKeeper.getRecoverableZooKeeper().getSessionId()) + ", cluster-up flag was=" + wasUp); // create the snapshot manager this.snapshotManager = new SnapshotManager(this); }
clusterStatusTracker.setClusterUp(); activeMasterManager.blockUntilBecomingActiveMaster(100, Mockito.mock(MonitoredTask.class));
/** * Sets the cluster as up. * @throws 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); } }
masterAddressTracker.start(); clusterStatusTracker = new ClusterStatusTracker(zooKeeper, this); clusterStatusTracker.start(); } else { masterAddressTracker = null;
boolean wasUp = this.clusterStatusTracker.isClusterUp(); if (!wasUp) this.clusterStatusTracker.setClusterUp();
/** * @return False if cluster shutdown in progress */ private boolean isClusterUp() { return clusterStatusTracker != null && clusterStatusTracker.isClusterUp(); }
clusterStatusTracker.setClusterUp();
/** * Sets the cluster as up. * @throws KeeperException unexpected zk exception */ public void setClusterUp() throws KeeperException { byte [] upData = toByteArray(); try { ZKUtil.createAndWatch(watcher, watcher.getZNodePaths().clusterStateZNode, upData); } catch(KeeperException.NodeExistsException nee) { ZKUtil.setData(watcher, watcher.getZNodePaths().clusterStateZNode, upData); } }
@SuppressWarnings("deprecation") @Override public void shutdown() { if (cpHost != null) { try { cpHost.preShutdown(); } catch (IOException ioe) { LOG.error("Error call master coprocessor preShutdown()", ioe); } } if (mxBean != null) { MBeanUtil.unregisterMBean(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); } }
public DummyMaster(ZKWatcher 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(); }
clusterStatusTracker.setClusterUp(); activeMasterManager.blockUntilBecomingActiveMaster(100, Mockito.mock(MonitoredTask.class));
public void shutdown() { if (cpHost != null) { try { cpHost.preShutdown(); } catch (IOException ioe) { LOG.error("Error call master coprocessor preShutdown()", ioe); } } if (this.serverManager != null) { this.serverManager.shutdownCluster(); } if (this.clusterStatusTracker != null){ try { this.clusterStatusTracker.setClusterDown(); } catch (KeeperException e) { LOG.error("ZooKeeper exception trying to set cluster as down in ZK", e); } } }
/** * 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); }