/** * Kill a bookie by index. Also, stops the respective auto recovery process for this bookie, if * isAutoRecoveryEnabled is true. * * @param index * Bookie Index * @return the configuration of killed bookie * @throws InterruptedException * @throws IOException */ public ServerConfiguration killBookie(int index) throws Exception { if (index >= bs.size()) { throw new IOException("Bookie does not exist"); } BookieServer server = bs.get(index); server.shutdown(); stopAutoRecoveryService(server); bs.remove(server); return bsConfs.remove(index); }
/** * Restart bookie servers using new configuration settings. Also restart the respective auto recovery process, if * isAutoRecoveryEnabled is true. * * @param newConf * New Configuration Settings * @throws InterruptedException * @throws IOException * @throws KeeperException * @throws BookieException */ public void restartBookies(ServerConfiguration newConf) throws Exception { // shut down bookie server for (BookieServer server : bs) { server.shutdown(); stopAutoRecoveryService(server); } bs.clear(); Thread.sleep(1000); // restart them to ensure we can't List<ServerConfiguration> bsConfsCopy = new ArrayList<ServerConfiguration>(bsConfs); bsConfs.clear(); for (ServerConfiguration conf : bsConfsCopy) { if (null != newConf) { conf.loadConf(newConf); } startBookie(conf); } }
/** * Stop cluster. Also, stops all the auto recovery processes for the bookie cluster, if isAutoRecoveryEnabled is * true. * * @throws Exception */ protected void stopBKCluster() throws Exception { if (bkc != null) { bkc.close(); } for (BookieServer server : bs) { server.shutdown(); AutoRecoveryMain autoRecovery = autoRecoveryProcesses.get(server); if (autoRecovery != null && isAutoRecoveryEnabled()) { autoRecovery.shutdown(); LOG.debug("Shutdown auto recovery for bookieserver:" + server.getLocalAddress()); } } bs.clear(); for (File f : tmpDirs) { FileUtils.deleteDirectory(f); } }
/** * Kill a bookie by its socket address. Also, stops the autorecovery process for the corresponding bookie server, if * isAutoRecoveryEnabled is true. * * @param addr * Socket Address * @return the configuration of killed bookie * @throws InterruptedException */ public ServerConfiguration killBookie(InetSocketAddress addr) throws Exception { BookieServer toRemove = null; int toRemoveIndex = 0; for (BookieServer server : bs) { if (server.getLocalAddress().equals(addr)) { server.shutdown(); toRemove = server; break; } ++toRemoveIndex; } if (toRemove != null) { stopAutoRecoveryService(toRemove); bs.remove(toRemove); return bsConfs.remove(toRemoveIndex); } return null; }
assertEquals("replacement bookie didn't start", ensembleSize + 1, bkutil.checkBookiesUp(ensembleSize + 1, 10)); bookieToFail.shutdown(); assertEquals("New bookie didn't die", ensembleSize, bkutil.checkBookiesUp(ensembleSize, 10)); } finally { if (replacementBookie != null) { replacementBookie.shutdown(); bookieToFail.shutdown();
@Override protected void doClose() throws IOException { this.server.shutdown(); } }
public void shutdownBookies() { for (BookieServer bookieServer: bs) { bookieServer.shutdown(); } }
/** * Stops the BookieService with the given index. * * @param bookieIndex The index of the bookie to stop. */ public void stopBookie(int bookieIndex) { Preconditions.checkState(this.servers.size() > 0, "No Bookies initialized. Call startAll()."); Preconditions.checkState(this.servers.get(0) != null, "Bookie already stopped."); val bk = this.servers.get(bookieIndex); bk.shutdown(); this.servers.set(bookieIndex, null); log.info("Bookie {} stopped.", bookieIndex); }
@Override public void close() { if (bookieServer != null) { LOG.info("Apache Bookkeeper stopping"); try { bookieServer.shutdown(); bookieServer.join(); } catch (InterruptedException err) { Thread.currentThread().interrupt(); } finally { bookieServer = null; } } }
DeathWatcher(ServerConfiguration conf) { super("BookieDeathWatcher-" + conf.getBookiePort()); watchInterval = conf.getDeathWatchInterval(); // set a default uncaught exception handler to shutdown the bookie server // when it notices the bookie is not running any more. setUncaughtExceptionHandler((thread, cause) -> { LOG.info("BookieDeathWatcher exited loop due to uncaught exception from thread {}", thread.getName(), cause); shutdown(); }); }
public void stop() throws Exception { if (null != streamStorage) { LOG.debug("Local bk stream storage stopping ..."); streamStorage.close(); } LOG.debug("Local ZK/BK stopping ..."); for (BookieServer bookie : bs) { bookie.shutdown(); } zkc.close(); zks.shutdown(); serverFactory.shutdown(); LOG.debug("Local ZK/BK stopped"); }
public void shutdown() { if (null != functionsWorkerService) { functionsWorkerService.stop(); log.info("Shut down functions worker service successfully."); } pulsarService.getShutdownService().run(); log.info("Shut down broker service successfully."); if (bookieStatsProvider != null) { bookieStatsProvider.stop(); log.info("Shut down bookieStatsProvider successfully."); } if (bookieServer != null) { bookieServer.shutdown(); log.info("Shut down bookieServer successfully."); } if (autoRecoveryMain != null) { autoRecoveryMain.shutdown(); log.info("Shut down autoRecoveryMain successfully."); } } }