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; }
public BookieService(BookieConfiguration conf, StatsLogger statsLogger) throws Exception { super(NAME, conf, statsLogger); this.server = new BookieServer(conf.getServerConf(), statsLogger); }
bs[i] = new BookieServer(bsConfs[i], NullStatsLogger.INSTANCE); } catch (InvalidCookieException e) { bs[i] = new BookieServer(bsConfs[i], NullStatsLogger.INSTANCE);
val bs = new BookieServer(conf); bs.start(); return bs;
serializeLocalBookieConfig(bsConfs[i], fileName); bs[i] = new BookieServer(bsConfs[i]); bs[i].start();
bookieServer = new BookieServer(conf, statsLogger); bookieServer.start(); for (int i = 0; i < 100; i++) {
checkNotNull(bookieConfig, "No ServerConfiguration for Bookie"); checkNotNull(bookieStatsProvider, "No Stats Provider for Bookie"); bookieServer = new BookieServer(bookieConfig, bookieStatsProvider.getStatsLogger("")); } else { bookieServer = null;