public BookieServer newBookie() throws Exception { ServerConfiguration bookieConf = new ServerConfiguration(); bookieConf.setZkTimeout(zkTimeoutSec * 1000); bookieConf.setBookiePort(0); bookieConf.setAllowLoopback(true); File tmpdir = File.createTempFile("bookie" + UUID.randomUUID() + "_", "test"); if (!tmpdir.delete()) { LOG.debug("Fail to delete tmpdir " + tmpdir); } if (!tmpdir.mkdir()) { throw new IOException("Fail to create tmpdir " + tmpdir); } tmpDirs.add(tmpdir); bookieConf.setZkServers(zkEnsemble); bookieConf.setJournalDirName(tmpdir.getPath()); bookieConf.setLedgerDirNames(new String[]{tmpdir.getPath()}); BookieServer b = new BookieServer(bookieConf); b.start(); for (int i = 0; i < 10 && !b.isRunning(); i++) { Thread.sleep(10000); } if (!b.isRunning()) { throw new IOException("Bookie would not start"); } return b; }
/** * Start a bookie with the given bookie instance. Also, starts the auto recovery for this bookie, if * isAutoRecoveryEnabled is true. */ protected BookieServer startBookie(ServerConfiguration conf, final Bookie b) throws Exception { BookieServer server = new BookieServer(conf) { @Override protected Bookie newBookie(ServerConfiguration conf) throws IOException, KeeperException, InterruptedException, BookieException { return b; } }; server.start(); int port = conf.getBookiePort(); while (bkc.getZkHandle().exists( "/ledgers/available/" + InetAddress.getLocalHost().getHostAddress() + ":" + port, false) == null) { Thread.sleep(500); } bkc.readBookiesBlocking(); LOG.info("New bookie on port " + port + " has been created."); return server; }
/** * Helper method to startup a bookie server using a configuration object. Also, starts the auto recovery process if * isAutoRecoveryEnabled is true. * * @param conf * Server Configuration Object * */ protected BookieServer startBookie(ServerConfiguration conf) throws Exception { BookieServer server = new BookieServer(conf); bsConfs.add(conf); bs.add(server); server.start(); if (bkc == null) { bkc = new BookKeeperTestClient(baseClientConf); } int port = conf.getBookiePort(); while (bkc.getZkHandle().exists( "/ledgers/available/" + InetAddress.getLocalHost().getHostAddress() + ":" + port, false) == null) { Thread.sleep(500); } bkc.readBookiesBlocking(); LOG.info("New bookie on port " + port + " has been created."); return server; }
@Override protected void doStart() { try { this.server.start(); } catch (IOException | UnavailableException | InterruptedException | BKException e) { throw new RuntimeException("Failed to start bookie server", e); } }
public void start() throws Exception { if (bookieStatsProvider != null) { bookieStatsProvider.start(bookieConfig); log.info("started bookieStatsProvider."); } if (bookieServer != null) { bookieServer.start(); log.info("started bookieServer."); } if (autoRecoveryMain != null) { autoRecoveryMain.start(); log.info("started bookie autoRecoveryMain."); } pulsarService.start(); log.info("PulsarService started."); }
bs[i].start(); LOG.debug("Local BK[{}] started (port: {}, data_directory: {})", i, bookiePort, bkDataDir.getAbsolutePath());
bs.start(); return bs;
bookieServer.start(); for (int i = 0; i < 100; i++) { if (bookieServer.getBookie().isRunning()) {