getMasterLock(zroot + Constants.ZMASTER_LOCK);
TableManager.getInstance().addObserver(this);
recovery = new CoordinateRecoveryTask(fs);
Thread recoveryThread = new Daemon(new LoggingRunnable(log, recovery), "Recovery Status");
recoveryThread.start();
loggers = new TabletServerLoggers(this, ServerConfiguration.getSystemConfiguration());
loggers.scanZooKeeperForUpdates();
StatusThread statusThread = new StatusThread();
statusThread.start();
MigrationCleanupThread migrationCleanupThread = new MigrationCleanupThread();
migrationCleanupThread.start();
tserverSet.startListeningForTabletServerChanges();
AuthInfo systemAuths = SecurityConstants.getSystemCredentials();
final TabletStateStore stores[] = {new ZooTabletStateStore(new ZooStore(zroot)), new RootTabletStateStore(instance, systemAuths, this),
new MetaDataStateStore(instance, systemAuths, this)};
watchers.add(new TabletGroupWatcher(stores[2], null));
watchers.add(new TabletGroupWatcher(stores[1], watchers.get(0)));
watchers.add(new TabletGroupWatcher(stores[0], watchers.get(1)));
for (TabletGroupWatcher watcher : watchers) {
watcher.start();
}
// TODO: add shutdown for fate object
try {
fate = new Fate<Master>(this, new org.apache.accumulo.server.fate.ZooStore<Master>(ZooUtil.getRoot(instance) + Constants.ZFATE,
ZooReaderWriter.getRetryingInstance()), fateThreadCount);
} catch (KeeperException e) {
throw new IOException(e);
} catch (InterruptedException e) {
throw new IOException(e);
}
Processor processor = new MasterClientService.Processor(TraceWrap.service(new MasterClientServiceHandler()));
clientService = TServerUtils.startServer(Property.MASTER_CLIENTPORT, processor, "Master", "Master Client Service Handler", null,
Property.MASTER_MINTHREADS, Property.MASTER_THREADCHECK).server;
while (!clientService.isServing()) {
UtilWaitThread.sleep(100);
}
while (clientService.isServing()) {
UtilWaitThread.sleep(500);
}
final long deadline = System.currentTimeMillis() + MAX_CLEANUP_WAIT_TIME;
statusThread.join(remaining(deadline));
recovery.stop();
recoveryThread.join(remaining(deadline));
// quit, even if the tablet servers somehow jam up and the watchers
// don't stop
for (TabletGroupWatcher watcher : watchers) {
watcher.join(remaining(deadline));